diff options
473 files changed, 12485 insertions, 7872 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b70110947b..f3614007ef9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ unset(PLATFORM_DEFAULT) if(UNIX AND NOT APPLE) option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON) option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON) - option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON) + option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON) # freebsd doesn't seems to support XDND if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") @@ -167,9 +167,20 @@ if(UNIX AND NOT APPLE) endif() else() # not an option for other OS's - set(WITH_BUILTIN_GLEW ON) + set(WITH_SYSTEM_GLEW OFF) endif() + +# (unix defaults to System OpenJPEG On) +if(UNIX AND NOT APPLE) + set(PLATFORM_DEFAULT ON) +else() + set(PLATFORM_DEFAULT OFF) +endif() +option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" ${PLATFORM_DEFAULT}) +unset(PLATFORM_DEFAULT) + + # Modifiers option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON) option(WITH_MOD_SMOKE "Enable Smoke Modifier (Smoke Simulation)" ON) @@ -1485,10 +1496,11 @@ endif() if(WITH_IMAGE_OPENJPEG) - if(UNIX AND NOT APPLE) + if(WITH_SYSTEM_OPENJPEG) # dealt with above else() set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg") + add_definitions(-DOPJ_STATIC) endif() endif() @@ -1539,20 +1551,20 @@ endif() #----------------------------------------------------------------------------- # Configure GLEW -if(WITH_BUILTIN_GLEW) - # set(GLEW_LIBRARY "") # unused - set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include") -else() +if(WITH_SYSTEM_GLEW) find_package(GLEW) if(NOT GLEW_FOUND) - message(FATAL_ERROR "GLEW is required to build blender, install it or use WITH_BUILTIN_GLEW") + message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW") endif() mark_as_advanced( GLEW_LIBRARY GLEW_INCLUDE_PATH ) +else() + # set(GLEW_LIBRARY "") # unused + set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include") endif() #----------------------------------------------------------------------------- @@ -1790,8 +1802,9 @@ if(FIRST_RUN) info_cfg_option(WITH_INSTALL_PORTABLE) info_cfg_option(WITH_X11_XF86VMODE) info_cfg_option(WITH_X11_XINPUT) - info_cfg_option(WITH_BUILTIN_GLEW) info_cfg_option(WITH_MEM_JEMALLOC) + info_cfg_option(WITH_SYSTEM_GLEW) + info_cfg_option(WITH_SYSTEM_OPENJPEG) info_cfg_text("Image Formats:") info_cfg_option(WITH_IMAGE_CINEON) diff --git a/SConstruct b/SConstruct index 9bc61d7aeb2..088361af649 100644 --- a/SConstruct +++ b/SConstruct @@ -240,6 +240,7 @@ print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBU if 'blenderlite' in B.targets: target_env_defs = {} target_env_defs['WITH_BF_GAMEENGINE'] = False + target_env_defs['WITH_BF_CYCLES'] = False target_env_defs['WITH_BF_OPENAL'] = False target_env_defs['WITH_BF_OPENEXR'] = False target_env_defs['WITH_BF_OPENMP'] = False diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake index d19f0cf32e8..e2adc17a2e8 100644 --- a/build_files/cmake/config/blender_lite.cmake +++ b/build_files/cmake/config/blender_lite.cmake @@ -6,9 +6,9 @@ # set(WITH_INSTALL_PORTABLE ON CACHE FORCE BOOL) +set(WITH_SYSTEM_GLEW ON CACHE FORCE BOOL) set(WITH_BUILDINFO OFF CACHE FORCE BOOL) -set(WITH_BUILTIN_GLEW OFF CACHE FORCE BOOL) set(WITH_BULLET OFF CACHE FORCE BOOL) set(WITH_CODEC_FFMPEG OFF CACHE FORCE BOOL) set(WITH_CODEC_SNDFILE OFF CACHE FORCE BOOL) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 2b61ddca648..61a89b568ad 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -193,7 +193,7 @@ macro(SETUP_LIBDIRS) if(WITH_OPENIMAGEIO) link_directories(${OPENIMAGEIO_LIBPATH}) endif() - if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) + if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG) link_directories(${OPENJPEG_LIBPATH}) endif() if(WITH_CODEC_QUICKTIME) @@ -253,7 +253,7 @@ macro(setup_liblinks endif() endif() - if(NOT WITH_BUILTIN_GLEW) + if(WITH_SYSTEM_GLEW) target_link_libraries(${target} ${GLEW_LIBRARY}) endif() @@ -303,7 +303,7 @@ macro(setup_liblinks target_link_libraries(${target} ${OPENEXR_LIBRARIES}) endif() endif() - if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) + if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG) target_link_libraries(${target} ${OPENJPEG_LIBRARIES}) endif() if(WITH_CODEC_FFMPEG) diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index dc83411adac..723651971d0 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -181,7 +181,7 @@ CXX = 'g++' CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ] CXXFLAGS = [] -CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC'] +CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-DNDEBUG', '-O2'] diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index db30f453228..6b0c4338567 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -188,7 +188,7 @@ BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast', '/arch:SSE'] BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr'] -CPPFLAGS = ['-DWIN32','-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE'] +CPPFLAGS = ['-DWIN32','-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-O2', '-DNDEBUG'] diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index cecf91e48a8..2649c5505d5 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -179,7 +179,7 @@ CXX = 'g++' CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ] CXXFLAGS = [ '-fpermissive' ] -CPPFLAGS = ['-DWIN32', '-DMS_WIN64', '-DFREE_WINDOWS', '-DFREE_WINDOWS64', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC'] +CPPFLAGS = ['-DWIN32', '-DMS_WIN64', '-DFREE_WINDOWS', '-DFREE_WINDOWS64', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-DNDEBUG', '-O2', '-ftree-vectorize'] diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index fe16278dd19..1f873360a3b 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -186,7 +186,7 @@ BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast'] BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr', '/Od'] -CPPFLAGS = ['-DWIN32', '-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE'] +CPPFLAGS = ['-DWIN32', '-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-O2', '-DNDEBUG'] diff --git a/doc/python_api/examples/bpy.ops.2.py b/doc/python_api/examples/bpy.ops.2.py index 86b7438888c..575d020a5a0 100644 --- a/doc/python_api/examples/bpy.ops.2.py +++ b/doc/python_api/examples/bpy.ops.2.py @@ -15,4 +15,3 @@ you would pass {'active_object': object}. import bpy override = {'selected_bases': list(bpy.context.scene.object_bases)} bpy.ops.object.delete(override) - diff --git a/doc/python_api/examples/bpy.ops.3.py b/doc/python_api/examples/bpy.ops.3.py index 0b5bcafe5be..7dec69cf566 100644 --- a/doc/python_api/examples/bpy.ops.3.py +++ b/doc/python_api/examples/bpy.ops.3.py @@ -9,10 +9,9 @@ import bpy for window in bpy.context.window_manager.windows: screen = window.screen - + for area in screen.areas: if area.type == 'VIEW_3D': override = {'window': window, 'screen': screen, 'area': area} bpy.ops.screen.screen_full_area(override) break - diff --git a/doc/python_api/examples/bpy.types.Object.py b/doc/python_api/examples/bpy.types.Object.py index 5301797aae2..2ddce248a5b 100644 --- a/doc/python_api/examples/bpy.types.Object.py +++ b/doc/python_api/examples/bpy.types.Object.py @@ -2,7 +2,7 @@ Basic Object Operations Example +++++++++++++++++++++++++++++++ This script demonstrates basic operations on object like creating new -object, placing it into scene, selecting it and making it active +object, placing it into scene, selecting it and making it active. """ import bpy @@ -11,15 +11,15 @@ from mathutils import Matrix scene = bpy.context.scene # Create new lamp datablock -lamp_data = bpy.data.lamps.new(name="New Lamp", type="POINT") +lamp_data = bpy.data.lamps.new(name="New Lamp", type='POINT') -# Create new object with out lamp datablock +# Create new object with our lamp datablock lamp_object = bpy.data.objects.new(name="New Lamp", object_data=lamp_data) # Link lamp object to the scene so it'll appear in this scene scene.objects.link(lamp_object) -# Place lamp to specified location +# Place lamp to a specified location lamp_object.location = (5.0, 5.0, 5.0) # And finally select it make active diff --git a/doc/python_api/examples/bpy.types.Panel.1.py b/doc/python_api/examples/bpy.types.Panel.1.py index cd85d30cea0..fbcdae8baeb 100644 --- a/doc/python_api/examples/bpy.types.Panel.1.py +++ b/doc/python_api/examples/bpy.types.Panel.1.py @@ -2,7 +2,7 @@ Simple Object Panel +++++++++++++++++++ This panel has a :class:`Panel.poll` and :class:`Panel.draw_header` function, -even though the contents is basic this closely resemples blenders panels. +even though the contents is basic this closely resembles blenders panels. """ import bpy diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 1d83410a3d7..b5f94c06d4c 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -40,7 +40,7 @@ if(WITH_BINRELOC) add_subdirectory(binreloc) endif() -if(WITH_BUILTIN_GLEW) +if(NOT WITH_SYSTEM_GLEW) add_subdirectory(glew) endif() @@ -48,7 +48,7 @@ if(WITH_GAMEENGINE) add_subdirectory(recastnavigation) endif() -if(WITH_IMAGE_OPENJPEG AND (NOT UNIX OR APPLE)) +if(WITH_IMAGE_OPENJPEG AND (NOT WITH_SYSTEM_OPENJPEG)) add_subdirectory(libopenjpeg) endif() diff --git a/extern/libopenjpeg/CMakeLists.txt b/extern/libopenjpeg/CMakeLists.txt index 6967048ac83..c602ddcabb9 100644 --- a/extern/libopenjpeg/CMakeLists.txt +++ b/extern/libopenjpeg/CMakeLists.txt @@ -54,6 +54,11 @@ set(SRC t2.c tcd.c tgt.c + cidx_manager.c + phix_manager.c + ppix_manager.c + thix_manager.c + tpix_manager.c bio.h cio.h @@ -78,6 +83,9 @@ set(SRC t2.h tcd.h tgt.h + cidx_manager.h + indexbox_manager.h + opj_config.h ) blender_add_lib(extern_openjpeg "${SRC}" "${INC}" "${INC_SYS}") diff --git a/extern/libopenjpeg/cidx_manager.c b/extern/libopenjpeg/cidx_manager.c new file mode 100644 index 00000000000..6131b938ea6 --- /dev/null +++ b/extern/libopenjpeg/cidx_manager.c @@ -0,0 +1,213 @@ +/* + * $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include "opj_includes.h" + + +/* + * Write CPTR Codestream finder box + * + * @param[in] coff offset of j2k codestream + * @param[in] clen length of j2k codestream + * @param[in] cio file output handle + */ +void write_cptr(int coff, int clen, opj_cio_t *cio); + + +/* + * Write main header index table (box) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] cio file output handle + * @return length of mainmhix box + */ +int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio); + + +/* + * Check if EPH option is used + * + * @param[in] coff offset of j2k codestream + * @param[in] markers marker information + * @param[in] marknum number of markers + * @param[in] cio file output handle + * @return true if EPH is used + */ +opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio); + + +int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen) +{ + int len, i, lenp; + opj_jp2_box_t *box; + int num_box = 0; + opj_bool EPHused; + (void)image; /* unused ? */ + + lenp = -1; + box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t)); + + for (i=0;i<2;i++){ + + if(i) + cio_seek( cio, lenp); + + lenp = cio_tell( cio); + + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_CIDX, 4); /* CIDX */ + write_cptr( offset, cstr_info.codestream_size, cio); + + write_manf( i, num_box, box, cio); + + num_box = 0; + box[num_box].length = write_mainmhix( offset, cstr_info, cio); + box[num_box].type = JPIP_MHIX; + num_box++; + + box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio); + box[num_box].type = JPIP_TPIX; + num_box++; + + box[num_box].length = write_thix( offset, cstr_info, cio); + box[num_box].type = JPIP_THIX; + num_box++; + + EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio); + + box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio); + box[num_box].type = JPIP_PPIX; + num_box++; + + box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio); + box[num_box].type = JPIP_PHIX; + num_box++; + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free( box); + + return len; +} + +void write_cptr(int coff, int clen, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_CPTR, 4); /* T */ + cio_write( cio, 0, 2); /* DR A PRECISER !! */ + cio_write( cio, 0, 2); /* CONT */ + cio_write( cio, coff, 8); /* COFF A PRECISER !! */ + cio_write( cio, clen, 8); /* CLEN */ + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); +} + +void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio) +{ + int len, lenp, i; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_MANF,4); /* T */ + + if (second){ /* Write only during the second pass */ + for( i=0; i<v; i++){ + cio_write( cio, box[i].length, 4); /* Box length */ + cio_write( cio, box[i].type, 4); /* Box type */ + } + } + + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); +} + +int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio) +{ + int i; + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_MHIX, 4); /* MHIX */ + + cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8); /* TLEN */ + + for(i = 1; i < cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */ + cio_write( cio, cstr_info.marker[i].type, 2); + cio_write( cio, 0, 2); + cio_write( cio, cstr_info.marker[i].pos-coff, 8); + cio_write( cio, cstr_info.marker[i].len, 2); + } + + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} + +opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio) +{ + opj_bool EPHused = OPJ_FALSE; + int i=0; + int org_pos; + unsigned int Scod; + + for(i = 0; i < marknum; i++){ + if( markers[i].type == J2K_MS_COD){ + org_pos = cio_tell( cio); + cio_seek( cio, coff+markers[i].pos+2); + + Scod = cio_read( cio, 1); + if( ((Scod >> 2) & 1)) + EPHused = OPJ_TRUE; + cio_seek( cio, org_pos); + + break; + } + } + return EPHused; +} diff --git a/extern/libopenjpeg/cidx_manager.h b/extern/libopenjpeg/cidx_manager.h new file mode 100644 index 00000000000..23eebd52baa --- /dev/null +++ b/extern/libopenjpeg/cidx_manager.h @@ -0,0 +1,56 @@ +/* + * $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.h from 2KAN indexer + */ + + +#ifndef CIDX_MANAGER_H_ +# define CIDX_MANAGER_H_ + +#include "openjpeg.h" + + +/* + * Write Codestream index box (superbox) + * + * @param[in] offset offset of j2k codestream + * @param[in] cio file output handle + * @param[in] image image data + * @param[in] cstr_info codestream information + * @param[in] j2klen length of j2k codestream + * @return length of cidx box + */ +int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen); + + +#endif /* !CIDX_MANAGER_H_ */ diff --git a/extern/libopenjpeg/cio.c b/extern/libopenjpeg/cio.c index 2ac262a1f6b..b8a7ecf8a87 100644 --- a/extern/libopenjpeg/cio.c +++ b/extern/libopenjpeg/cio.c @@ -126,13 +126,13 @@ unsigned char *cio_getbp(opj_cio_t *cio) { /* * Write a byte. */ -bool cio_byteout(opj_cio_t *cio, unsigned char v) { +opj_bool cio_byteout(opj_cio_t *cio, unsigned char v) { if (cio->bp >= cio->end) { opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n"); - return false; + return OPJ_FALSE; } *cio->bp++ = v; - return true; + return OPJ_TRUE; } /* @@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) { * v : value to write * n : number of bytes to write */ -unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) { +unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n) { int i; for (i = n - 1; i >= 0; i--) { if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) ) diff --git a/extern/libopenjpeg/cio.h b/extern/libopenjpeg/cio.h index 580bf9c0d12..ce1a13ecb3a 100644 --- a/extern/libopenjpeg/cio.h +++ b/extern/libopenjpeg/cio.h @@ -63,7 +63,7 @@ Write some bytes @param n Number of bytes to write @return Returns the number of bytes written or 0 if an error occured */ -unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n); +unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n); /** Read some bytes @param cio CIO handle diff --git a/extern/libopenjpeg/dwt.c b/extern/libopenjpeg/dwt.c index 357b475b9ac..0fbfc2033fe 100644 --- a/extern/libopenjpeg/dwt.c +++ b/extern/libopenjpeg/dwt.c @@ -64,12 +64,12 @@ typedef struct v4dwt_local { int cas ; } v4dwt_t ; -static const float dwt_alpha = 1.586134342f; // 12994 -static const float dwt_beta = 0.052980118f; // 434 -static const float dwt_gamma = -0.882911075f; // -7233 -static const float dwt_delta = -0.443506852f; // -3633 +static const float dwt_alpha = 1.586134342f; /* 12994 */ +static const float dwt_beta = 0.052980118f; /* 434 */ +static const float dwt_gamma = -0.882911075f; /* -7233 */ +static const float dwt_delta = -0.443506852f; /* -3633 */ -static const float K = 1.230174105f; // 10078 +static const float K = 1.230174105f; /* 10078 */ /* FIXME: What is this constant? */ static const float c13318 = 1.625732422f; @@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1 int w = tilec->x1 - tilec->x0; - h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int)); + h.mem = (int*)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int)); v.mem = h.mem; while( --numres) { @@ -570,6 +570,20 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in int count = w->sn; int i, k; for(k = 0; k < 2; ++k){ + if (count + 3 * x < size && ((size_t) a & 0x0f) == 0 && ((size_t) bi & 0x0f) == 0 && (x & 0x0f) == 0) { + /* Fast code path */ + for(i = 0; i < count; ++i){ + int j = i; + bi[i*8 ] = a[j]; + j += x; + bi[i*8 + 1] = a[j]; + j += x; + bi[i*8 + 2] = a[j]; + j += x; + bi[i*8 + 3] = a[j]; + } + } else { + /* Slow code path */ for(i = 0; i < count; ++i){ int j = i; bi[i*8 ] = a[j]; @@ -583,6 +597,7 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in if(j > size) continue; bi[i*8 + 3] = a[j]; } + } bi = (float*) (w->wavelet + 1 - w->cas); a += w->sn; size -= w->sn; @@ -608,9 +623,21 @@ static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){ static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){ __m128* restrict vw = (__m128*) w; int i; + /* 4x unrolled loop */ + for(i = 0; i < count >> 2; ++i){ + *vw = _mm_mul_ps(*vw, c); + vw += 2; + *vw = _mm_mul_ps(*vw, c); + vw += 2; + *vw = _mm_mul_ps(*vw, c); + vw += 2; + *vw = _mm_mul_ps(*vw, c); + vw += 2; + } + count &= 3; for(i = 0; i < count; ++i){ - __m128 tmp = vw[i*2]; - vw[i*2] = _mm_mul_ps(tmp, c); + *vw = _mm_mul_ps(*vw, c); + vw += 2; } } @@ -618,14 +645,16 @@ static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){ __m128* restrict vl = (__m128*) l; __m128* restrict vw = (__m128*) w; int i; + __m128 tmp1, tmp2, tmp3; + tmp1 = vl[0]; for(i = 0; i < m; ++i){ - __m128 tmp1 = vl[ 0]; - __m128 tmp2 = vw[-1]; - __m128 tmp3 = vw[ 0]; + tmp2 = vw[-1]; + tmp3 = vw[ 0]; vw[-1] = _mm_add_ps(tmp2, _mm_mul_ps(_mm_add_ps(tmp1, tmp3), c)); - vl = vw; + tmp1 = tmp3; vw += 2; } + vl = vw - 2; if(m >= k){ return; } @@ -773,19 +802,24 @@ void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){ h.dn = rw - h.sn; h.cas = res->x0 % 2; - for(j = rh; j > 0; j -= 4){ + for(j = rh; j > 3; j -= 4){ + int k; v4dwt_interleave_h(&h, aj, w, bufsize); v4dwt_decode(&h); - if(j >= 4){ - int k; for(k = rw; --k >= 0;){ aj[k ] = h.wavelet[k].f[0]; aj[k+w ] = h.wavelet[k].f[1]; aj[k+w*2] = h.wavelet[k].f[2]; aj[k+w*3] = h.wavelet[k].f[3]; } - }else{ + aj += w*4; + bufsize -= w*4; + } + if (rh & 0x03) { int k; + j = rh & 0x03; + v4dwt_interleave_h(&h, aj, w, bufsize); + v4dwt_decode(&h); for(k = rw; --k >= 0;){ switch(j) { case 3: aj[k+w*2] = h.wavelet[k].f[2]; @@ -794,30 +828,29 @@ void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){ } } } - aj += w*4; - bufsize -= w*4; - } v.dn = rh - v.sn; v.cas = res->y0 % 2; aj = (float*) tilec->data; - for(j = rw; j > 0; j -= 4){ + for(j = rw; j > 3; j -= 4){ + int k; v4dwt_interleave_v(&v, aj, w); v4dwt_decode(&v); - if(j >= 4){ - int k; for(k = 0; k < rh; ++k){ memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(float)); } - }else{ + aj += 4; + } + if (rw & 0x03){ int k; + j = rw & 0x03; + v4dwt_interleave_v(&v, aj, w); + v4dwt_decode(&v); for(k = 0; k < rh; ++k){ memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(float)); } } - aj += 4; - } } opj_aligned_free(h.wavelet); diff --git a/extern/libopenjpeg/event.c b/extern/libopenjpeg/event.c index fe46e423552..0dc22f12549 100644 --- a/extern/libopenjpeg/event.c +++ b/extern/libopenjpeg/event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,8 +29,9 @@ /* ========================================================== Utility functions ==========================================================*/ -#if 0 -#if !defined(_MSC_VER) && !defined(__MINGW32__) + +#ifdef OPJ_CODE_NOT_USED +#ifndef _WIN32 static char* i2a(unsigned i, char *a, unsigned r) { if (i/r > 0) a = i2a(i/r,a,r); @@ -57,8 +58,8 @@ _itoa(int i, char *a, int r) { return a; } -#endif /* !WIN32 */ -#endif /* unused - campbell */ +#endif /* !_WIN32 */ +#endif /* ----------------------------------------------------------------------- */ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) { @@ -72,7 +73,7 @@ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_ return NULL; } -bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { +opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { #define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */ opj_msg_callback msg_handler = NULL; @@ -92,10 +93,10 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { break; } if(msg_handler == NULL) { - return false; + return OPJ_FALSE; } } else { - return false; + return OPJ_FALSE; } if ((fmt != NULL) && (event_mgr != NULL)) { @@ -116,6 +117,6 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { msg_handler(message, cinfo->client_data); } - return true; + return OPJ_TRUE; } diff --git a/extern/libopenjpeg/event.h b/extern/libopenjpeg/event.h index 11910b0e4bc..9c59787caf3 100644 --- a/extern/libopenjpeg/event.h +++ b/extern/libopenjpeg/event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ Write formatted data to a string and send the string to a user callback. @param fmt Format-control string (plus optionnal arguments) @return Returns true if successful, returns false otherwise */ -bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...); +opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/image.c b/extern/libopenjpeg/image.c index ea8e59ea547..7c1e7f7faa2 100644 --- a/extern/libopenjpeg/image.c +++ b/extern/libopenjpeg/image.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,7 @@ #include "opj_includes.h" opj_image_t* opj_image_create0(void) { - opj_image_t *image = (opj_image_t*)opj_malloc(sizeof(opj_image_t)); + opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t)); return image; } @@ -86,4 +86,3 @@ void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) { opj_free(image); } } - diff --git a/extern/libopenjpeg/image.h b/extern/libopenjpeg/image.h index 04c362eb834..f828b5b77c8 100644 --- a/extern/libopenjpeg/image.h +++ b/extern/libopenjpeg/image.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/extern/libopenjpeg/indexbox_manager.h b/extern/libopenjpeg/indexbox_manager.h new file mode 100644 index 00000000000..7364df62c22 --- /dev/null +++ b/extern/libopenjpeg/indexbox_manager.h @@ -0,0 +1,118 @@ +/* + * $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#ifndef INDEXBOX_MANAGER_H_ +# define INDEXBOX_MANAGER_H_ + +#include "openjpeg.h" +#include "j2k.h" /* needed to use jp2.h */ +#include "jp2.h" + +#define JPIP_CIDX 0x63696478 /* Codestream index */ +#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */ +#define JPIP_MANF 0x6d616e66 /* Manifest Box */ +#define JPIP_FAIX 0x66616978 /* Fragment array Index box */ +#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */ +#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */ +#define JPIP_THIX 0x74686978 /* Tile header Index Table box */ +#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */ +#define JPIP_PHIX 0x70686978 /* Packet Header index Table */ +#define JPIP_FIDX 0x66696478 /* File Index */ +#define JPIP_FPTR 0x66707472 /* File Finder */ +#define JPIP_PRXY 0x70727879 /* Proxy boxes */ +#define JPIP_IPTR 0x69707472 /* Index finder box */ +#define JPIP_PHLD 0x70686c64 /* Place holder */ + + +/* + * Write tile-part Index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of tpix box + */ +int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio); + + +/* + * Write tile header index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information pointer + * @param[in] cio file output handle + * @return length of thix box + */ +int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio); + + +/* + * Write precinct packet index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] EPHused true if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of ppix box + */ +int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + + +/* + * Write packet header index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] EPHused true if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of ppix box + */ +int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + +/* + * Wriet manifest box (box) + * + * @param[in] second number to be visited + * @param[in] v number of boxes + * @param[in] box box to be manifested + * @param[in] cio file output handle + */ +void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio); + + +#endif /* !INDEXBOX_MANAGER_H_ */ diff --git a/extern/libopenjpeg/j2k.c b/extern/libopenjpeg/j2k.c index 8e7b1ce081f..d34c75faa7b 100644 --- a/extern/libopenjpeg/j2k.c +++ b/extern/libopenjpeg/j2k.c @@ -6,6 +6,7 @@ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2006-2007, Parvatha Elangovan + * Copyright (c) 2010-2011, Kaori Hagihara * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -228,6 +229,23 @@ Read an unknown marker @param j2k J2K handle */ static void j2k_read_unk(opj_j2k_t *j2k); +/** +Add main header marker information +@param cstr_info Codestream information structure +@param type marker type +@param pos byte offset of marker segment +@param len length of marker segment + */ +static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); +/** +Add tile header marker information +@param tileno tile index number +@param cstr_info Codestream information structure +@param type marker type +@param pos byte offset of marker segment +@param len length of marker segment + */ +static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); /*@}*/ @@ -236,7 +254,7 @@ static void j2k_read_unk(opj_j2k_t *j2k); /* ----------------------------------------------------------------------- */ typedef struct j2k_prog_order{ OPJ_PROG_ORDER enum_prog; - char str_prog[4]; + char str_prog[5]; }j2k_prog_order_t; j2k_prog_order_t j2k_prog_order_list[] = { @@ -245,7 +263,7 @@ j2k_prog_order_t j2k_prog_order_list[] = { {PCRL, "PCRL"}, {RLCP, "RLCP"}, {RPCL, "RPCL"}, - {-1, ""} + {(OPJ_PROG_ORDER)-1, ""} }; char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){ @@ -258,79 +276,6 @@ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){ return po->str_prog; } -void j2k_dump_image(FILE *fd, opj_image_t * img) { - int compno; - fprintf(fd, "image {\n"); - fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1); - fprintf(fd, " numcomps=%d\n", img->numcomps); - for (compno = 0; compno < img->numcomps; compno++) { - opj_image_comp_t *comp = &img->comps[compno]; - fprintf(fd, " comp %d {\n", compno); - fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy); - fprintf(fd, " prec=%d\n", comp->prec); - fprintf(fd, " sgnd=%d\n", comp->sgnd); - fprintf(fd, " }\n"); - } - fprintf(fd, "}\n"); -} - -void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) { - int tileno, compno, layno, bandno, resno, numbands; - fprintf(fd, "coding parameters {\n"); - fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0); - fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy); - fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th); - for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { - opj_tcp_t *tcp = &cp->tcps[tileno]; - fprintf(fd, " tile %d {\n", tileno); - fprintf(fd, " csty=%x\n", tcp->csty); - fprintf(fd, " prg=%d\n", tcp->prg); - fprintf(fd, " numlayers=%d\n", tcp->numlayers); - fprintf(fd, " mct=%d\n", tcp->mct); - fprintf(fd, " rates="); - for (layno = 0; layno < tcp->numlayers; layno++) { - fprintf(fd, "%.1f ", tcp->rates[layno]); - } - fprintf(fd, "\n"); - for (compno = 0; compno < img->numcomps; compno++) { - opj_tccp_t *tccp = &tcp->tccps[compno]; - fprintf(fd, " comp %d {\n", compno); - fprintf(fd, " csty=%x\n", tccp->csty); - fprintf(fd, " numresolutions=%d\n", tccp->numresolutions); - fprintf(fd, " cblkw=%d\n", tccp->cblkw); - fprintf(fd, " cblkh=%d\n", tccp->cblkh); - fprintf(fd, " cblksty=%x\n", tccp->cblksty); - fprintf(fd, " qmfbid=%d\n", tccp->qmfbid); - fprintf(fd, " qntsty=%d\n", tccp->qntsty); - fprintf(fd, " numgbits=%d\n", tccp->numgbits); - fprintf(fd, " roishift=%d\n", tccp->roishift); - fprintf(fd, " stepsizes="); - numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2; - for (bandno = 0; bandno < numbands; bandno++) { - fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant, - tccp->stepsizes[bandno].expn); - } - fprintf(fd, "\n"); - - if (tccp->csty & J2K_CCP_CSTY_PRT) { - fprintf(fd, " prcw="); - for (resno = 0; resno < tccp->numresolutions; resno++) { - fprintf(fd, "%d ", tccp->prcw[resno]); - } - fprintf(fd, "\n"); - fprintf(fd, " prch="); - for (resno = 0; resno < tccp->numresolutions; resno++) { - fprintf(fd, "%d ", tccp->prch[resno]); - } - fprintf(fd, "\n"); - } - fprintf(fd, " }\n"); - } - fprintf(fd, " }\n"); - } - fprintf(fd, "}\n"); -} - /* ----------------------------------------------------------------------- */ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){ char *prog; @@ -370,6 +315,9 @@ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){ /** mem allocation for TLM marker*/ int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t *j2k ){ int pino,tileno,totnum_tp=0; + + OPJ_ARG_NOT_USED(img_numcomp); + j2k->cur_totnum_tp = (int *) opj_malloc(cp->tw * cp->th * sizeof(int)); for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { int cur_totnum_tp = 0; @@ -398,12 +346,14 @@ static void j2k_write_soc(opj_j2k_t *j2k) { opj_cio_t *cio = j2k->cio; cio_write(cio, J2K_MS_SOC, 2); + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio), 0); + /* UniPG>> */ #ifdef USE_JPWL /* update markers struct */ j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2); - #endif /* USE_JPWL */ /* <<UniPG */ } @@ -424,7 +374,7 @@ static void j2k_write_siz(opj_j2k_t *j2k) { opj_cio_t *cio = j2k->cio; opj_image_t *image = j2k->image; opj_cp_t *cp = j2k->cp; - + cio_write(cio, J2K_MS_SIZ, 2); /* SIZ */ lenp = cio_tell(cio); cio_skip(cio, 2); @@ -447,6 +397,9 @@ static void j2k_write_siz(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lsiz */ cio_seek(cio, lenp + len); + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SIZ, lenp, len); } static void j2k_read_siz(opj_j2k_t *j2k) { @@ -467,6 +420,13 @@ static void j2k_read_siz(opj_j2k_t *j2k) { cp->tx0 = cio_read(cio, 4); /* XT0siz */ cp->ty0 = cio_read(cio, 4); /* YT0siz */ + if ((image->x0<0)||(image->x1<0)||(image->y0<0)||(image->y1<0)) { + opj_event_msg(j2k->cinfo, EVT_ERROR, + "%s: invalid image size (x0:%d, x1:%d, y0:%d, y1:%d)\n", + image->x0,image->x1,image->y0,image->y1); + return; + } + image->numcomps = cio_read(cio, 2); /* Csiz */ #ifdef USE_JPWL @@ -670,6 +630,11 @@ static void j2k_write_com(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); cio_seek(cio, lenp + len); + + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COM, lenp, len); + } } @@ -713,7 +678,7 @@ static void j2k_read_cox(opj_j2k_t *j2k, int compno) { tccp->numresolutions = cio_read(cio, 1) + 1; /* SPcox (D) */ - // If user wants to remove more resolutions than the codestream contains, return error + /* If user wants to remove more resolutions than the codestream contains, return error*/ if (cp->reduce >= tccp->numresolutions) { opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number " "of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno); @@ -773,6 +738,10 @@ static void j2k_write_cod(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lcod */ cio_seek(cio, lenp + len); + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COD, lenp, len); + } static void j2k_read_cod(opj_j2k_t *j2k) { @@ -901,6 +870,15 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) { }; }; + +#else + /* We check whether there are too many subbands */ + if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) { + opj_event_msg(j2k->cinfo, EVT_WARNING , + "bad number of subbands in Sqcx (%d) regarding to J2K_MAXBANDS (%d) \n" + "- limiting number of bands to J2K_MAXBANDS and try to move to the next markers\n", numbands, J2K_MAXBANDS); + } + #endif /* USE_JPWL */ for (bandno = 0; bandno < numbands; bandno++) { @@ -913,8 +891,10 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) { expn = tmp >> 11; mant = tmp & 0x7ff; } - tccp->stepsizes[bandno].expn = expn; - tccp->stepsizes[bandno].mant = mant; + if (bandno < J2K_MAXBANDS){ + tccp->stepsizes[bandno].expn = expn; + tccp->stepsizes[bandno].mant = mant; + } } /* Add Antonin : if scalar_derived -> compute other stepsizes */ @@ -942,6 +922,9 @@ static void j2k_write_qcd(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lqcd */ cio_seek(cio, lenp + len); + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_QCD, lenp, len); } static void j2k_read_qcd(opj_j2k_t *j2k) { @@ -978,7 +961,7 @@ static void j2k_read_qcc(opj_j2k_t *j2k) { int len, compno; int numcomp = j2k->image->numcomps; opj_cio_t *cio = j2k->cio; - + len = cio_read(cio, 2); /* Lqcc */ compno = cio_read(cio, numcomp <= 256 ? 1 : 2); /* Cqcc */ @@ -1263,6 +1246,10 @@ static void j2k_write_sot(opj_j2k_t *j2k) { j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2); #endif /* USE_JPWL */ /* <<UniPG */ + + if( j2k->cstr_info && j2k->cur_tp_num==0){ + j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOT, lenp, len); + } } static void j2k_read_sot(opj_j2k_t *j2k) { @@ -1346,6 +1333,11 @@ static void j2k_read_sot(opj_j2k_t *j2k) { partno = cio_read(cio, 1); numparts = cio_read(cio, 1); + + if (partno >= numparts) { + opj_event_msg(j2k->cinfo, EVT_WARNING, "SOT marker inconsistency in tile %d: tile-part index greater (%d) than number of tile-parts (%d)\n", tileno, partno, numparts); + numparts = partno+1; + } j2k->curtileno = tileno; j2k->cur_tp_num = partno; @@ -1361,15 +1353,14 @@ static void j2k_read_sot(opj_j2k_t *j2k) { j2k->cstr_info->tile[tileno].tileno = tileno; j2k->cstr_info->tile[tileno].start_pos = cio_tell(cio) - 12; j2k->cstr_info->tile[tileno].end_pos = j2k->cstr_info->tile[tileno].start_pos + totlen - 1; - j2k->cstr_info->tile[tileno].num_tps = numparts; - if (numparts) - j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t)); - else - j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10) - } - else { + } else { j2k->cstr_info->tile[tileno].end_pos += totlen; - } + } + j2k->cstr_info->tile[tileno].num_tps = numparts; + if (numparts) + j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, numparts * sizeof(opj_tp_info_t)); + else + j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, 10 * sizeof(opj_tp_info_t)); /* Fixme (10)*/ j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = cio_tell(cio) - 12; j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos = j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1; @@ -1405,6 +1396,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) { tcd->cur_tp_num = j2k->cur_tp_num; cio_write(cio, J2K_MS_SOD, 2); + + if( j2k->cstr_info && j2k->cur_tp_num==0){ + j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOD, cio_tell(cio), 0); + } + if (j2k->curtileno == 0) { j2k->sod_start = cio_tell(cio) + j2k->pos_correction; } @@ -1431,7 +1427,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) { tcp = &cp->tcps[j2k->curtileno]; for (layno = 0; layno < tcp->numlayers; layno++) { - tcp->rates[layno] -= tcp->rates[layno] ? (j2k->sod_start / (cp->th * cp->tw)) : 0; + if (tcp->rates[layno]>(j2k->sod_start / (cp->th * cp->tw))) { + tcp->rates[layno]-=(j2k->sod_start / (cp->th * cp->tw)); + } else if (tcp->rates[layno]) { + tcp->rates[layno]=1; + } } if(j2k->cur_tp_num == 0){ tcd->tcd_image->tiles->packno = 0; @@ -1554,7 +1554,7 @@ static void j2k_write_eoc(opj_j2k_t *j2k) { static void j2k_read_eoc(opj_j2k_t *j2k) { int i, tileno; - bool success; + opj_bool success; /* if packets should be decoded */ if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) { @@ -1567,7 +1567,7 @@ static void j2k_read_eoc(opj_j2k_t *j2k) { opj_free(j2k->tile_data[tileno]); j2k->tile_data[tileno] = NULL; tcd_free_decode_tile(tcd, i); - if (success == false) { + if (success == OPJ_FALSE) { j2k->state |= J2K_STATE_ERR; break; } @@ -1822,7 +1822,7 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c if (j2k->cp->correct) { int orig_pos = cio_tell(cio); - bool status; + opj_bool status; /* call the corrector */ status = jpwl_correct(j2k); @@ -1861,13 +1861,13 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c return 0; } e = j2k_dec_mstab_lookup(id); - // Check if the marker is known + /* Check if the marker is known*/ if (!(j2k->state & e->states)) { opj_image_destroy(image); opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id); return 0; } - // Check if the decoding is limited to the main header + /* Check if the decoding is limited to the main header*/ if (e->id == J2K_MS_SOT && j2k->cp->limit_decoding == LIMIT_TO_MAIN_HEADER) { opj_event_msg(cinfo, EVT_INFO, "Main Header decoded.\n"); return image; @@ -1893,7 +1893,6 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c if (j2k->state != J2K_STATE_MT) { opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n"); } - return image; } @@ -1905,9 +1904,10 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre opj_image_t *image = NULL; opj_jpt_msg_header_t header; int position; - opj_common_ptr cinfo = j2k->cinfo; - + + OPJ_ARG_NOT_USED(cstr_info); + j2k->cio = cio; /* create an empty image */ @@ -2098,12 +2098,12 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ int i; /* set JPWL on */ - cp->epc_on = true; - cp->info_on = false; /* no informative technique */ + cp->epc_on = OPJ_TRUE; + cp->info_on = OPJ_FALSE; /* no informative technique */ /* set EPB on */ if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) { - cp->epb_on = true; + cp->epb_on = OPJ_TRUE; cp->hprot_MH = parameters->jpwl_hprot_MH; for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) { @@ -2124,7 +2124,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ /* set ESD writing */ if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) { - cp->esd_on = true; + cp->esd_on = OPJ_TRUE; cp->sens_size = parameters->jpwl_sens_size; cp->sens_addr = parameters->jpwl_sens_addr; @@ -2138,10 +2138,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ } /* always set RED writing to false: we are at the encoder */ - cp->red_on = false; + cp->red_on = OPJ_FALSE; } else { - cp->epc_on = false; + cp->epc_on = OPJ_FALSE; } #endif /* USE_JPWL */ @@ -2214,10 +2214,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ if(parameters->cp_cinema) { - //Precinct size for lowest frequency subband=128 + /*Precinct size for lowest frequency subband=128*/ tccp->prcw[0] = 7; tccp->prch[0] = 7; - //Precinct size at all other resolutions = 256 + /*Precinct size at all other resolutions = 256*/ for (j = 1; j < tccp->numresolutions; j++) { tccp->prcw[j] = 8; tccp->prch[j] = 8; @@ -2259,7 +2259,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ } p++; /*printf("\nsize precinct for level %d : %d,%d\n", j,tccp->prcw[j], tccp->prch[j]); */ - } //end for + } /*end for*/ } else { for (j = 0; j < tccp->numresolutions; j++) { tccp->prcw[j] = 15; @@ -2273,7 +2273,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ } } -bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { +opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { int tileno, compno; opj_cp_t *cp = NULL; @@ -2284,8 +2284,6 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre cp = j2k->cp; - /* j2k_dump_cp(stdout, image, cp); */ - /* INDEX >> */ j2k->cstr_info = cstr_info; if (cstr_info) { @@ -2382,6 +2380,9 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre /* INDEX >> */ if(cstr_info) { cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction; + cstr_info->tile[j2k->curtileno].maxmarknum = 10; + cstr_info->tile[j2k->curtileno].marker = (opj_marker_info_t *) opj_malloc(cstr_info->tile[j2k->curtileno].maxmarknum * sizeof(opj_marker_info_t)); + cstr_info->tile[j2k->curtileno].marknum = 0; } /* << INDEX */ @@ -2488,11 +2489,46 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre } #endif /* USE_JPWL */ - return true; + return OPJ_TRUE; +} + +static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) { + + if (!cstr_info) + return; + + /* expand the list? */ + if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) { + cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F); + cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum); + } + + /* add the marker */ + cstr_info->marker[cstr_info->marknum].type = type; + cstr_info->marker[cstr_info->marknum].pos = pos; + cstr_info->marker[cstr_info->marknum].len = len; + cstr_info->marknum++; + } +static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) { + opj_marker_info_t *marker; + if (!cstr_info) + return; + /* expand the list? */ + if ((cstr_info->tile[tileno].marknum + 1) > cstr_info->tile[tileno].maxmarknum) { + cstr_info->tile[tileno].maxmarknum = 100 + (int) ((float) cstr_info->tile[tileno].maxmarknum * 1.0F); + cstr_info->tile[tileno].marker = (opj_marker_info_t*)opj_realloc(cstr_info->tile[tileno].marker, cstr_info->maxmarknum); + } + marker = &(cstr_info->tile[tileno].marker[cstr_info->tile[tileno].marknum]); + /* add the marker */ + marker->type = type; + marker->pos = pos; + marker->len = len; + cstr_info->tile[tileno].marknum++; +} diff --git a/extern/libopenjpeg/j2k.h b/extern/libopenjpeg/j2k.h index 5599be47a8d..6338c290dfd 100644 --- a/extern/libopenjpeg/j2k.h +++ b/extern/libopenjpeg/j2k.h @@ -45,12 +45,12 @@ The functions in J2K.C have for goal to read/write the several parts of the code #define J2K_CP_CSTY_SOP 0x02 #define J2K_CP_CSTY_EPH 0x04 #define J2K_CCP_CSTY_PRT 0x01 -#define J2K_CCP_CBLKSTY_LAZY 0x01 -#define J2K_CCP_CBLKSTY_RESET 0x02 -#define J2K_CCP_CBLKSTY_TERMALL 0x04 -#define J2K_CCP_CBLKSTY_VSC 0x08 -#define J2K_CCP_CBLKSTY_PTERM 0x10 -#define J2K_CCP_CBLKSTY_SEGSYM 0x20 +#define J2K_CCP_CBLKSTY_LAZY 0x01 /**< Selective arithmetic coding bypass */ +#define J2K_CCP_CBLKSTY_RESET 0x02 /**< Reset context probabilities on coding pass boundaries */ +#define J2K_CCP_CBLKSTY_TERMALL 0x04 /**< Termination on each coding pass */ +#define J2K_CCP_CBLKSTY_VSC 0x08 /**< Vertically stripe causal context */ +#define J2K_CCP_CBLKSTY_PTERM 0x10 /**< Predictable termination */ +#define J2K_CCP_CBLKSTY_SEGSYM 0x20 /**< Segmentation symbols are used */ #define J2K_CCP_QNTSTY_NOQNT 0 #define J2K_CCP_QNTSTY_SIQNT 1 #define J2K_CCP_QNTSTY_SEQNT 2 @@ -265,15 +265,15 @@ typedef struct opj_cp { /* UniPG>> */ #ifdef USE_JPWL /** enables writing of EPC in MH, thus activating JPWL */ - bool epc_on; + opj_bool epc_on; /** enables writing of EPB, in case of activated JPWL */ - bool epb_on; + opj_bool epb_on; /** enables writing of ESD, in case of activated JPWL */ - bool esd_on; + opj_bool esd_on; /** enables writing of informative techniques of ESD, in case of activated JPWL */ - bool info_on; + opj_bool info_on; /** enables writing of RED, in case of activated JPWL */ - bool red_on; + opj_bool red_on; /** error protection method for MH (0,1,16,32,37-128) */ int hprot_MH; /** tile number of header protection specification (>=0) */ @@ -299,7 +299,7 @@ typedef struct opj_cp { /** sensitivity methods for TPHs (-1,0-7) */ int sens_TPH[JPWL_MAX_NO_TILESPECS]; /** enables JPWL correction at the decoder */ - bool correct; + opj_bool correct; /** expected number of components at the decoder */ int exp_comps; /** maximum number of tiles at the decoder */ @@ -436,7 +436,7 @@ Encode an image into a JPEG-2000 codestream @param cstr_info Codestream information structure if required, NULL otherwise @return Returns true if successful, returns false otherwise */ -bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); +opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/j2k_lib.c b/extern/libopenjpeg/j2k_lib.c index 91aee007152..a66e31e9afb 100644 --- a/extern/libopenjpeg/j2k_lib.c +++ b/extern/libopenjpeg/j2k_lib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,18 +24,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifdef WIN32 +#ifdef _WIN32 #include <windows.h> #else #include <sys/time.h> #include <sys/resource.h> #include <sys/times.h> -#endif /* WIN32 */ +#endif /* _WIN32 */ #include "opj_includes.h" double opj_clock(void) { -#ifdef WIN32 - /* WIN32: use QueryPerformance (very accurate) */ +#ifdef _WIN32 + /* _WIN32: use QueryPerformance (very accurate) */ LARGE_INTEGER freq , t ; /* freq is the clock speed of the CPU */ QueryPerformanceFrequency(&freq) ; diff --git a/extern/libopenjpeg/j2k_lib.h b/extern/libopenjpeg/j2k_lib.h index 7df4d367757..5f3406e5106 100644 --- a/extern/libopenjpeg/j2k_lib.h +++ b/extern/libopenjpeg/j2k_lib.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/extern/libopenjpeg/jp2.c b/extern/libopenjpeg/jp2.c index b2831cfb0b5..5ae114c33b9 100644 --- a/extern/libopenjpeg/jp2.c +++ b/extern/libopenjpeg/jp2.c @@ -5,6 +5,7 @@ * Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team + * Copyright (c) 2010-2011, Kaori Hagihara * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,7 +29,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #include "opj_includes.h" /** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */ @@ -44,7 +44,7 @@ Read box headers @param box @return Returns true if successful, returns false otherwise */ -static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box); +static opj_bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box); /*static void jp2_write_url(opj_cio_t *cio, char *Idx_file);*/ /** Read the IHDR box - Image Header box @@ -52,12 +52,11 @@ Read the IHDR box - Image Header box @param cio Input buffer stream @return Returns true if successful, returns false otherwise */ -static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio); static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio); static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio); -static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio); static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio); -static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio); /** Write the FTYP box - File type box @param jp2 JP2 handle @@ -70,9 +69,9 @@ Read the FTYP box - File type box @param cio Input buffer stream @return Returns true if successful, returns false otherwise */ -static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio); static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); -static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset); +static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset); static void jp2_write_jp(opj_cio_t *cio); /** Read the JP box - JPEG 2000 signature @@ -80,29 +79,92 @@ Read the JP box - JPEG 2000 signature @param cio Input buffer stream @return Returns true if successful, returns false otherwise */ -static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio); /** Decode the structure of a JP2 file @param jp2 JP2 handle @param cio Input buffer stream +@param color Collector for profile, cdef and pclr data @return Returns true if successful, returns false otherwise */ -static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio); - +static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_color_t *color); +/** +Apply collected palette data +@param color Collector for profile, cdef and pclr data +@param image +*/ +static void jp2_apply_pclr(opj_jp2_color_t *color, opj_image_t *image, opj_common_ptr cinfo); +/** +Collect palette data +@param jp2 JP2 handle +@param cio Input buffer stream +@param box +@param color Collector for profile, cdef and pclr data +@return Returns true if successful, returns false otherwise +*/ +static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color); +/** +Collect component mapping data +@param jp2 JP2 handle +@param cio Input buffer stream +@param box +@param color Collector for profile, cdef and pclr data +@return Returns true if successful, returns false otherwise +*/ +static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color); +/** +Collect colour specification data +@param jp2 JP2 handle +@param cio Input buffer stream +@param box +@param color Collector for profile, cdef and pclr data +@return Returns true if successful, returns false otherwise +*/ +static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color); +/** +Write file Index (superbox) +@param[in] offset_jp2c offset of jp2c box +@param[in] length_jp2c length of jp2c box +@param[in] offset_idx offset of cidx box +@param[in] length_idx length of cidx box +@param[in] cio file output handle +@return length of fidx box +*/ +static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio); +/** +Write index Finder box +@param[in] offset offset of fidx box +@param[in] length length of fidx box +@param[in] cio file output handle +*/ +static void write_iptr( int offset, int length, opj_cio_t *cio); +/** +Write proxy box +@param[in] offset_jp2c offset of jp2c box +@param[in] length_jp2c length of jp2c box +@param[in] offset_idx offset of cidx box +@param[in] length_idx length of cidx box +@param[in] cio file output handle +*/ +static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio); /*@}*/ /*@}*/ /* ----------------------------------------------------------------------- */ -static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) { +static opj_bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) { box->init_pos = cio_tell(cio); box->length = cio_read(cio, 4); box->type = cio_read(cio, 4); if (box->length == 1) { if (cio_read(cio, 4) != 0) { opj_event_msg(cinfo, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n"); - return false; + return OPJ_FALSE; } box->length = cio_read(cio, 4); if (box->length == 0) @@ -112,7 +174,7 @@ static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t box->length = cio_numbytesleft(cio) + 8; } - return true; + return OPJ_TRUE; } #if 0 @@ -139,7 +201,7 @@ static void jp2_write_url(opj_cio_t *cio, char *Idx_file) { } #endif -static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { opj_jp2_box_t box; opj_common_ptr cinfo = jp2->cinfo; @@ -147,7 +209,7 @@ static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { jp2_read_boxhdr(cinfo, cio, &box); if (JP2_IHDR != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected IHDR Marker\n"); - return false; + return OPJ_FALSE; } jp2->h = cio_read(cio, 4); /* HEIGHT */ @@ -163,10 +225,10 @@ static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with IHDR Box\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { @@ -211,7 +273,7 @@ static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { } -static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { unsigned int i; opj_jp2_box_t box; @@ -220,7 +282,7 @@ static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { jp2_read_boxhdr(cinfo, cio, &box); if (JP2_BPCC != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected BPCC Marker\n"); - return false; + return OPJ_FALSE; } for (i = 0; i < jp2->numcomps; i++) { @@ -229,10 +291,10 @@ static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with BPCC Box\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) { @@ -246,11 +308,10 @@ static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) { cio_write(cio, jp2->precedence, 1); /* PRECEDENCE */ cio_write(cio, jp2->approx, 1); /* APPROX */ - if (jp2->meth == 1) { - cio_write(cio, jp2->enumcs, 4); /* EnumCS */ - } else { - cio_write(cio, 0, 1); /* PROFILE (??) */ - } + if(jp2->meth == 2) + jp2->enumcs = 0; + + cio_write(cio, jp2->enumcs, 4); /* EnumCS */ box.length = cio_tell(cio) - box.init_pos; cio_seek(cio, box.init_pos); @@ -258,42 +319,478 @@ static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio) { - opj_jp2_box_t box; +static void jp2_free_pclr(opj_jp2_color_t *color) +{ + opj_free(color->jp2_pclr->channel_sign); + opj_free(color->jp2_pclr->channel_size); + opj_free(color->jp2_pclr->entries); + + if(color->jp2_pclr->cmap) opj_free(color->jp2_pclr->cmap); + + opj_free(color->jp2_pclr); color->jp2_pclr = NULL; +} + +static void free_color_data(opj_jp2_color_t *color) +{ + if(color->jp2_pclr) + { + jp2_free_pclr(color); + } + if(color->jp2_cdef) + { + if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info); + opj_free(color->jp2_cdef); + } + if(color->icc_profile_buf) opj_free(color->icc_profile_buf); +} + +static void jp2_apply_pclr(opj_jp2_color_t *color, opj_image_t *image, opj_common_ptr cinfo) +{ + opj_image_comp_t *old_comps, *new_comps; + unsigned char *channel_size, *channel_sign; + unsigned int *entries; + opj_jp2_cmap_comp_t *cmap; + int *src, *dst; + unsigned int j, max; + unsigned short i, nr_channels, cmp, pcol; + int k, top_k; + + channel_size = color->jp2_pclr->channel_size; + channel_sign = color->jp2_pclr->channel_sign; + entries = color->jp2_pclr->entries; + cmap = color->jp2_pclr->cmap; + nr_channels = color->jp2_pclr->nr_channels; + + old_comps = image->comps; + new_comps = (opj_image_comp_t*) + opj_malloc(nr_channels * sizeof(opj_image_comp_t)); + + for(i = 0; i < nr_channels; ++i) + { + pcol = cmap[i].pcol; cmp = cmap[i].cmp; + + if( pcol < nr_channels ) + new_comps[pcol] = old_comps[cmp]; + else + { + opj_event_msg(cinfo, EVT_ERROR, "Error with pcol value %d (max: %d). skipping\n", pcol, nr_channels); + continue; + } + + if(cmap[i].mtyp == 0) /* Direct use */ + { + old_comps[cmp].data = NULL; continue; + } +/* Palette mapping: */ + new_comps[pcol].data = (int*) + opj_malloc(old_comps[cmp].w * old_comps[cmp].h * sizeof(int)); + new_comps[pcol].prec = channel_size[i]; + new_comps[pcol].sgnd = channel_sign[i]; + } + top_k = color->jp2_pclr->nr_entries - 1; + + for(i = 0; i < nr_channels; ++i) + { +/* Direct use: */ + if(cmap[i].mtyp == 0) continue; + +/* Palette mapping: */ + cmp = cmap[i].cmp; pcol = cmap[i].pcol; + src = old_comps[cmp].data; + dst = new_comps[pcol].data; + max = new_comps[pcol].w * new_comps[pcol].h; + + for(j = 0; j < max; ++j) + { +/* The index */ + if((k = src[j]) < 0) k = 0; else if(k > top_k) k = top_k; +/* The colour */ + dst[j] = entries[k * nr_channels + pcol]; + } + } + max = image->numcomps; + for(i = 0; i < max; ++i) + { + if(old_comps[i].data) opj_free(old_comps[i].data); + } + opj_free(old_comps); + image->comps = new_comps; + image->numcomps = nr_channels; + + jp2_free_pclr(color); + +}/* apply_pclr() */ + +static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ + opj_jp2_pclr_t *jp2_pclr; + unsigned char *channel_size, *channel_sign; + unsigned int *entries; + unsigned short nr_entries, nr_channels; + unsigned short i, j; + unsigned char uc; + + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + +/* Part 1, I.5.3.4: 'There shall be at most one Palette box inside + * a JP2 Header box' : +*/ + if(color->jp2_pclr) return OPJ_FALSE; + + nr_entries = (unsigned short)cio_read(cio, 2); /* NE */ + nr_channels = (unsigned short)cio_read(cio, 1);/* NPC */ + + entries = (unsigned int*) + opj_malloc(nr_channels * nr_entries * sizeof(unsigned int)); + channel_size = (unsigned char*)opj_malloc(nr_channels); + channel_sign = (unsigned char*)opj_malloc(nr_channels); + + jp2_pclr = (opj_jp2_pclr_t*)opj_malloc(sizeof(opj_jp2_pclr_t)); + jp2_pclr->channel_sign = channel_sign; + jp2_pclr->channel_size = channel_size; + jp2_pclr->entries = entries; + jp2_pclr->nr_entries = nr_entries; + jp2_pclr->nr_channels = nr_channels; + jp2_pclr->cmap = NULL; + + color->jp2_pclr = jp2_pclr; + + for(i = 0; i < nr_channels; ++i) + { + uc = cio_read(cio, 1); /* Bi */ + channel_size[i] = (uc & 0x7f) + 1; + channel_sign[i] = (uc & 0x80)?1:0; + } + + for(j = 0; j < nr_entries; ++j) + { + for(i = 0; i < nr_channels; ++i) + { +/* Cji */ + *entries++ = cio_read(cio, channel_size[i]>>3); + } + } + + return OPJ_TRUE; +}/* jp2_read_pclr() */ + +static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ + opj_jp2_cmap_comp_t *cmap; + unsigned short i, nr_channels; + + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + +/* Need nr_channels: */ + if(color->jp2_pclr == NULL) return OPJ_FALSE; + +/* Part 1, I.5.3.5: 'There shall be at most one Component Mapping box + * inside a JP2 Header box' : +*/ + if(color->jp2_pclr->cmap) return OPJ_FALSE; + + nr_channels = color->jp2_pclr->nr_channels; + cmap = (opj_jp2_cmap_comp_t*) + opj_malloc(nr_channels * sizeof(opj_jp2_cmap_comp_t)); + + for(i = 0; i < nr_channels; ++i) + { + cmap[i].cmp = (unsigned short)cio_read(cio, 2); + cmap[i].mtyp = cio_read(cio, 1); + cmap[i].pcol = cio_read(cio, 1); + + } + color->jp2_pclr->cmap = cmap; + + return OPJ_TRUE; +}/* jp2_read_cmap() */ + +static void jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color) +{ + opj_jp2_cdef_info_t *info; + int color_space; + unsigned short i, n, cn, typ, asoc, acn; + + color_space = image->color_space; + info = color->jp2_cdef->info; + n = color->jp2_cdef->n; + + for(i = 0; i < n; ++i) + { +/* WATCH: acn = asoc - 1 ! */ + if((asoc = info[i].asoc) == 0) continue; + + cn = info[i].cn; typ = info[i].typ; acn = asoc - 1; + + if(cn != acn) + { + opj_image_comp_t saved; + + memcpy(&saved, &image->comps[cn], sizeof(opj_image_comp_t)); + memcpy(&image->comps[cn], &image->comps[acn], sizeof(opj_image_comp_t)); + memcpy(&image->comps[acn], &saved, sizeof(opj_image_comp_t)); + + info[i].asoc = cn + 1; + info[acn].asoc = info[acn].cn + 1; + } + } + if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info); + + opj_free(color->jp2_cdef); color->jp2_cdef = NULL; + +}/* jp2_apply_cdef() */ + +static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ + opj_jp2_cdef_info_t *info; + unsigned short i, n; + + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + +/* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box + * inside a JP2 Header box.' +*/ + if(color->jp2_cdef) return OPJ_FALSE; + + if((n = (unsigned short)cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */ + + info = (opj_jp2_cdef_info_t*) + opj_malloc(n * sizeof(opj_jp2_cdef_info_t)); + + color->jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t)); + color->jp2_cdef->info = info; + color->jp2_cdef->n = n; + + for(i = 0; i < n; ++i) + { + info[i].cn = (unsigned short)cio_read(cio, 2); + info[i].typ = (unsigned short)cio_read(cio, 2); + info[i].asoc = (unsigned short)cio_read(cio, 2); + + } + return OPJ_TRUE; +}/* jp2_read_cdef() */ + +static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ int skip_len; + opj_common_ptr cinfo; - opj_common_ptr cinfo = jp2->cinfo; +/* Part 1, I.5.3.3 : 'A conforming JP2 reader shall ignore all Colour + * Specification boxes after the first.' +*/ + if(color->jp2_has_colr) return OPJ_FALSE; - jp2_read_boxhdr(cinfo, cio, &box); - do { - if (JP2_COLR != box.type) { - cio_skip(cio, box.length - 8); - jp2_read_boxhdr(cinfo, cio, &box); - } - } while(JP2_COLR != box.type); + cinfo = jp2->cinfo; jp2->meth = cio_read(cio, 1); /* METH */ jp2->precedence = cio_read(cio, 1); /* PRECEDENCE */ jp2->approx = cio_read(cio, 1); /* APPROX */ - if (jp2->meth == 1) { - jp2->enumcs = cio_read(cio, 4); /* EnumCS */ - } else { - /* skip PROFILE */ - skip_len = box.init_pos + box.length - cio_tell(cio); - if (skip_len < 0) { - opj_event_msg(cinfo, EVT_ERROR, "Error with JP2H box size\n"); - return false; - } - cio_skip(cio, box.init_pos + box.length - cio_tell(cio)); - } + if (jp2->meth == 1) + { + jp2->enumcs = cio_read(cio, 4); /* EnumCS */ + } + else + if (jp2->meth == 2) + { +/* skip PROFILE */ + skip_len = box->init_pos + box->length - cio_tell(cio); + if (skip_len < 0) + { + opj_event_msg(cinfo, EVT_ERROR, "Error with COLR box size\n"); + return OPJ_FALSE; + } + if(skip_len > 0) + { + unsigned char *start; + + start = cio_getbp(cio); + color->icc_profile_buf = (unsigned char*)opj_malloc(skip_len); + color->icc_profile_len = skip_len; + + cio_skip(cio, box->init_pos + box->length - cio_tell(cio)); + + memcpy(color->icc_profile_buf, start, skip_len); + } + } + + if (cio_tell(cio) - box->init_pos != box->length) + { + opj_event_msg(cinfo, EVT_ERROR, "Error with COLR Box\n"); + return OPJ_FALSE; + } + color->jp2_has_colr = 1; + + return OPJ_TRUE; +}/* jp2_read_colr() */ + +opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color) +{ + opj_jp2_box_t box; + int jp2h_end; + + opj_common_ptr cinfo = jp2->cinfo; + + jp2_read_boxhdr(cinfo, cio, &box); + do + { + if (JP2_JP2H != box.type) + { + if (box.type == JP2_JP2C) + { + opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n"); + return OPJ_FALSE; + } + cio_skip(cio, box.length - 8); + + if(cio->bp >= cio->end) return OPJ_FALSE; + + jp2_read_boxhdr(cinfo, cio, &box); + } + } while(JP2_JP2H != box.type); + + if (!jp2_read_ihdr(jp2, cio)) + return OPJ_FALSE; + jp2h_end = box.init_pos + box.length; + + if (jp2->bpc == 255) + { + if (!jp2_read_bpcc(jp2, cio)) + return OPJ_FALSE; + } + jp2_read_boxhdr(cinfo, cio, &box); + + while(cio_tell(cio) < jp2h_end) + { + if(box.type == JP2_COLR) + { + if( !jp2_read_colr(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + if(box.type == JP2_CDEF && !jp2->ignore_pclr_cmap_cdef) + { + if( !jp2_read_cdef(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + if(box.type == JP2_PCLR && !jp2->ignore_pclr_cmap_cdef) + { + if( !jp2_read_pclr(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + if(box.type == JP2_CMAP && !jp2->ignore_pclr_cmap_cdef) + { + if( !jp2_read_cmap(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + jp2_read_boxhdr(cinfo, cio, &box); + + }/* while(cio_tell(cio) < box_end) */ + + cio_seek(cio, jp2h_end); + +/* Part 1, I.5.3.3 : 'must contain at least one' */ + return (color->jp2_has_colr == 1); + +}/* jp2_read_jp2h() */ + +opj_image_t* opj_jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, + opj_codestream_info_t *cstr_info) +{ + opj_common_ptr cinfo; + opj_image_t *image = NULL; + opj_jp2_color_t color; + + if(!jp2 || !cio) + { + return NULL; + } + memset(&color, 0, sizeof(opj_jp2_color_t)); + cinfo = jp2->cinfo; + +/* JP2 decoding */ + if(!jp2_read_struct(jp2, cio, &color)) + { + free_color_data(&color); + opj_event_msg(cinfo, EVT_ERROR, "Failed to decode jp2 structure\n"); + return NULL; + } + +/* J2K decoding */ + image = j2k_decode(jp2->j2k, cio, cstr_info); + + if(!image) + { + free_color_data(&color); + opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n"); + return NULL; + } + + if (!jp2->ignore_pclr_cmap_cdef){ + + /* Set Image Color Space */ + if (jp2->enumcs == 16) + image->color_space = CLRSPC_SRGB; + else if (jp2->enumcs == 17) + image->color_space = CLRSPC_GRAY; + else if (jp2->enumcs == 18) + image->color_space = CLRSPC_SYCC; + else + image->color_space = CLRSPC_UNKNOWN; + + if(color.jp2_cdef) + { + jp2_apply_cdef(image, &color); + } + if(color.jp2_pclr) + { +/* Part 1, I.5.3.4: Either both or none : */ + if( !color.jp2_pclr->cmap) + jp2_free_pclr(&color); + else + jp2_apply_pclr(&color, image, cinfo); + } + if(color.icc_profile_buf) + { + image->icc_profile_buf = color.icc_profile_buf; + color.icc_profile_buf = NULL; + image->icc_profile_len = color.icc_profile_len; + } + } + + return image; + +}/* opj_jp2_decode() */ - if (cio_tell(cio) - box.init_pos != box.length) { - opj_event_msg(cinfo, EVT_ERROR, "Error with BPCC Box\n"); - return false; - } - return true; -} void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) { opj_jp2_box_t box; @@ -315,44 +812,6 @@ void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) { - opj_jp2_box_t box; - int skip_len; - - opj_common_ptr cinfo = jp2->cinfo; - - jp2_read_boxhdr(cinfo, cio, &box); - do { - if (JP2_JP2H != box.type) { - if (box.type == JP2_JP2C) { - opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n"); - return false; - } - cio_skip(cio, box.length - 8); - jp2_read_boxhdr(cinfo, cio, &box); - } - } while(JP2_JP2H != box.type); - - if (!jp2_read_ihdr(jp2, cio)) - return false; - - if (jp2->bpc == 255) { - if (!jp2_read_bpcc(jp2, cio)) - return false; - } - if (!jp2_read_colr(jp2, cio)) - return false; - - skip_len = box.init_pos + box.length - cio_tell(cio); - if (skip_len < 0) { - opj_event_msg(cinfo, EVT_ERROR, "Error with JP2H Box\n"); - return false; - } - cio_skip(cio, box.init_pos + box.length - cio_tell(cio)); - - return true; -} - static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { unsigned int i; opj_jp2_box_t box; @@ -374,7 +833,7 @@ static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { int i; opj_jp2_box_t box; @@ -384,7 +843,7 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { if (JP2_FTYP != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected FTYP Marker\n"); - return false; + return OPJ_FALSE; } jp2->brand = cio_read(cio, 4); /* BR */ @@ -398,10 +857,10 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with FTYP Box\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { @@ -433,7 +892,7 @@ static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, op return box.length; } -static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) { +static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) { opj_jp2_box_t box; opj_common_ptr cinfo = jp2->cinfo; @@ -449,7 +908,7 @@ static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_code *j2k_codestream_offset = cio_tell(cio); *j2k_codestream_length = box.length - 8; - return true; + return OPJ_TRUE; } static void jp2_write_jp(opj_cio_t *cio) { @@ -466,7 +925,7 @@ static void jp2_write_jp(opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) { opj_jp2_box_t box; opj_common_ptr cinfo = jp2->cinfo; @@ -474,34 +933,96 @@ static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) { jp2_read_boxhdr(cinfo, cio, &box); if (JP2_JP != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected JP Marker\n"); - return false; + return OPJ_FALSE; } if (0x0d0a870a != cio_read(cio, 4)) { opj_event_msg(cinfo, EVT_ERROR, "Error with JP Marker\n"); - return false; + return OPJ_FALSE; } if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with JP Box size\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } -static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_color_t *color) { if (!jp2_read_jp(jp2, cio)) - return false; + return OPJ_FALSE; if (!jp2_read_ftyp(jp2, cio)) - return false; - if (!jp2_read_jp2h(jp2, cio)) - return false; + return OPJ_FALSE; + if (!jp2_read_jp2h(jp2, cio, color)) + return OPJ_FALSE; if (!jp2_read_jp2c(jp2, cio, &jp2->j2k_codestream_length, &jp2->j2k_codestream_offset)) - return false; + return OPJ_FALSE; - return true; + return OPJ_TRUE; +} + + +static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FIDX, 4); /* IPTR */ + + write_prxy( offset_jp2c, length_jp2c, offset_idx, length_idx, cio); + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} + +static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_PRXY, 4); /* IPTR */ + + cio_write( cio, offset_jp2c, 8); /* OOFF */ + cio_write( cio, length_jp2c, 4); /* OBH part 1 */ + cio_write( cio, JP2_JP2C, 4); /* OBH part 2 */ + + cio_write( cio, 1,1); /* NI */ + + cio_write( cio, offset_idx, 8); /* IOFF */ + cio_write( cio, length_idx, 4); /* IBH part 1 */ + cio_write( cio, JPIP_CIDX, 4); /* IBH part 2 */ + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); } +static void write_iptr( int offset, int length, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_IPTR, 4); /* IPTR */ + + cio_write( cio, offset, 8); + cio_write( cio, length, 8); + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); +} + + /* ----------------------------------------------------------------------- */ /* JP2 decoder interface */ /* ----------------------------------------------------------------------- */ @@ -539,42 +1060,7 @@ void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters) { /* setup the J2K codec */ j2k_setup_decoder(jp2->j2k, parameters); /* further JP2 initializations go here */ -} - -opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info) { - opj_common_ptr cinfo; - opj_image_t *image = NULL; - - if(!jp2 || !cio) { - return NULL; - } - - cinfo = jp2->cinfo; - - /* JP2 decoding */ - if(!jp2_read_struct(jp2, cio)) { - opj_event_msg(cinfo, EVT_ERROR, "Failed to decode jp2 structure\n"); - return NULL; - } - - /* J2K decoding */ - image = j2k_decode(jp2->j2k, cio, cstr_info); - if(!image) { - opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n"); - return NULL; - } - - /* Set Image Color Space */ - if (jp2->enumcs == 16) - image->color_space = CLRSPC_SRGB; - else if (jp2->enumcs == 17) - image->color_space = CLRSPC_GRAY; - else if (jp2->enumcs == 18) - image->color_space = CLRSPC_SYCC; - else - image->color_space = CLRSPC_UNKNOWN; - - return image; + jp2->ignore_pclr_cmap_cdef = parameters->flags & OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; } /* ----------------------------------------------------------------------- */ @@ -664,30 +1150,23 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_ for (i = 0; i < image->numcomps; i++) { jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7); } - - /* Colour Specification box */ - - if ((image->numcomps == 1 || image->numcomps == 3) && (jp2->bpc != 255)) { - jp2->meth = 1; /* METH: Enumerated colourspace */ - } else { - jp2->meth = 2; /* METH: Restricted ICC profile */ - } - if (jp2->meth == 1) { - if (image->color_space == 1) - jp2->enumcs = 16; /* sRGB as defined by IEC 61966–2–1 */ - else if (image->color_space == 2) - jp2->enumcs = 17; /* greyscale */ - else if (image->color_space == 3) - jp2->enumcs = 18; /* YUV */ - } else { - jp2->enumcs = 0; /* PROFILE (??) */ - } + jp2->meth = 1; + if (image->color_space == 1) + jp2->enumcs = 16; /* sRGB as defined by IEC 61966-2.1 */ + else if (image->color_space == 2) + jp2->enumcs = 17; /* greyscale */ + else if (image->color_space == 3) + jp2->enumcs = 18; /* YUV */ jp2->precedence = 0; /* PRECEDENCE */ jp2->approx = 0; /* APPROX */ - + + jp2->jpip_on = parameters->jpip_on; } -bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { +opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { + + int pos_iptr, pos_cidx, pos_jp2c, len_jp2c, len_cidx, end_pos, pos_fidx, len_fidx; + pos_jp2c = pos_iptr = -1; /* remove a warning */ /* JP2 encoding */ @@ -698,14 +1177,34 @@ bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestre /* JP2 Header box */ jp2_write_jp2h(jp2, cio); + if( jp2->jpip_on){ + pos_iptr = cio_tell( cio); + cio_skip( cio, 24); /* IPTR further ! */ + + pos_jp2c = cio_tell( cio); + } + /* J2K encoding */ + if(!(len_jp2c = jp2_write_jp2c( jp2, cio, image, cstr_info))){ + opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n"); + return OPJ_FALSE; + } - if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) { - opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n"); - return false; + if( jp2->jpip_on){ + pos_cidx = cio_tell( cio); + + len_cidx = write_cidx( pos_jp2c+8, cio, image, *cstr_info, len_jp2c-8); + + pos_fidx = cio_tell( cio); + len_fidx = write_fidx( pos_jp2c, len_jp2c, pos_cidx, len_cidx, cio); + + end_pos = cio_tell( cio); + + cio_seek( cio, pos_iptr); + write_iptr( pos_fidx, len_fidx, cio); + + cio_seek( cio, end_pos); } - return true; + return OPJ_TRUE; } - - diff --git a/extern/libopenjpeg/jp2.h b/extern/libopenjpeg/jp2.h index 7e363be2eee..acb643cad77 100644 --- a/extern/libopenjpeg/jp2.h +++ b/extern/libopenjpeg/jp2.h @@ -46,11 +46,64 @@ #define JP2_COLR 0x636f6c72 /**< Colour specification box */ #define JP2_JP2C 0x6a703263 /**< Contiguous codestream box */ #define JP2_URL 0x75726c20 /**< URL box */ -#define JP2_DBTL 0x6474626c /**< ??? */ +#define JP2_DTBL 0x6474626c /**< Data Reference box */ #define JP2_BPCC 0x62706363 /**< Bits per component box */ #define JP2_JP2 0x6a703220 /**< File type fields */ +#define JP2_PCLR 0x70636c72 /**< Palette box */ +#define JP2_CMAP 0x636d6170 /**< Component Mapping box */ +#define JP2_CDEF 0x63646566 /**< Channel Definition box */ /* ----------------------------------------------------------------------- */ +/** +Channel description: channel index, type, assocation +*/ +typedef struct opj_jp2_cdef_info +{ + unsigned short cn, typ, asoc; +} opj_jp2_cdef_info_t; + +/** +Channel descriptions and number of descriptions +*/ +typedef struct opj_jp2_cdef +{ + opj_jp2_cdef_info_t *info; + unsigned short n; +} opj_jp2_cdef_t; + +/** +Component mappings: channel index, mapping type, palette index +*/ +typedef struct opj_jp2_cmap_comp +{ + unsigned short cmp; + unsigned char mtyp, pcol; +} opj_jp2_cmap_comp_t; + +/** +Palette data: table entries, palette columns +*/ +typedef struct opj_jp2_pclr +{ + unsigned int *entries; + unsigned char *channel_sign; + unsigned char *channel_size; + opj_jp2_cmap_comp_t *cmap; + unsigned short nr_entries, nr_channels; +} opj_jp2_pclr_t; + +/** +Collector for ICC profile, palette, component mapping, channel description +*/ +typedef struct opj_jp2_color +{ + unsigned char *icc_profile_buf; + int icc_profile_len; + + opj_jp2_cdef_t *jp2_cdef; + opj_jp2_pclr_t *jp2_pclr; + unsigned char jp2_has_colr; +} opj_jp2_color_t; /** JP2 component @@ -87,6 +140,8 @@ typedef struct opj_jp2 { opj_jp2_comps_t *comps; unsigned int j2k_codestream_offset; unsigned int j2k_codestream_length; + opj_bool jpip_on; + opj_bool ignore_pclr_cmap_cdef; } opj_jp2_t; /** @@ -111,9 +166,10 @@ void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio); Read the JP2H box - JP2 Header box (used in MJ2) @param jp2 JP2 handle @param cio Input buffer stream +@param ext Collector for profile, cdef and pclr data @return Returns true if successful, returns false otherwise */ -bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio); +opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color); /** Creates a JP2 decompression structure @param cinfo Codec context info @@ -139,7 +195,7 @@ Decode an image from a JPEG-2000 file stream @param cstr_info Codestream information structure if required, NULL otherwise @return Returns a decoded image if successful, returns NULL otherwise */ -opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info); +opj_image_t* opj_jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info); /** Creates a JP2 compression structure @param cinfo Codec context info @@ -167,7 +223,8 @@ Encode an image into a JPEG-2000 file stream @param cstr_info Codestream information structure if required, NULL otherwise @return Returns true if successful, returns false otherwise */ -bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); +opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); + /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/mct.c b/extern/libopenjpeg/mct.c index ca21744f3e4..870993b06d2 100644 --- a/extern/libopenjpeg/mct.c +++ b/extern/libopenjpeg/mct.c @@ -29,6 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef __SSE__ +#include <xmmintrin.h> +#endif + #include "opj_includes.h" /* <summary> */ @@ -127,6 +131,44 @@ void mct_decode_real( int n) { int i; +#ifdef __SSE__ + __m128 vrv, vgu, vgv, vbu; + vrv = _mm_set1_ps(1.402f); + vgu = _mm_set1_ps(0.34413f); + vgv = _mm_set1_ps(0.71414f); + vbu = _mm_set1_ps(1.772f); + for (i = 0; i < (n >> 3); ++i) { + __m128 vy, vu, vv; + __m128 vr, vg, vb; + + vy = _mm_load_ps(c0); + vu = _mm_load_ps(c1); + vv = _mm_load_ps(c2); + vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv)); + vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv)); + vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu)); + _mm_store_ps(c0, vr); + _mm_store_ps(c1, vg); + _mm_store_ps(c2, vb); + c0 += 4; + c1 += 4; + c2 += 4; + + vy = _mm_load_ps(c0); + vu = _mm_load_ps(c1); + vv = _mm_load_ps(c2); + vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv)); + vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv)); + vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu)); + _mm_store_ps(c0, vr); + _mm_store_ps(c1, vg); + _mm_store_ps(c2, vb); + c0 += 4; + c1 += 4; + c2 += 4; + } + n &= 7; +#endif for(i = 0; i < n; ++i) { float y = c0[i]; float u = c1[i]; diff --git a/extern/libopenjpeg/mqc.c b/extern/libopenjpeg/mqc.c index 9aa9d2c2e5b..14129fbf4e5 100644 --- a/extern/libopenjpeg/mqc.c +++ b/extern/libopenjpeg/mqc.c @@ -68,24 +68,23 @@ FIXME: documentation ??? @param mqc MQC handle @return */ -static int mqc_mpsexchange(opj_mqc_t *mqc); +static INLINE int mqc_mpsexchange(opj_mqc_t *const mqc); /** FIXME: documentation ??? @param mqc MQC handle @return */ -static int mqc_lpsexchange(opj_mqc_t *mqc); +static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc); /** Input a byte @param mqc MQC handle */ -static void mqc_bytein(opj_mqc_t *mqc); +static INLINE void mqc_bytein(opj_mqc_t *const mqc); /** Renormalize mqc->a and mqc->c while decoding @param mqc MQC handle */ -static void mqc_renormd(opj_mqc_t *mqc); - +static INLINE void mqc_renormd(opj_mqc_t *const mqc); /*@}*/ /*@}*/ @@ -271,7 +270,7 @@ static void mqc_setbits(opj_mqc_t *mqc) { } } -static int mqc_mpsexchange(opj_mqc_t *mqc) { +static INLINE int mqc_mpsexchange(opj_mqc_t *const mqc) { int d; if (mqc->a < (*mqc->curctx)->qeval) { d = 1 - (*mqc->curctx)->mps; @@ -284,7 +283,7 @@ static int mqc_mpsexchange(opj_mqc_t *mqc) { return d; } -static int mqc_lpsexchange(opj_mqc_t *mqc) { +static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc) { int d; if (mqc->a < (*mqc->curctx)->qeval) { mqc->a = (*mqc->curctx)->qeval; @@ -299,7 +298,15 @@ static int mqc_lpsexchange(opj_mqc_t *mqc) { return d; } -static void mqc_bytein(opj_mqc_t *mqc) { +#ifdef MQC_PERF_OPT +static INLINE void mqc_bytein(opj_mqc_t *const mqc) { + unsigned int i = *((unsigned int *) mqc->bp); + mqc->c += i & 0xffff00; + mqc->ct = i & 0x0f; + mqc->bp += (i >> 2) & 0x04; +} +#else +static void mqc_bytein(opj_mqc_t *const mqc) { if (mqc->bp != mqc->end) { unsigned int c; if (mqc->bp + 1 != mqc->end) { @@ -326,8 +333,9 @@ static void mqc_bytein(opj_mqc_t *mqc) { mqc->ct = 8; } } +#endif -static void mqc_renormd(opj_mqc_t *mqc) { +static INLINE void mqc_renormd(opj_mqc_t *const mqc) { do { if (mqc->ct == 0) { mqc_bytein(mqc); @@ -346,11 +354,19 @@ static void mqc_renormd(opj_mqc_t *mqc) { opj_mqc_t* mqc_create(void) { opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t)); +#ifdef MQC_PERF_OPT + mqc->buffer = NULL; +#endif return mqc; } void mqc_destroy(opj_mqc_t *mqc) { if(mqc) { +#ifdef MQC_PERF_OPT + if (mqc->buffer) { + opj_free(mqc->buffer); + } +#endif opj_free(mqc); } } @@ -499,13 +515,51 @@ void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) { mqc->bp = bp; if (len==0) mqc->c = 0xff << 16; else mqc->c = *mqc->bp << 16; + +#ifdef MQC_PERF_OPT + { + unsigned int c; + unsigned int *ip; + unsigned char *end = mqc->end - 1; + mqc->buffer = opj_realloc(mqc->buffer, (len + 1) * sizeof(unsigned int)); + ip = (unsigned int *) mqc->buffer; + + while (bp < end) { + c = *(bp + 1); + if (*bp == 0xff) { + if (c > 0x8f) { + break; + } else { + *ip = 0x00000017 | (c << 9); + } + } else { + *ip = 0x00000018 | (c << 8); + } + bp++; + ip++; + } + + /* Handle last byte of data */ + c = 0xff; + if (*bp == 0xff) { + *ip = 0x0000ff18; + } else { + bp++; + *ip = 0x00000018 | (c << 8); + } + ip++; + + *ip = 0x0000ff08; + mqc->bp = mqc->buffer; + } +#endif mqc_bytein(mqc); mqc->c <<= 7; mqc->ct -= 7; mqc->a = 0x8000; } -int mqc_decode(opj_mqc_t *mqc) { +int mqc_decode(opj_mqc_t *const mqc) { int d; mqc->a -= (*mqc->curctx)->qeval; if ((mqc->c >> 16) < (*mqc->curctx)->qeval) { diff --git a/extern/libopenjpeg/mqc.h b/extern/libopenjpeg/mqc.h index 8cc8c934598..d00cd1067d8 100644 --- a/extern/libopenjpeg/mqc.h +++ b/extern/libopenjpeg/mqc.h @@ -70,6 +70,9 @@ typedef struct opj_mqc { unsigned char *end; opj_mqc_state_t *ctxs[MQC_NUMCTXS]; opj_mqc_state_t **curctx; +#ifdef MQC_PERF_OPT + unsigned char *buffer; +#endif } opj_mqc_t; /** @name Exported functions */ @@ -188,7 +191,7 @@ Decode a symbol @param mqc MQC handle @return Returns the decoded symbol (0 or 1) */ -int mqc_decode(opj_mqc_t *mqc); +int mqc_decode(opj_mqc_t *const mqc); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/openjpeg.c b/extern/libopenjpeg/openjpeg.c index 96fa0ad57e5..180cc844ab5 100644 --- a/extern/libopenjpeg/openjpeg.c +++ b/extern/libopenjpeg/openjpeg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,17 +24,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifdef WIN32 +#ifdef _WIN32 #include <windows.h> -#endif /* WIN32 */ +#endif /* _WIN32 */ +#include "opj_config.h" #include "opj_includes.h" /* ---------------------------------------------------------------------- */ -#ifdef WIN32 +#ifdef _WIN32 #ifndef OPJ_STATIC BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + + OPJ_ARG_NOT_USED(lpReserved); + OPJ_ARG_NOT_USED(hModule); + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH : break; @@ -48,19 +53,19 @@ DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } #endif /* OPJ_STATIC */ -#endif /* WIN32 */ +#endif /* _WIN32 */ /* ---------------------------------------------------------------------- */ const char* OPJ_CALLCONV opj_version(void) { - return OPENJPEG_VERSION; + return PACKAGE_VERSION; } opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) { - opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t)); + opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_calloc(1, sizeof(opj_dinfo_t)); if(!dinfo) return NULL; - dinfo->is_decompressor = true; + dinfo->is_decompressor = OPJ_TRUE; switch(format) { case CODEC_J2K: case CODEC_JPT: @@ -120,9 +125,10 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete parameters->decod_format = -1; parameters->cod_format = -1; + parameters->flags = 0; /* UniPG>> */ #ifdef USE_JPWL - parameters->jpwl_correct = false; + parameters->jpwl_correct = OPJ_FALSE; parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS; parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES; #endif /* USE_JPWL */ @@ -159,7 +165,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci case CODEC_JPT: return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info); case CODEC_JP2: - return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info); + return opj_jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info); case CODEC_UNKNOWN: default: break; @@ -169,9 +175,9 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci } opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) { - opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t)); + opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_calloc(1, sizeof(opj_cinfo_t)); if(!cinfo) return NULL; - cinfo->is_decompressor = false; + cinfo->is_decompressor = OPJ_FALSE; switch(format) { case CODEC_J2K: /* get a J2K coder handle */ @@ -238,9 +244,15 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete parameters->tp_on = 0; parameters->decod_format = -1; parameters->cod_format = -1; + parameters->tcp_rates[0] = 0; + parameters->tcp_numlayers = 0; + parameters->cp_disto_alloc = 0; + parameters->cp_fixed_alloc = 0; + parameters->cp_fixed_quality = 0; + parameters->jpip_on = OPJ_FALSE; /* UniPG>> */ #ifdef USE_JPWL - parameters->jpwl_epc_on = false; + parameters->jpwl_epc_on = OPJ_FALSE; parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */ { int i; @@ -290,7 +302,7 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param } } -bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) { +opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) { if (index != NULL) opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n" "To extract the index, use the opj_encode_with_info() function.\n" @@ -298,20 +310,20 @@ bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *im return opj_encode_with_info(cinfo, cio, image, NULL); } -bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { +opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { if(cinfo && cio && image) { switch(cinfo->codec_format) { case CODEC_J2K: return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info); case CODEC_JP2: - return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info); + return opj_jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info); case CODEC_JPT: case CODEC_UNKNOWN: default: break; } } - return false; + return OPJ_FALSE; } void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { @@ -322,8 +334,10 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { opj_free(tile_info->thresh); opj_free(tile_info->packet); opj_free(tile_info->tp); + opj_free(tile_info->marker); } opj_free(cstr_info->tile); opj_free(cstr_info->marker); + opj_free(cstr_info->numdecompos); } } diff --git a/extern/libopenjpeg/openjpeg.h b/extern/libopenjpeg/openjpeg.h index ae7764eab2f..53e9fac0438 100644 --- a/extern/libopenjpeg/openjpeg.h +++ b/extern/libopenjpeg/openjpeg.h @@ -6,6 +6,7 @@ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2006-2007, Parvatha Elangovan + * Copyright (c) 2010-2011, Kaori Hagihara * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +33,6 @@ #ifndef OPENJPEG_H #define OPENJPEG_H -#define OPENJPEG_VERSION "1.3.0" /* ========================================================== @@ -40,34 +40,32 @@ ========================================================== */ +#if defined(OPJ_STATIC) || !defined(_WIN32) #define OPJ_API #define OPJ_CALLCONV - -#ifndef __cplusplus -#if defined(HAVE_STDBOOL_H) -/* -The C language implementation does correctly provide the standard header -file "stdbool.h". - */ -#include <stdbool.h> #else +#define OPJ_CALLCONV __stdcall /* -The C language implementation does not provide the standard header file -"stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this -braindamage below. -*/ -#if !defined(bool) -#define bool int -#endif -#if !defined(true) -#define true 1 -#endif -#if !defined(false) -#define false 0 -#endif -#endif -#endif /* __cplusplus */ +The following ifdef block is the standard way of creating macros which make exporting +from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS +symbol defined on the command line. this symbol should not be defined on any project +that uses this DLL. This way any other project whose source files include this file see +OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols +defined with this macro as being exported. +*/ +#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) +#define OPJ_API __declspec(dllexport) +#else +#define OPJ_API __declspec(dllimport) +#endif /* OPJ_EXPORTS */ +#endif /* !OPJ_STATIC || !_WIN32 */ +typedef int opj_bool; +#define OPJ_TRUE 1 +#define OPJ_FALSE 0 + +/* Avoid compile-time warning because parameter is not used */ +#define OPJ_ARG_NOT_USED(x) (void)(x) /* ========================================================== Useful constant definitions @@ -130,7 +128,8 @@ typedef enum PROG_ORDER { Supported image color spaces */ typedef enum COLOR_SPACE { - CLRSPC_UNKNOWN = -1, /**< place-holder */ + CLRSPC_UNKNOWN = -1, /**< not supported by the library */ + CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ CLRSPC_SRGB = 1, /**< sRGB */ CLRSPC_GRAY = 2, /**< grayscale */ CLRSPC_SYCC = 3 /**< YUV */ @@ -141,9 +140,9 @@ Supported codec */ typedef enum CODEC_FORMAT { CODEC_UNKNOWN = -1, /**< place-holder */ - CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ - CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ - CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */ + CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ + CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ + CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */ } OPJ_CODEC_FORMAT; /** @@ -226,7 +225,7 @@ Compression parameters */ typedef struct opj_cparameters { /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */ - bool tile_size_on; + opj_bool tile_size_on; /** XTOsiz */ int cp_tx0; /** YTOsiz */ @@ -308,7 +307,7 @@ typedef struct opj_cparameters { /**@name JPWL encoding parameters */ /*@{*/ /** enables writing of EPC in MH, thus activating JPWL */ - bool jpwl_epc_on; + opj_bool jpwl_epc_on; /** error protection method for MH (0,1,16,32,37-128) */ int jpwl_hprot_MH; /** tile number of header protection specification (>=0) */ @@ -348,8 +347,12 @@ typedef struct opj_cparameters { char tp_flag; /** MCT (multiple component transform) */ char tcp_mct; + /** Enable JPIP indexing*/ + opj_bool jpip_on; } opj_cparameters_t; +#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 + /** Decompression parameters */ @@ -386,7 +389,7 @@ typedef struct opj_dparameters { /**@name JPWL decoding parameters */ /*@{*/ /** activates the JPWL correction capabilities */ - bool jpwl_correct; + opj_bool jpwl_correct; /** expected number of components */ int jpwl_exp_comps; /** maximum number of tiles */ @@ -402,6 +405,7 @@ typedef struct opj_dparameters { */ OPJ_LIMIT_DECODING cp_limit_decoding; + unsigned int flags; } opj_dparameters_t; /** Common fields between JPEG-2000 compression and decompression master structs. */ @@ -409,7 +413,7 @@ typedef struct opj_dparameters { #define opj_common_fields \ opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\ void * client_data; /**< Available for use by application */\ - bool is_decompressor; /**< So common code can tell which is which */\ + opj_bool is_decompressor; /**< So common code can tell which is which */\ OPJ_CODEC_FORMAT codec_format; /**< selected codec */\ void *j2k_handle; /**< pointer to the J2K codec */\ void *jp2_handle; /**< pointer to the JP2 codec */\ @@ -537,6 +541,10 @@ typedef struct opj_image { OPJ_COLOR_SPACE color_space; /** image components */ opj_image_comp_t *comps; + /** 'restricted' ICC profile */ + unsigned char *icc_profile_buf; + /** size of ICC profile */ + int icc_profile_len; } opj_image_t; /** @@ -583,6 +591,21 @@ typedef struct opj_packet_info { double disto; } opj_packet_info_t; + +/* UniPG>> */ +/** +Marker structure +*/ +typedef struct opj_marker_info_t { + /** marker type */ + unsigned short int type; + /** position in codestream */ + int pos; + /** length, marker val included */ + int len; +} opj_marker_info_t; +/* <<UniPG */ + /** Index structure : Information concerning tile-parts */ @@ -627,26 +650,18 @@ typedef struct opj_tile_info { int numpix; /** add fixed_quality */ double distotile; + /** number of markers */ + int marknum; + /** list of markers */ + opj_marker_info_t *marker; + /** actual size of markers array */ + int maxmarknum; /** number of tile parts */ int num_tps; /** information concerning tile parts */ opj_tp_info_t *tp; } opj_tile_info_t; -/* UniPG>> */ -/** -Marker structure -*/ -typedef struct opj_marker_info_t { - /** marker type */ - unsigned short int type; - /** position in codestream */ - int pos; - /** length, marker val included */ - int len; -} opj_marker_info_t; -/* <<UniPG */ - /** Index structure of the codestream */ @@ -865,13 +880,13 @@ Setup the encoder parameters using the current image and using user parameters. OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image); /** Encode an image into a JPEG-2000 codestream -@param cinfo compressor handle +3@param cinfo compressor handle @param cio Output buffer stream @param image Image to encode @param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci() @return Returns true if successful, returns false otherwise */ -OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index); +OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index); /** Encode an image into a JPEG-2000 codestream and extract the codestream information @param cinfo compressor handle @@ -880,13 +895,14 @@ Encode an image into a JPEG-2000 codestream and extract the codestream informati @param cstr_info Codestream information structure if needed afterwards, NULL otherwise @return Returns true if successful, returns false otherwise */ -OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); +OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); /** Destroy Codestream information after compression or decompression @param cstr_info Codestream information structure */ OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info); + #ifdef __cplusplus } #endif diff --git a/extern/libopenjpeg/opj_config.h b/extern/libopenjpeg/opj_config.h new file mode 100644 index 00000000000..82e12be03a9 --- /dev/null +++ b/extern/libopenjpeg/opj_config.h @@ -0,0 +1,38 @@ +/* for BLENDER - we hand-maintain this, + * for the original OpenJpeg package it is generated, + * the endian check is a blender define */ + +/* create config.h for CMake */ +#define PACKAGE_VERSION "1.5.0" + +#define HAVE_INTTYPES_H +#define HAVE_MEMORY_H +#define HAVE_STDINT_H +#define HAVE_STDLIB_H +#define HAVE_STRINGS_H +#define HAVE_STRING_H +#define HAVE_SYS_STAT_H +#define HAVE_SYS_TYPES_H +#define HAVE_UNISTD_H +/* #define HAVE_LIBPNG */ +/* #define HAVE_PNG_H */ +/* #define HAVE_LIBTIFF */ +/* #define HAVE_TIFF_H */ + +/* #undef HAVE_LIBLCMS1 */ +/* #undef HAVE_LIBLCMS2 */ +/* #undef HAVE_LCMS1_H */ +/* #undef HAVE_LCMS2_H */ + +/* Byte order. */ +/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or +__LITTLE_ENDIAN__ to match the endianness of the architecture being +compiled for. This is not necessarily the same as the architecture of the +machine doing the building. In order to support Universal Binaries on +Mac OS X, we prefer those defines to decide the endianness. +On other platforms we use the result of the TRY_RUN. */ +#if defined(__BIG_ENDIAN__) +# define OPJ_BIG_ENDIAN +#else +# undef OPJ_BIG_ENDIAN +#endif diff --git a/extern/libopenjpeg/opj_includes.h b/extern/libopenjpeg/opj_includes.h index 3464cfcf9ed..2b5866a9990 100644 --- a/extern/libopenjpeg/opj_includes.h +++ b/extern/libopenjpeg/opj_includes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ Most compilers implement their own version of this keyword ... */ #ifndef INLINE #if defined(_MSC_VER) - #define INLINE __inline + #define INLINE __forceinline #elif defined(__GNUC__) #define INLINE __inline__ #elif defined(__MWERKS__) @@ -86,30 +86,28 @@ Most compilers implement their own version of this keyword ... #endif #endif -/* MSVC does not have lrintf */ -#ifdef _MSC_VER +/* MSVC and Borland C do not have lrintf */ +#if defined(_MSC_VER) || defined(__BORLANDC__) +static INLINE long lrintf(float f){ #ifdef _M_X64 -#include <emmintrin.h> -static INLINE long lrintf(float f) { - return _mm_cvtss_si32(_mm_load_ss(&f)); -} + return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); #else -static INLINE long lrintf(float f){ - int i; - - _asm{ - fld f - fistp i - }; - - return i; -} + int i; + + _asm{ + fld f + fistp i + }; + + return i; #endif +} #endif #include "j2k_lib.h" #include "opj_malloc.h" #include "event.h" +#include "bio.h" #include "cio.h" #include "image.h" @@ -130,9 +128,12 @@ static INLINE long lrintf(float f){ #include "int.h" #include "fix.h" +#include "cidx_manager.h" +#include "indexbox_manager.h" + /* JPWL>> */ #ifdef USE_JPWL -#include "../jpwl/jpwl.h" +#include "./jpwl/jpwl.h" #endif /* USE_JPWL */ /* <<JPWL */ diff --git a/extern/libopenjpeg/opj_malloc.h b/extern/libopenjpeg/opj_malloc.h index 960bdb3ec4b..87493f497c7 100644 --- a/extern/libopenjpeg/opj_malloc.h +++ b/extern/libopenjpeg/opj_malloc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com> * All rights reserved. * @@ -45,7 +45,11 @@ Allocate an uninitialized memory block @param size Bytes to allocate @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ +#ifdef ALLOC_PERF_OPT +void * OPJ_CALLCONV opj_malloc(size_t size); +#else #define opj_malloc(size) malloc(size) +#endif /** Allocate a memory block with elements initialized to 0 @@ -53,7 +57,11 @@ Allocate a memory block with elements initialized to 0 @param size Bytes per block to allocate @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ +#ifdef ALLOC_PERF_OPT +void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements); +#else #define opj_calloc(num, size) calloc(num, size) +#endif /** Allocate memory aligned to a 16 byte boundry @@ -61,7 +69,7 @@ Allocate memory aligned to a 16 byte boundry @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ /* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */ -#ifdef WIN32 +#ifdef _WIN32 /* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */ #ifdef __GNUC__ #include <mm_malloc.h> @@ -72,23 +80,16 @@ Allocate memory aligned to a 16 byte boundry #define HAVE_MM_MALLOC #endif #endif -#else /* Not WIN32 */ +#else /* Not _WIN32 */ #if defined(__sun) - #define HAVE_MEMALIGN - #elif defined(__GNUC__) - #if !defined(__APPLE__) && !defined(__FreeBSD__) - #define HAVE_MEMALIGN - #include <malloc.h> - #endif - /* Linux x86_64 and OSX always align allocations to 16 bytes */ - #elif !defined(__amd64__) && !defined(__APPLE__) - /* FIXME: Yes, this is a big assumption */ - #define HAVE_POSIX_MEMALIGN + #define HAVE_MEMALIGN + /* Linux x86_64 and OSX always align allocations to 16 bytes */ + #elif !defined(__amd64__) && !defined(__APPLE__) + #define HAVE_MEMALIGN + #include <malloc.h> #endif #endif - - #define opj_aligned_malloc(size) malloc(size) #define opj_aligned_free(m) free(m) @@ -120,19 +121,34 @@ Allocate memory aligned to a 16 byte boundry #define opj_aligned_free(m) free(m) #endif +#ifdef ALLOC_PERF_OPT + #undef opj_aligned_malloc + #define opj_aligned_malloc(size) opj_malloc(size) + #undef opj_aligned_free + #define opj_aligned_free(m) opj_free(m) +#endif + /** Reallocate memory blocks. -@param memblock Pointer to previously allocated memory block -@param size New size in bytes +@param m Pointer to previously allocated memory block +@param s New size in bytes @return Returns a void pointer to the reallocated (and possibly moved) memory block */ +#ifdef ALLOC_PERF_OPT +void * OPJ_CALLCONV opj_realloc(void * m, size_t s); +#else #define opj_realloc(m, s) realloc(m, s) +#endif /** Deallocates or frees a memory block. -@param memblock Previously allocated memory block to be freed +@param m Previously allocated memory block to be freed */ +#ifdef ALLOC_PERF_OPT +void OPJ_CALLCONV opj_free(void * m); +#else #define opj_free(m) free(m) +#endif #ifdef __GNUC__ #pragma GCC poison malloc calloc realloc free diff --git a/extern/libopenjpeg/phix_manager.c b/extern/libopenjpeg/phix_manager.c new file mode 100644 index 00000000000..60a02811785 --- /dev/null +++ b/extern/libopenjpeg/phix_manager.c @@ -0,0 +1,170 @@ +/* + * $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <stdlib.h> +#include <math.h> +#include "opj_includes.h" + +/* + * Write faix box of phix + * + * @param[in] coff offset of j2k codestream + * @param[in] compno component number + * @param[in] cstr_info codestream information + * @param[in] EPHused true if if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of faix box + */ +int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + +int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp=0, compno, i; + opj_jp2_box_t *box; + + box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t)); + + for( i=0;i<2;i++){ + if (i) cio_seek( cio, lenp); + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_PHIX, 4); /* PHIX */ + + write_manf( i, cstr_info.numcomps, box, cio); + + for( compno=0; compno<cstr_info.numcomps; compno++){ + box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio); + box[compno].type = JPIP_FAIX; + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free(box); + + return len; +} + +int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8 */ + opj_tile_info_t *tile_Idx; + opj_packet_info_t packet; + int resno, precno, layno, num_packet; + int numOfres, numOfprec, numOflayers; + packet.end_ph_pos = packet.start_pos = -1; + (void)EPHused; /* unused ? */ + + if( j2klen > pow( 2, 32)){ + size_of_coding = 8; + version = 1; + } + else{ + size_of_coding = 4; + version = 0; + } + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FAIX, 4); /* FAIX */ + cio_write( cio, version,1); /* Version 0 = 4 bytes */ + + nmax = 0; + for( i=0; i<=cstr_info.numdecompos[compno]; i++) + nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers; + + cio_write( cio, nmax, size_of_coding); /* NMAX */ + cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ + + for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ + tile_Idx = &cstr_info.tile[ tileno]; + + num_packet = 0; + numOfres = cstr_info.numdecompos[compno] + 1; + + for( resno=0; resno<numOfres ; resno++){ + numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno]; + for( precno=0; precno<numOfprec; precno++){ + numOflayers = cstr_info.numlayers; + for( layno=0; layno<numOflayers; layno++){ + + switch ( cstr_info.prog){ + case LRCP: + packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RLCP: + packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RPCL: + packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno]; + break; + case PCRL: + packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno]; + break; + case CPRL: + packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno]; + break; + default: + fprintf( stderr, "failed to ppix indexing\n"); + } + + cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ + cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */ + + num_packet++; + } + } + } + + /* PADDING */ + while( num_packet < nmax){ + cio_write( cio, 0, size_of_coding); /* start position */ + cio_write( cio, 0, size_of_coding); /* length */ + num_packet++; + } + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} diff --git a/extern/libopenjpeg/pi.c b/extern/libopenjpeg/pi.c index ac7654c5f14..e8e33bfe600 100644 --- a/extern/libopenjpeg/pi.c +++ b/extern/libopenjpeg/pi.c @@ -43,31 +43,31 @@ Get next packet in layer-resolution-component-precinct order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_lrcp(opj_pi_iterator_t * pi); +static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi); /** Get next packet in resolution-layer-component-precinct order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_rlcp(opj_pi_iterator_t * pi); +static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi); /** Get next packet in resolution-precinct-component-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_rpcl(opj_pi_iterator_t * pi); +static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi); /** Get next packet in precinct-component-resolution-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_pcrl(opj_pi_iterator_t * pi); +static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi); /** Get next packet in component-precinct-resolution-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_cprl(opj_pi_iterator_t * pi); +static opj_bool pi_next_cprl(opj_pi_iterator_t * pi); /*@}*/ @@ -79,7 +79,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi); ========================================================== */ -static bool pi_next_lrcp(opj_pi_iterator_t * pi) { +static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -108,7 +108,7 @@ static bool pi_next_lrcp(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -116,10 +116,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_rlcp(opj_pi_iterator_t * pi) { +static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -147,7 +147,7 @@ static bool pi_next_rlcp(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -155,10 +155,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_rpcl(opj_pi_iterator_t * pi) { +static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -209,14 +209,14 @@ if (!pi->tp_on){ try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; - if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpx))))){ + if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){ continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){ continue; } - if ((res->pw==0)||(res->pw==0)) continue; + if ((res->pw==0)||(res->ph==0)) continue; if ((trx0==trx1)||(try0==try1)) continue; @@ -229,7 +229,7 @@ if (!pi->tp_on){ index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -238,10 +238,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_pcrl(opj_pi_iterator_t * pi) { +static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -290,14 +290,14 @@ static bool pi_next_pcrl(opj_pi_iterator_t * pi) { try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; - if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpx))))){ + if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){ continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){ continue; } - if ((res->pw==0)||(res->pw==0)) continue; + if ((res->pw==0)||(res->ph==0)) continue; if ((trx0==trx1)||(try0==try1)) continue; @@ -310,7 +310,7 @@ static bool pi_next_pcrl(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -319,10 +319,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_cprl(opj_pi_iterator_t * pi) { +static opj_bool pi_next_cprl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -369,14 +369,14 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) { try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; - if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpx))))){ + if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){ continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){ continue; } - if ((res->pw==0)||(res->pw==0)) continue; + if ((res->pw==0)||(res->ph==0)) continue; if ((trx0==trx1)||(try0==try1)) continue; @@ -389,7 +389,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -398,7 +398,7 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } /* @@ -707,7 +707,7 @@ void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) { } } -bool pi_next(opj_pi_iterator_t * pi) { +opj_bool pi_next(opj_pi_iterator_t * pi) { switch (pi->poc.prg) { case LRCP: return pi_next_lrcp(pi); @@ -720,13 +720,13 @@ bool pi_next(opj_pi_iterator_t * pi) { case CPRL: return pi_next_cprl(pi); case PROG_UNKNOWN: - return false; + return OPJ_FALSE; } - return false; + return OPJ_FALSE; } -bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){ +opj_bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){ char prog[4]; int i; int incr_top=1,resetX=0; @@ -748,7 +748,7 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino, case RPCL: strncpy(prog, "RPCL",4); break; case PROG_UNKNOWN: - return true; + return OPJ_TRUE; } if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){ @@ -958,6 +958,6 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino, } } } - return false; + return OPJ_FALSE; } diff --git a/extern/libopenjpeg/pi.h b/extern/libopenjpeg/pi.h index b5e0f6a4df8..cf9135fd1f5 100644 --- a/extern/libopenjpeg/pi.h +++ b/extern/libopenjpeg/pi.h @@ -115,12 +115,14 @@ Modify the packet iterator for enabling tile part generation @param pi Handle to the packet iterator generated in pi_initialise_encode @param cp Coding parameters @param tileno Number that identifies the tile for which to list the packets +@param pino Iterator index for pi @param tpnum Tile part number of the current tile @param tppos The position of the tile part flag in the progression order +@param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass @param cur_totnum_tp The total number of tile parts in the current tile @return Returns true if an error is detected */ -bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp); +opj_bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp); /** Create a packet iterator for Decoder @param image Raw image for which the packets will be listed @@ -145,7 +147,7 @@ Modify the packet iterator to point to the next packet @param pi Packet iterator to modify @return Returns false if pi pointed to the last packet or else returns true */ -bool pi_next(opj_pi_iterator_t * pi); +opj_bool pi_next(opj_pi_iterator_t * pi); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/ppix_manager.c b/extern/libopenjpeg/ppix_manager.c new file mode 100644 index 00000000000..58d324ceb41 --- /dev/null +++ b/extern/libopenjpeg/ppix_manager.c @@ -0,0 +1,173 @@ +/* + * $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "opj_includes.h" + +/* + * Write faix box of ppix + * + * @param[in] coff offset of j2k codestream + * @param[in] compno component number + * @param[in] cstr_info codestream information + * @param[in] EPHused true if if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of faix box + */ +int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + +int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp, compno, i; + opj_jp2_box_t *box; + + /* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */ + + lenp = -1; + box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t)); + + for (i=0;i<2;i++){ + if (i) cio_seek( cio, lenp); + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_PPIX, 4); /* PPIX */ + + write_manf( i, cstr_info.numcomps, box, cio); + + for (compno=0; compno<cstr_info.numcomps; compno++){ + box[compno].length = write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio); + box[compno].type = JPIP_FAIX; + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free(box); + + return len; +} + +int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8*/ + opj_tile_info_t *tile_Idx; + opj_packet_info_t packet; + int resno, precno, layno, num_packet; + int numOfres, numOfprec, numOflayers; + packet.end_pos = packet.end_ph_pos = packet.start_pos = -1; + (void)EPHused; /* unused ? */ + + if( j2klen > pow( 2, 32)){ + size_of_coding = 8; + version = 1; + } + else{ + size_of_coding = 4; + version = 0; + } + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FAIX, 4); /* FAIX */ + cio_write( cio, version, 1); /* Version 0 = 4 bytes */ + + nmax = 0; + for( i=0; i<=cstr_info.numdecompos[compno]; i++) + nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers; + + cio_write( cio, nmax, size_of_coding); /* NMAX */ + cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ + + for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ + tile_Idx = &cstr_info.tile[ tileno]; + + num_packet=0; + numOfres = cstr_info.numdecompos[compno] + 1; + + for( resno=0; resno<numOfres ; resno++){ + numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno]; + for( precno=0; precno<numOfprec; precno++){ + numOflayers = cstr_info.numlayers; + for( layno=0; layno<numOflayers; layno++){ + + switch ( cstr_info.prog){ + case LRCP: + packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RLCP: + packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RPCL: + packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno]; + break; + case PCRL: + packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno]; + break; + case CPRL: + packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno]; + break; + default: + fprintf( stderr, "failed to ppix indexing\n"); + } + + cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ + cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */ + + num_packet++; + } + } + } + + while( num_packet < nmax){ /* PADDING */ + cio_write( cio, 0, size_of_coding); /* start position */ + cio_write( cio, 0, size_of_coding); /* length */ + num_packet++; + } + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} diff --git a/extern/libopenjpeg/t1.c b/extern/libopenjpeg/t1.c index ad1c6a83ab6..477720412aa 100644 --- a/extern/libopenjpeg/t1.c +++ b/extern/libopenjpeg/t1.c @@ -62,13 +62,25 @@ static void t1_enc_sigpass_step( /** Decode significant pass */ -static void t1_dec_sigpass_step( +static INLINE void t1_dec_sigpass_step_raw( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf, + int vsc); +static INLINE void t1_dec_sigpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf); +static INLINE void t1_dec_sigpass_step_mqc_vsc( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, int oneplushalf, - char type, int vsc); /** Encode significant pass @@ -83,12 +95,19 @@ static void t1_enc_sigpass( /** Decode significant pass */ -static void t1_dec_sigpass( +static void t1_dec_sigpass_raw( opj_t1_t *t1, int bpno, int orient, - char type, int cblksty); +static void t1_dec_sigpass_mqc( + opj_t1_t *t1, + int bpno, + int orient); +static void t1_dec_sigpass_mqc_vsc( + opj_t1_t *t1, + int bpno, + int orient); /** Encode refinement pass */ @@ -104,14 +123,27 @@ static void t1_enc_refpass_step( /** Decode refinement pass */ -static void t1_dec_refpass_step( +static INLINE void t1_dec_refpass_step_raw( opj_t1_t *t1, flag_t *flagsp, int *datap, int poshalf, int neghalf, - char type, int vsc); +static INLINE void t1_dec_refpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf); +static INLINE void t1_dec_refpass_step_mqc_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf, + int vsc); + /** Encode refinement pass */ @@ -124,11 +156,16 @@ static void t1_enc_refpass( /** Decode refinement pass */ -static void t1_dec_refpass( +static void t1_dec_refpass_raw( opj_t1_t *t1, int bpno, - char type, int cblksty); +static void t1_dec_refpass_mqc( + opj_t1_t *t1, + int bpno); +static void t1_dec_refpass_mqc_vsc( + opj_t1_t *t1, + int bpno); /** Encode clean-up pass */ @@ -145,11 +182,23 @@ static void t1_enc_clnpass_step( /** Decode clean-up pass */ +static void t1_dec_clnpass_step_partial( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf); static void t1_dec_clnpass_step( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, + int oneplushalf); +static void t1_dec_clnpass_step_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, int oneplushalf, int partial, int vsc); @@ -178,7 +227,8 @@ static double t1_getwmsedec( int bpno, int qmfbid, double stepsize, - int numcomps); + int numcomps, + int mct); /** Encode 1 code-block @param t1 T1 handle @@ -190,6 +240,7 @@ Encode 1 code-block @param stepsize @param cblksty Code-block style @param numcomps +@param mct @param tile */ static void t1_encode_cblk( @@ -202,6 +253,7 @@ static void t1_encode_cblk( double stepsize, int cblksty, int numcomps, + int mct, opj_tcd_tile_t * tile); /** Decode 1 code-block @@ -321,29 +373,43 @@ static void t1_enc_sigpass_step( } } -static void t1_dec_sigpass_step( +static INLINE void t1_dec_sigpass_step_raw( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, int oneplushalf, - char type, int vsc) { int v, flag; - opj_raw_t *raw = t1->raw; /* RAW component */ - opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + OPJ_ARG_NOT_USED(orient); flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { - if (type == T1_TYPE_RAW) { if (raw_decode(raw)) { v = raw_decode(raw); /* ESSAI */ *datap = v ? -oneplushalf : oneplushalf; t1_updateflags(flagsp, v, t1->flags_stride); } - } else { + *flagsp |= T1_VISIT; + } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_sigpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf) +{ + int v, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = *flagsp; + if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); if (mqc_decode(mqc)) { mqc_setcurctx(mqc, t1_getctxno_sc(flag)); @@ -351,6 +417,30 @@ static void t1_dec_sigpass_step( *datap = v ? -oneplushalf : oneplushalf; t1_updateflags(flagsp, v, t1->flags_stride); } + *flagsp |= T1_VISIT; + } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_sigpass_step_mqc_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf, + int vsc) +{ + int v, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); + if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { + mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); + if (mqc_decode(mqc)) { + mqc_setcurctx(mqc, t1_getctxno_sc(flag)); + v = mqc_decode(mqc) ^ t1_getspb(flag); + *datap = v ? -oneplushalf : oneplushalf; + t1_updateflags(flagsp, v, t1->flags_stride); } *flagsp |= T1_VISIT; } @@ -386,11 +476,10 @@ static void t1_enc_sigpass( } } -static void t1_dec_sigpass( +static void t1_dec_sigpass_raw( opj_t1_t *t1, int bpno, int orient, - char type, int cblksty) { int i, j, k, one, half, oneplushalf, vsc; @@ -401,13 +490,79 @@ static void t1_dec_sigpass( for (i = 0; i < t1->w; ++i) { for (j = k; j < k + 4 && j < t1->h; ++j) { vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0; - t1_dec_sigpass_step( + t1_dec_sigpass_step_raw( + t1, + &t1->flags[((j+1) * t1->flags_stride) + i + 1], + &t1->data[(j * t1->w) + i], + orient, + oneplushalf, + vsc); + } + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_sigpass_mqc( + opj_t1_t *t1, + int bpno, + int orient) +{ + int i, j, k, one, half, oneplushalf; + int *data1 = t1->data; + flag_t *flags1 = &t1->flags[1]; + one = 1 << bpno; + half = one >> 1; + oneplushalf = one | half; + for (k = 0; k < (t1->h & ~3); k += 4) { + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + data1 += t1->w << 2; + flags1 += t1->flags_stride << 2; + } + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + for (j = k; j < t1->h; ++j) { + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_sigpass_mqc_vsc( + opj_t1_t *t1, + int bpno, + int orient) +{ + int i, j, k, one, half, oneplushalf, vsc; + one = 1 << bpno; + half = one >> 1; + oneplushalf = one | half; + for (k = 0; k < t1->h; k += 4) { + for (i = 0; i < t1->w; ++i) { + for (j = k; j < k + 4 && j < t1->h; ++j) { + vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0; + t1_dec_sigpass_step_mqc_vsc( t1, &t1->flags[((j+1) * t1->flags_stride) + i + 1], &t1->data[(j * t1->w) + i], orient, oneplushalf, - type, vsc); } } @@ -442,28 +597,64 @@ static void t1_enc_refpass_step( } } -static void t1_dec_refpass_step( +static INLINE void t1_dec_refpass_step_raw( opj_t1_t *t1, flag_t *flagsp, int *datap, int poshalf, int neghalf, - char type, int vsc) { int v, t, flag; - opj_mqc_t *mqc = t1->mqc; /* MQC component */ opj_raw_t *raw = t1->raw; /* RAW component */ flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { - mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */ - if (type == T1_TYPE_RAW) { v = raw_decode(raw); - } else { + t = v ? poshalf : neghalf; + *datap += *datap < 0 ? -t : t; + *flagsp |= T1_REFINE; + } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_refpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf) +{ + int v, t, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = *flagsp; + if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { + mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */ v = mqc_decode(mqc); + t = v ? poshalf : neghalf; + *datap += *datap < 0 ? -t : t; + *flagsp |= T1_REFINE; } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_refpass_step_mqc_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf, + int vsc) +{ + int v, t, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); + if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { + mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */ + v = mqc_decode(mqc); t = v ? poshalf : neghalf; *datap += *datap < 0 ? -t : t; *flagsp |= T1_REFINE; @@ -498,10 +689,9 @@ static void t1_enc_refpass( } } -static void t1_dec_refpass( +static void t1_dec_refpass_raw( opj_t1_t *t1, int bpno, - char type, int cblksty) { int i, j, k, one, poshalf, neghalf; @@ -513,13 +703,78 @@ static void t1_dec_refpass( for (i = 0; i < t1->w; ++i) { for (j = k; j < k + 4 && j < t1->h; ++j) { vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0; - t1_dec_refpass_step( + t1_dec_refpass_step_raw( + t1, + &t1->flags[((j+1) * t1->flags_stride) + i + 1], + &t1->data[(j * t1->w) + i], + poshalf, + neghalf, + vsc); + } + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_refpass_mqc( + opj_t1_t *t1, + int bpno) +{ + int i, j, k, one, poshalf, neghalf; + int *data1 = t1->data; + flag_t *flags1 = &t1->flags[1]; + one = 1 << bpno; + poshalf = one >> 1; + neghalf = bpno > 0 ? -poshalf : -1; + for (k = 0; k < (t1->h & ~3); k += 4) { + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + } + data1 += t1->w << 2; + flags1 += t1->flags_stride << 2; + } + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + for (j = k; j < t1->h; ++j) { + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_refpass_mqc_vsc( + opj_t1_t *t1, + int bpno) +{ + int i, j, k, one, poshalf, neghalf; + int vsc; + one = 1 << bpno; + poshalf = one >> 1; + neghalf = bpno > 0 ? -poshalf : -1; + for (k = 0; k < t1->h; k += 4) { + for (i = 0; i < t1->w; ++i) { + for (j = k; j < k + 4 && j < t1->h; ++j) { + vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0; + t1_dec_refpass_step_mqc_vsc( t1, &t1->flags[((j+1) * t1->flags_stride) + i + 1], &t1->data[(j * t1->w) + i], poshalf, neghalf, - type, vsc); } } @@ -561,11 +816,55 @@ LABEL_PARTIAL: *flagsp &= ~T1_VISIT; } +static void t1_dec_clnpass_step_partial( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf) +{ + int v, flag; + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + OPJ_ARG_NOT_USED(orient); + + flag = *flagsp; + mqc_setcurctx(mqc, t1_getctxno_sc(flag)); + v = mqc_decode(mqc) ^ t1_getspb(flag); + *datap = v ? -oneplushalf : oneplushalf; + t1_updateflags(flagsp, v, t1->flags_stride); + *flagsp &= ~T1_VISIT; +} /* VSC and BYPASS by Antonin */ + static void t1_dec_clnpass_step( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, + int oneplushalf) +{ + int v, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = *flagsp; + if (!(flag & (T1_SIG | T1_VISIT))) { + mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); + if (mqc_decode(mqc)) { + mqc_setcurctx(mqc, t1_getctxno_sc(flag)); + v = mqc_decode(mqc) ^ t1_getspb(flag); + *datap = v ? -oneplushalf : oneplushalf; + t1_updateflags(flagsp, v, t1->flags_stride); + } + } + *flagsp &= ~T1_VISIT; +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_clnpass_step_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, int oneplushalf, int partial, int vsc) @@ -589,7 +888,7 @@ LABEL_PARTIAL: } } *flagsp &= ~T1_VISIT; -} /* VSC and BYPASS by Antonin */ +} static void t1_enc_clnpass( opj_t1_t *t1, @@ -669,22 +968,16 @@ static void t1_dec_clnpass( one = 1 << bpno; half = one >> 1; oneplushalf = one | half; + if (cblksty & J2K_CCP_CBLKSTY_VSC) { for (k = 0; k < t1->h; k += 4) { for (i = 0; i < t1->w; ++i) { if (k + 3 < t1->h) { - if (cblksty & J2K_CCP_CBLKSTY_VSC) { agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) || (MACRO_t1_flags(1 + k + 3,1 + i) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); } else { - agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) - || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) - || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) - || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); - } - } else { agg = 0; } if (agg) { @@ -699,8 +992,8 @@ static void t1_dec_clnpass( runlen = 0; } for (j = k + runlen; j < k + 4 && j < t1->h; ++j) { - vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0; - t1_dec_clnpass_step( + vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0; + t1_dec_clnpass_step_vsc( t1, &t1->flags[((j+1) * t1->flags_stride) + i + 1], &t1->data[(j * t1->w) + i], @@ -711,6 +1004,65 @@ static void t1_dec_clnpass( } } } + } else { + int *data1 = t1->data; + flag_t *flags1 = &t1->flags[1]; + for (k = 0; k < (t1->h & ~3); k += 4) { + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) + || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) + || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) + || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); + if (agg) { + mqc_setcurctx(mqc, T1_CTXNO_AGG); + if (!mqc_decode(mqc)) { + continue; + } + mqc_setcurctx(mqc, T1_CTXNO_UNI); + runlen = mqc_decode(mqc); + runlen = (runlen << 1) | mqc_decode(mqc); + flags2 += runlen * t1->flags_stride; + data2 += runlen * t1->w; + for (j = k + runlen; j < k + 4 && j < t1->h; ++j) { + flags2 += t1->flags_stride; + if (agg && (j == k + runlen)) { + t1_dec_clnpass_step_partial(t1, flags2, data2, orient, oneplushalf); + } else { + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + } + data2 += t1->w; + } + } else { + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + } + data1 += t1->w << 2; + flags1 += t1->flags_stride << 2; + } + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + for (j = k; j < t1->h; ++j) { + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + } + } + if (segsym) { int v = 0; mqc_setcurctx(mqc, T1_CTXNO_UNI); @@ -736,14 +1088,15 @@ static double t1_getwmsedec( int bpno, int qmfbid, double stepsize, - int numcomps) + int numcomps, + int mct) { double w1, w2, wmsedec; if (qmfbid == 1) { - w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0; + w1 = (mct && numcomps==3) ? mct_getnorm(compno) : 1.0; w2 = dwt_getnorm(level, orient); } else { /* if (qmfbid == 0) */ - w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0; + w1 = (mct && numcomps==3) ? mct_getnorm_real(compno) : 1.0; w2 = dwt_getnorm_real(level, orient); } wmsedec = w1 * w2 * stepsize * (1 << bpno); @@ -752,7 +1105,7 @@ static double t1_getwmsedec( return wmsedec; } -static bool allocate_buffers( +static opj_bool allocate_buffers( opj_t1_t *t1, int w, int h) @@ -764,7 +1117,7 @@ static bool allocate_buffers( opj_aligned_free(t1->data); t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int)); if(!t1->data){ - return false; + return OPJ_FALSE; } t1->datasize=datasize; } @@ -777,7 +1130,7 @@ static bool allocate_buffers( opj_aligned_free(t1->flags); t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t)); if(!t1->flags){ - return false; + return OPJ_FALSE; } t1->flagssize=flagssize; } @@ -786,7 +1139,7 @@ static bool allocate_buffers( t1->w=w; t1->h=h; - return true; + return OPJ_TRUE; } /** mod fixed_quality */ @@ -800,6 +1153,7 @@ static void t1_encode_cblk( double stepsize, int cblksty, int numcomps, + int mct, opj_tcd_tile_t * tile) { double cumwmsedec = 0.0; @@ -850,7 +1204,7 @@ static void t1_encode_cblk( } /* fixed_quality */ - tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps); + tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps, mct); cumwmsedec += tempwmsedec; tile->distotile += tempwmsedec; @@ -971,10 +1325,26 @@ static void t1_decode_cblk( for (passno = 0; passno < seg->numpasses; ++passno) { switch (passtype) { case 0: - t1_dec_sigpass(t1, bpno+1, orient, type, cblksty); + if (type == T1_TYPE_RAW) { + t1_dec_sigpass_raw(t1, bpno+1, orient, cblksty); + } else { + if (cblksty & J2K_CCP_CBLKSTY_VSC) { + t1_dec_sigpass_mqc_vsc(t1, bpno+1, orient); + } else { + t1_dec_sigpass_mqc(t1, bpno+1, orient); + } + } break; case 1: - t1_dec_refpass(t1, bpno+1, type, cblksty); + if (type == T1_TYPE_RAW) { + t1_dec_refpass_raw(t1, bpno+1, cblksty); + } else { + if (cblksty & J2K_CCP_CBLKSTY_VSC) { + t1_dec_refpass_mqc_vsc(t1, bpno+1); + } else { + t1_dec_refpass_mqc(t1, bpno+1); + } + } break; case 2: t1_dec_clnpass(t1, bpno+1, orient, cblksty); @@ -1045,6 +1415,7 @@ void t1_encode_cblks( for (bandno = 0; bandno < res->numbands; ++bandno) { opj_tcd_band_t* restrict band = &res->bands[bandno]; + int bandconst = 8192 * 8192 / ((int) floor(band->stepsize * 8192)); for (precno = 0; precno < res->pw * res->ph; ++precno) { opj_tcd_precinct_t *prc = &band->precincts[precno]; @@ -1095,7 +1466,7 @@ void t1_encode_cblks( datap[(j * cblk_w) + i] = fix_mul( tmp, - 8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS); + bandconst) >> (11 - T1_NMSEDEC_FRACBITS); } } } @@ -1110,6 +1481,7 @@ void t1_encode_cblks( band->stepsize, tccp->cblksty, tile->numcomps, + tcp->mct, tile); } /* cblkno */ @@ -1140,7 +1512,6 @@ void t1_decode_cblks( for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) { opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno]; int* restrict datap; - void* restrict tiledp; int cblk_w, cblk_h; int x, y; int i, j; @@ -1181,8 +1552,8 @@ void t1_decode_cblks( } } - tiledp=(void*)&tilec->data[(y * tile_w) + x]; if (tccp->qmfbid == 1) { + int* restrict tiledp = &tilec->data[(y * tile_w) + x]; for (j = 0; j < cblk_h; ++j) { for (i = 0; i < cblk_w; ++i) { int tmp = datap[(j * cblk_w) + i]; @@ -1190,11 +1561,16 @@ void t1_decode_cblks( } } } else { /* if (tccp->qmfbid == 0) */ + float* restrict tiledp = (float*) &tilec->data[(y * tile_w) + x]; for (j = 0; j < cblk_h; ++j) { + float* restrict tiledp2 = tiledp; for (i = 0; i < cblk_w; ++i) { - float tmp = datap[(j * cblk_w) + i] * band->stepsize; - ((float*)tiledp)[(j * tile_w) + i] = tmp; + float tmp = *datap * band->stepsize; + *tiledp2 = tmp; + datap++; + tiledp2++; } + tiledp += tile_w; } } opj_free(cblk->data); diff --git a/extern/libopenjpeg/t1.h b/extern/libopenjpeg/t1.h index 0b4294e1d6b..572ec88d2f6 100644 --- a/extern/libopenjpeg/t1.h +++ b/extern/libopenjpeg/t1.h @@ -135,8 +135,8 @@ void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp); /** Decode the code-blocks of a tile @param t1 T1 handle -@param tile The tile to decode -@param tcp Tile coding parameters +@param tilec The tile to decode +@param tccp Tile coding parameters */ void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp); /* ----------------------------------------------------------------------- */ diff --git a/extern/libopenjpeg/t2.c b/extern/libopenjpeg/t2.c index be9b42a4132..232a5437329 100644 --- a/extern/libopenjpeg/t2.c +++ b/extern/libopenjpeg/t2.c @@ -59,7 +59,8 @@ Encode a packet of a tile to a destination buffer */ static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_codestream_info_t *cstr_info, int tileno); /** -@param seg +@param cblk +@param index @param cblksty @param first */ @@ -72,6 +73,7 @@ Decode a packet of a tile from a source buffer @param tile Tile for which to write the packets @param tcp Tile coding parameters @param pi Packet identity +@param pack_info Packet information @return */ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, @@ -147,8 +149,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera c[1] = 145; c[2] = 0; c[3] = 4; - c[4] = (tile->packno % 65536) / 256; - c[5] = (tile->packno % 65536) % 256; + c[4] = (unsigned char)((tile->packno % 65536) / 256); + c[5] = (unsigned char)((tile->packno % 65536) % 256); c += 6; } /* </SOP> */ @@ -253,8 +255,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera /* </EPH> */ /* << INDEX */ - // End of packet header position. Currently only represents the distance to start of packet - // Will be updated later by incrementing with packet start value + /* End of packet header position. Currently only represents the distance to start of packet + // Will be updated later by incrementing with packet start value */ if(cstr_info && cstr_info->index_write) { opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno]; info_PK->end_ph_pos = (int)(c - dest); @@ -401,8 +403,8 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t } /* << INDEX */ - // End of packet header position. Currently only represents the distance to start of packet - // Will be updated later by incrementing with packet start value + /* End of packet header position. Currently only represents the distance to start of packet + // Will be updated later by incrementing with packet start value*/ if(pack_info) { pack_info->end_ph_pos = (int)(c - src); } @@ -494,14 +496,15 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t if (tcp->csty & J2K_CP_CSTY_EPH) { if ((*hd) != 0xff || (*(hd + 1) != 0x92)) { opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n"); + return -999; } else { hd += 2; } } /* << INDEX */ - // End of packet header position. Currently only represents the distance to start of packet - // Will be updated later by incrementing with packet start value + /* End of packet header position. Currently only represents the distance to start of packet + // Will be updated later by incrementing with packet start value*/ if(pack_info) { pack_info->end_ph_pos = (int)(hd - src); } @@ -565,7 +568,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t #endif /* USE_JPWL */ - cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char*)); + cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char)); memcpy(cblk->data + cblk->len, c, seg->newlen); if (seg->numpasses == 0) { seg->data = &cblk->data; @@ -614,6 +617,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye int tpnum = compno; if (pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode,cur_totnum_tp)) { opj_event_msg(t2->cinfo, EVT_ERROR, "Error initializing Packet Iterator\n"); + pi_destroy(pi, cp, tileno); return -999; } while (pi_next(&pi[poc])) { @@ -658,8 +662,8 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye info_PK->start_pos = ((cp->tp_on | tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1; } info_PK->end_pos = info_PK->start_pos + e - 1; - info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance - // to start of packet is incremented by value of start of packet + info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance + // to start of packet is incremented by value of start of packet*/ } cstr_info->packno++; @@ -710,7 +714,7 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj } else { e = 0; } - + if(e == -999) return -999; /* progression in resolution */ image->comps[pi[pino].compno].resno_decoded = (e > 0) ? @@ -724,8 +728,9 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno]; if (!cstr_info->packno) { info_PK->start_pos = info_TL->end_header + 1; - } else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ // New tile part - info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in previous tile-part + } else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ /* New tile part*/ + info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in previous tile-part*/ + info_TL->tp[curtp].tp_start_pack = tp_start_packno; tp_start_packno = cstr_info->packno; curtp++; info_PK->start_pos = cstr_info->tile[tileno].tp[curtp].tp_end_header+1; @@ -733,8 +738,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1; } info_PK->end_pos = info_PK->start_pos + e - 1; - info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance - // to start of packet is incremented by value of start of packet + info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance + // to start of packet is incremented by value of start of packet*/ cstr_info->packno++; } /* << INDEX */ @@ -748,7 +753,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj } /* INDEX >> */ if(cstr_info) { - cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in last tile-part + cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in last tile-part*/ + cstr_info->tile[tileno].tp[curtp].tp_start_pack = tp_start_packno; } /* << INDEX */ diff --git a/extern/libopenjpeg/t2.h b/extern/libopenjpeg/t2.h index b15b7520019..2151ba67f48 100644 --- a/extern/libopenjpeg/t2.h +++ b/extern/libopenjpeg/t2.h @@ -67,6 +67,7 @@ Encode the packets of a tile to a destination buffer @param cstr_info Codestream information structure @param tpnum Tile part number of the current tile @param tppos The position of the tile part flag in the progression order +@param pino @param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass @param cur_totnum_tp The total number of tile parts in the current tile */ @@ -78,6 +79,7 @@ Decode the packets of a tile from a source buffer @param len length of the source buffer @param tileno number that identifies the tile for which to decode the packets @param tile tile for which to decode the packets +@param cstr_info Codestream information structure */ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info); diff --git a/extern/libopenjpeg/tcd.c b/extern/libopenjpeg/tcd.c index f4a54553e28..18cdbc786bc 100644 --- a/extern/libopenjpeg/tcd.c +++ b/extern/libopenjpeg/tcd.c @@ -33,7 +33,7 @@ #include "opj_includes.h" void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) { - int tileno, compno, resno, bandno, precno;//, cblkno; + int tileno, compno, resno, bandno, precno;/*, cblkno;*/ fprintf(fd, "image {\n"); fprintf(fd, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", @@ -290,6 +290,7 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c for (i = 0; i < res->pw * res->ph * 3; i++) { band->precincts[i].imsbtree = NULL; band->precincts[i].incltree = NULL; + band->precincts[i].cblks.enc = NULL; } for (precno = 0; precno < res->pw * res->ph; precno++) { @@ -418,12 +419,19 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur /* Modification of the RATE >> */ for (j = 0; j < tcp->numlayers; j++) { tcp->rates[j] = tcp->rates[j] ? - ((float) (tile->numcomps - * (tile->x1 - tile->x0) - * (tile->y1 - tile->y0) - * image->comps[0].prec))/ - (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy) - : 0; + cp->tp_on ? + (((float) (tile->numcomps + * (tile->x1 - tile->x0) + * (tile->y1 - tile->y0) + * image->comps[0].prec)) + /(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)) - (((tcd->cur_totnum_tp - 1) * 14 )/ tcp->numlayers) + : + ((float) (tile->numcomps + * (tile->x1 - tile->x0) + * (tile->y1 - tile->y0) + * image->comps[0].prec))/ + (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy) + : 0; if (tcp->rates[j]) { if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) { @@ -584,7 +592,9 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur cblk->y0 = int_max(cblkystart, prc->y0); cblk->x1 = int_min(cblkxend, prc->x1); cblk->y1 = int_min(cblkyend, prc->y1); - cblk->data = (unsigned char*) opj_calloc(8192, sizeof(unsigned char)); + cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char)); + /* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */ + cblk->data += 2; cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t)); cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t)); } @@ -647,7 +657,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) { tilec->y1 = int_ceildiv(tile->y1, image->comps[i].dy); x0 = j == 0 ? tilec->x0 : int_min(x0, (unsigned int) tilec->x0); - y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->x0); + y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->y0); x1 = j == 0 ? tilec->x1 : int_max(x1, (unsigned int) tilec->x1); y1 = j == 0 ? tilec->y1 : int_max(y1, (unsigned int) tilec->y1); } @@ -667,6 +677,8 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, opj_tcp_t *tcp; opj_tcd_tile_t *tile; + OPJ_ARG_NOT_USED(cstr_info); + tcd->cp = cp; tcp = &(cp->tcps[cp->tileno[tileno]]); @@ -988,7 +1000,7 @@ void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) { } } -bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) { +opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) { int compno, resno, bandno, precno, cblkno, passno, layno; double min, max; double cumdisto[100]; /* fixed_quality */ @@ -1085,7 +1097,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre opj_t2_t *t2 = t2_create(tcd->cinfo, tcd->image, cp); double thresh = 0; - for (i = 0; i < 32; i++) { + for (i = 0; i < 128; i++) { int l = 0; double distoachieved = 0; /* fixed_quality */ thresh = (lo + hi) / 2; @@ -1140,7 +1152,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre } if (!success) { - return false; + return OPJ_FALSE; } if(cstr_info) { /* Threshold for Marcela Index */ @@ -1152,7 +1164,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]); } - return true; + return OPJ_TRUE; } int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) { @@ -1304,7 +1316,7 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op return l; } -bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) { +opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) { int l; int compno; int eof = 0; @@ -1340,7 +1352,7 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op } else { cstr_info->tile[tileno].pdx[resno] = 15; - cstr_info->tile[tileno].pdx[resno] = 15; + cstr_info->tile[tileno].pdy[resno] = 15; } } } @@ -1387,7 +1399,7 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op if (tcd->image->comps[compno].resno_decoded < 0) { opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number " " of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions); - return false; + return OPJ_FALSE; } } @@ -1407,18 +1419,23 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op if (tcd->tcp->mct) { int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0); - if (tcd->tcp->tccps[0].qmfbid == 1) { - mct_decode( - tile->comps[0].data, - tile->comps[1].data, - tile->comps[2].data, - n); - } else { - mct_decode_real( - (float*)tile->comps[0].data, - (float*)tile->comps[1].data, - (float*)tile->comps[2].data, - n); + + if (tile->numcomps >= 3 ){ + if (tcd->tcp->tccps[0].qmfbid == 1) { + mct_decode( + tile->comps[0].data, + tile->comps[1].data, + tile->comps[2].data, + n); + } else { + mct_decode_real( + (float*)tile->comps[0].data, + (float*)tile->comps[1].data, + (float*)tile->comps[2].data, + n); + } + } else{ + opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps); } } @@ -1467,10 +1484,10 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time); if (eof) { - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } void tcd_free_decode(opj_tcd_t *tcd) { @@ -1504,3 +1521,4 @@ void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) { } + diff --git a/extern/libopenjpeg/tcd.h b/extern/libopenjpeg/tcd.h index f0ac5619f1e..e3f93adc37f 100644 --- a/extern/libopenjpeg/tcd.h +++ b/extern/libopenjpeg/tcd.h @@ -251,7 +251,7 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final); void tcd_rateallocate_fixed(opj_tcd_t *tcd); void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final); -bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info); +opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info); /** Encode a tile from the raw image into a buffer @param tcd TCD handle @@ -268,8 +268,9 @@ Decode a tile from a buffer into a raw image @param src Source buffer @param len Length of source buffer @param tileno Number that identifies one of the tiles to be decoded +@param cstr_info Codestream information structure */ -bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info); +opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info); /** Free the memory allocated for decoding @param tcd TCD handle diff --git a/extern/libopenjpeg/thix_manager.c b/extern/libopenjpeg/thix_manager.c new file mode 100644 index 00000000000..aa55f217c06 --- /dev/null +++ b/extern/libopenjpeg/thix_manager.c @@ -0,0 +1,120 @@ +/* + * $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "opj_includes.h" + +/* + * Write tile-part headers mhix box + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] tileno tile number + * @param[in] cio file output handle + * @return length of mhix box + */ +int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio); + +int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio) +{ + int len, lenp, i; + int tileno; + opj_jp2_box_t *box; + + lenp = 0; + box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t)); + + for ( i = 0; i < 2 ; i++ ){ + if (i) + cio_seek( cio, lenp); + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_THIX, 4); /* THIX */ + write_manf( i, cstr_info.tw*cstr_info.th, box, cio); + + for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){ + box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio); + box[tileno].type = JPIP_MHIX; + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free(box); + + return len; +} + +int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio) +{ + int i; + opj_tile_info_t tile; + opj_tp_info_t tp; + int len, lenp; + opj_marker_info_t *marker; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_MHIX, 4); /* MHIX */ + + tile = cstr_info.tile[tileno]; + tp = tile.tp[0]; + + cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */ + + marker = cstr_info.tile[tileno].marker; + + for( i=0; i<cstr_info.tile[tileno].marknum; i++){ /* Marker restricted to 1 apparition */ + cio_write( cio, marker[i].type, 2); + cio_write( cio, 0, 2); + cio_write( cio, marker[i].pos-coff, 8); + cio_write( cio, marker[i].len, 2); + } + + /* free( marker);*/ + + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} diff --git a/extern/libopenjpeg/tpix_manager.c b/extern/libopenjpeg/tpix_manager.c new file mode 100644 index 00000000000..9ba9e7fdabc --- /dev/null +++ b/extern/libopenjpeg/tpix_manager.c @@ -0,0 +1,153 @@ +/* + * $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <math.h> +#include "opj_includes.h" + +#define MAX(a,b) ((a)>(b)?(a):(b)) + + +/* + * Write faix box of tpix + * + * @param[in] coff offset of j2k codestream + * @param[in] compno component number + * @param[in] cstr_info codestream information + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of faix box + */ +int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio); + + +int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio) +{ + int len, lenp; + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_TPIX, 4); /* TPIX */ + + write_tpixfaix( coff, 0, cstr_info, j2klen, cio); + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} + + +/* + * Get number of maximum tile parts per tile + * + * @param[in] cstr_info codestream information + * @return number of maximum tile parts per tile + */ +int get_num_max_tile_parts( opj_codestream_info_t cstr_info); + +int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio) +{ + int len, lenp; + int i, j; + int Aux; + int num_max_tile_parts; + int size_of_coding; /* 4 or 8 */ + opj_tp_info_t tp; + int version; + + num_max_tile_parts = get_num_max_tile_parts( cstr_info); + + if( j2klen > pow( 2, 32)){ + size_of_coding = 8; + version = num_max_tile_parts == 1 ? 1:3; + } + else{ + size_of_coding = 4; + version = num_max_tile_parts == 1 ? 0:2; + } + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FAIX, 4); /* FAIX */ + cio_write( cio, version, 1); /* Version 0 = 4 bytes */ + + cio_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */ + cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ + for (i = 0; i < cstr_info.tw*cstr_info.th; i++){ + for (j = 0; j < cstr_info.tile[i].num_tps; j++){ + tp = cstr_info.tile[i].tp[j]; + cio_write( cio, tp.tp_start_pos-coff, size_of_coding); /* start position */ + cio_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */ + if (version & 0x02){ + if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1) + Aux = cstr_info.numdecompos[compno] + 1; + else + Aux = j + 1; + + cio_write( cio, Aux,4); + /*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */ + /* fprintf(stderr,"AUX value %d\n",Aux);*/ + } + /*cio_write(0,4);*/ + } + /* PADDING */ + while (j < num_max_tile_parts){ + cio_write( cio, 0, size_of_coding); /* start position */ + cio_write( cio, 0, size_of_coding); /* length */ + if (version & 0x02) + cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */ + j++; + } + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; + +} + +int get_num_max_tile_parts( opj_codestream_info_t cstr_info) +{ + int num_max_tp = 0, i; + + for( i=0; i<cstr_info.tw*cstr_info.th; i++) + num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp); + + return num_max_tp; +} diff --git a/extern/recastnavigation/recast-capi.cpp b/extern/recastnavigation/recast-capi.cpp index 9aeb0d65cb0..1cf8ed5546e 100644 --- a/extern/recastnavigation/recast-capi.cpp +++ b/extern/recastnavigation/recast-capi.cpp @@ -278,7 +278,7 @@ static inline void swapfunc(char *, char *, int, int); #define min(a, b) (a) < (b) ? a : b #define swapcode(TYPE, parmi, parmj, n) \ { \ - long i = (n) / sizeof (TYPE); \ + long i = (n) / sizeof(TYPE); \ TYPE *pi = (TYPE *) (parmi); \ TYPE *pj = (TYPE *) (parmj); \ do { \ diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp index bbc7a0ca52e..238249bc7c8 100644 --- a/intern/audaspace/Python/AUD_PyAPI.cpp +++ b/intern/audaspace/Python/AUD_PyAPI.cpp @@ -28,7 +28,7 @@ #include "AUD_PyAPI.h" -#include "structmember.h" +#include <structmember.h> #include "AUD_I3DDevice.h" #include "AUD_I3DHandle.h" diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp index 6553073c54e..28a14a9cfc7 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -143,23 +143,23 @@ void AUD_FFMPEGReader::init() switch(m_codecCtx->sample_fmt) { - case SAMPLE_FMT_U8: + case AV_SAMPLE_FMT_U8: m_convert = AUD_convert_u8_float; m_specs.format = AUD_FORMAT_U8; break; - case SAMPLE_FMT_S16: + case AV_SAMPLE_FMT_S16: m_convert = AUD_convert_s16_float; m_specs.format = AUD_FORMAT_S16; break; - case SAMPLE_FMT_S32: + case AV_SAMPLE_FMT_S32: m_convert = AUD_convert_s32_float; m_specs.format = AUD_FORMAT_S32; break; - case SAMPLE_FMT_FLT: + case AV_SAMPLE_FMT_FLT: m_convert = AUD_convert_copy<float>; m_specs.format = AUD_FORMAT_FLOAT32; break; - case SAMPLE_FMT_DBL: + case AV_SAMPLE_FMT_DBL: m_convert = AUD_convert_double_float; m_specs.format = AUD_FORMAT_FLOAT64; break; @@ -189,7 +189,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(std::string filename) : } catch(AUD_Exception&) { - av_close_input_file(m_formatCtx); + avformat_close_input(&m_formatCtx); throw; } } @@ -227,7 +227,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) : } catch(AUD_Exception&) { - av_close_input_stream(m_formatCtx); + avformat_close_input(&m_formatCtx); av_free(m_aviocontext); throw; } @@ -239,7 +239,7 @@ AUD_FFMPEGReader::~AUD_FFMPEGReader() if(m_aviocontext) { - av_close_input_stream(m_formatCtx); + avformat_close_input(&m_formatCtx); av_free(m_aviocontext); } else diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp index 702c366c4df..2b34348da81 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGWriter.cpp @@ -133,23 +133,23 @@ AUD_FFMPEGWriter::AUD_FFMPEGWriter(std::string filename, AUD_DeviceSpecs specs, { case AUD_FORMAT_U8: m_convert = AUD_convert_float_u8; - m_codecCtx->sample_fmt = SAMPLE_FMT_U8; + m_codecCtx->sample_fmt = AV_SAMPLE_FMT_U8; break; case AUD_FORMAT_S16: m_convert = AUD_convert_float_s16; - m_codecCtx->sample_fmt = SAMPLE_FMT_S16; + m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S16; break; case AUD_FORMAT_S32: m_convert = AUD_convert_float_s32; - m_codecCtx->sample_fmt = SAMPLE_FMT_S32; + m_codecCtx->sample_fmt = AV_SAMPLE_FMT_S32; break; case AUD_FORMAT_FLOAT32: m_convert = AUD_convert_copy<float>; - m_codecCtx->sample_fmt = SAMPLE_FMT_FLT; + m_codecCtx->sample_fmt = AV_SAMPLE_FMT_FLT; break; case AUD_FORMAT_FLOAT64: m_convert = AUD_convert_float_double; - m_codecCtx->sample_fmt = SAMPLE_FMT_DBL; + m_codecCtx->sample_fmt = AV_SAMPLE_FMT_DBL; break; default: AUD_THROW(AUD_ERROR_FFMPEG, format_error); diff --git a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp index 543e7e087b1..46cde625cf2 100644 --- a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp +++ b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp @@ -205,15 +205,15 @@ Operate( void BSP_GhostTestApp3D:: UpdateFrame( -){ -if (m_window) { +) { + if (m_window) { - GHOST_Rect v_rect; - m_window->getClientBounds(v_rect); + GHOST_Rect v_rect; + m_window->getClientBounds(v_rect); - glViewport(0,0,v_rect.getWidth(),v_rect.getHeight()); + glViewport(0,0,v_rect.getWidth(),v_rect.getHeight()); -} + } } diff --git a/intern/bsp/test/BSP_GhostTest/main.cpp b/intern/bsp/test/BSP_GhostTest/main.cpp index d5fa884afa1..25185f40192 100644 --- a/intern/bsp/test/BSP_GhostTest/main.cpp +++ b/intern/bsp/test/BSP_GhostTest/main.cpp @@ -93,8 +93,8 @@ NewTestMesh( #endif -int main() { - +int main() +{ MT_Vector3 min,max; MT_Vector3 min2,max2; diff --git a/intern/bsp/test/BSP_GhostTest/plyfile.c b/intern/bsp/test/BSP_GhostTest/plyfile.c index 9cb9d81da22..b0134f06557 100644 --- a/intern/bsp/test/BSP_GhostTest/plyfile.c +++ b/intern/bsp/test/BSP_GhostTest/plyfile.c @@ -28,37 +28,37 @@ /* -The interface routines for reading and writing PLY polygon files. + The interface routines for reading and writing PLY polygon files. -Greg Turk, February 1994 + Greg Turk, February 1994 ---------------------------------------------------------------- + --------------------------------------------------------------- -A PLY file contains a single polygonal _object_. + A PLY file contains a single polygonal _object_. -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. + An object is composed of lists of _elements_. Typical elements are + vertices, faces, edges and materials. -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties the floating-point values x,y,z and the three unsigned -chars representing red, green and blue. + Each type of element for a given object has one or more _properties_ + associated with the element type. For instance, a vertex element may + have as properties the floating-point values x,y,z and the three unsigned + chars representing red, green and blue. ---------------------------------------------------------------- + --------------------------------------------------------------- -Copyright (c) 1994 The Board of Trustees of The Leland Stanford -Junior University. All rights reserved. + Copyright (c) 1994 The Board of Trustees of The Leland Stanford + Junior University. All rights reserved. -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. + Permission to use, copy, modify and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that the above copyright notice and this permission notice appear in + all copies of this software and that you do not sell the software. -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -*/ + */ #include <stdio.h> #include <stdlib.h> @@ -67,14 +67,14 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. #include "ply.h" char *type_names[] = { -"invalid", -"char", "short", "int", -"uchar", "ushort", "uint", -"float", "double", + "invalid", + "char", "short", "int", + "uchar", "ushort", "uint", + "float", "double", }; int ply_type_size[] = { - 0, 1, 2, 4, 1, 2, 4, 4, 8 + 0, 1, 2, 4, 1, 2, 4, 4, 8 }; #define NO_OTHER_PROPS -1 @@ -96,7 +96,7 @@ PlyElement *find_element(PlyFile *, char *); PlyProperty *find_property(PlyElement *, char *, int *); /* write to a file the word describing a PLY file data type */ -void write_scalar_type (FILE *, int); +void write_scalar_type(FILE *, int); /* read a line from a file and break it up into separate words */ char **get_words(FILE *, int *, char **); @@ -120,7 +120,7 @@ void copy_property(PlyProperty *, PlyProperty *); void store_item(char *, int, int, unsigned int, double); /* return the value of a stored item */ -void get_stored_item( void *, int, int *, unsigned int *, double *); +void get_stored_item(void *, int, int *, unsigned int *, double *); /* return the value stored in an item, given ptr to it and its type */ double get_item_value(char *, int); @@ -143,551 +143,551 @@ char *my_alloc(int, int, char *); /****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. + Given a file pointer, get ready to write PLY data to the file. -Entry: - fp - the given file pointer - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary + Entry: + fp - the given file pointer + nelems - number of elements in object + elem_names - list of element names + file_type - file type, either ascii or binary -Exit: - returns a pointer to a PlyFile, used to refer to this file, or NULL if error + Exit: + returns a pointer to a PlyFile, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_write( - FILE *fp, - int nelems, - char **elem_names, - int file_type -) + FILE *fp, + int nelems, + char **elem_names, + int file_type + ) { - int i; - PlyFile *plyfile; - PlyElement *elem; - - /* check for NULL file pointer */ - if (fp == NULL) - return (NULL); - - /* create a record for this object */ - - plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); - plyfile->file_type = file_type; - plyfile->num_comments = 0; - plyfile->num_obj_info = 0; - plyfile->nelems = nelems; - plyfile->version = 1.0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* tuck aside the names of the elements */ - - plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *) * nelems); - for (i = 0; i < nelems; i++) { - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - plyfile->elems[i] = elem; - elem->name = strdup (elem_names[i]); - elem->num = 0; - elem->nprops = 0; - } - - /* return pointer to the file descriptor */ - return (plyfile); + int i; + PlyFile *plyfile; + PlyElement *elem; + + /* check for NULL file pointer */ + if (fp == NULL) + return (NULL); + + /* create a record for this object */ + + plyfile = (PlyFile *) myalloc(sizeof(PlyFile)); + plyfile->file_type = file_type; + plyfile->num_comments = 0; + plyfile->num_obj_info = 0; + plyfile->nelems = nelems; + plyfile->version = 1.0; + plyfile->fp = fp; + plyfile->other_elems = NULL; + + /* tuck aside the names of the elements */ + + plyfile->elems = (PlyElement **) myalloc(sizeof(PlyElement *) * nelems); + for (i = 0; i < nelems; i++) { + elem = (PlyElement *) myalloc(sizeof(PlyElement)); + plyfile->elems[i] = elem; + elem->name = strdup(elem_names[i]); + elem->num = 0; + elem->nprops = 0; + } + + /* return pointer to the file descriptor */ + return (plyfile); } /****************************************************************************** -Open a polygon file for writing. + Open a polygon file for writing. -Entry: - filename - name of file to read from - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary + Entry: + filename - name of file to read from + nelems - number of elements in object + elem_names - list of element names + file_type - file type, either ascii or binary -Exit: - version - version number of PLY file - returns a file identifier, used to refer to this file, or NULL if error + Exit: + version - version number of PLY file + returns a file identifier, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_open_for_writing( - char *filename, - int nelems, - char **elem_names, - int file_type, - float *version -) + char *filename, + int nelems, + char **elem_names, + int file_type, + float *version + ) { - PlyFile *plyfile; - char *name; - FILE *fp; + PlyFile *plyfile; + char *name; + FILE *fp; - /* tack on the extension .ply, if necessary */ + /* tack on the extension .ply, if necessary */ - name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5)); - strcpy (name, filename); - if (strlen (name) < 4 || - strcmp (name + strlen (name) - 4, ".ply") != 0) - strcat (name, ".ply"); + name = (char *) myalloc(sizeof(char) * (strlen(filename) + 5)); + strcpy(name, filename); + if (strlen(name) < 4 || + strcmp(name + strlen(name) - 4, ".ply") != 0) + strcat(name, ".ply"); - /* open the file for writing */ + /* open the file for writing */ - fp = fopen (name, "w"); - if (fp == NULL) { - return (NULL); - } + fp = fopen(name, "w"); + if (fp == NULL) { + return (NULL); + } - /* create the actual PlyFile structure */ + /* create the actual PlyFile structure */ - plyfile = ply_write (fp, nelems, elem_names, file_type); - if (plyfile == NULL) - return (NULL); + plyfile = ply_write(fp, nelems, elem_names, file_type); + if (plyfile == NULL) + return (NULL); - /* say what PLY file version number we're writing */ - *version = plyfile->version; + /* say what PLY file version number we're writing */ + *version = plyfile->version; - /* return pointer to the file descriptor */ - return (plyfile); + /* return pointer to the file descriptor */ + return (plyfile); } /****************************************************************************** -Describe an element, including its properties and how many will be written -to the file. - -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - nelems - number of elements of this type to be written - nprops - number of properties contained in the element - prop_list - list of properties + Describe an element, including its properties and how many will be written + to the file. + + Entry: + plyfile - file identifier + elem_name - name of element that information is being specified about + nelems - number of elements of this type to be written + nprops - number of properties contained in the element + prop_list - list of properties ******************************************************************************/ void ply_describe_element( - PlyFile *plyfile, - char *elem_name, - int nelems, - int nprops, - PlyProperty *prop_list -) + PlyFile *plyfile, + char *elem_name, + int nelems, + int nprops, + PlyProperty *prop_list + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr,"ply_describe_element: can't find element '%s'\n",elem_name); - exit (-1); - } - - elem->num = nelems; - - /* copy the list of properties */ - - elem->nprops = nprops; - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *) * nprops); - elem->store_prop = (char *) myalloc (sizeof (char) * nprops); - - for (i = 0; i < nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - elem->props[i] = prop; - elem->store_prop[i] = NAMED_PROP; - copy_property (prop, &prop_list[i]); - } + int i; + PlyElement *elem; + PlyProperty *prop; + + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_describe_element: can't find element '%s'\n", elem_name); + exit(-1); + } + + elem->num = nelems; + + /* copy the list of properties */ + + elem->nprops = nprops; + elem->props = (PlyProperty **) myalloc(sizeof(PlyProperty *) * nprops); + elem->store_prop = (char *) myalloc(sizeof(char) * nprops); + + for (i = 0; i < nprops; i++) { + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + elem->props[i] = prop; + elem->store_prop[i] = NAMED_PROP; + copy_property(prop, &prop_list[i]); + } } /****************************************************************************** -Describe a property of an element. + Describe a property of an element. -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - prop - the new property + Entry: + plyfile - file identifier + elem_name - name of element that information is being specified about + prop - the new property ******************************************************************************/ void ply_describe_property( - PlyFile *plyfile, - char *elem_name, - PlyProperty *prop -) + PlyFile *plyfile, + char *elem_name, + PlyProperty *prop + ) { - PlyElement *elem; - PlyProperty *elem_prop; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr, "ply_describe_property: can't find element '%s'\n", - elem_name); - return; - } - - /* create room for new property */ - - if (elem->nprops == 0) { - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *)); - elem->store_prop = (char *) myalloc (sizeof (char)); - elem->nprops = 1; - } - else { - elem->nprops++; - elem->props = (PlyProperty **) - realloc (elem->props, sizeof (PlyProperty *) * elem->nprops); - elem->store_prop = (char *) - realloc (elem->store_prop, sizeof (char) * elem->nprops); - } - - /* copy the new property */ - - elem_prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property (elem_prop, prop); + PlyElement *elem; + PlyProperty *elem_prop; + + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_describe_property: can't find element '%s'\n", + elem_name); + return; + } + + /* create room for new property */ + + if (elem->nprops == 0) { + elem->props = (PlyProperty **) myalloc(sizeof(PlyProperty *)); + elem->store_prop = (char *) myalloc(sizeof(char)); + elem->nprops = 1; + } + else { + elem->nprops++; + elem->props = (PlyProperty **) + realloc(elem->props, sizeof(PlyProperty *) * elem->nprops); + elem->store_prop = (char *) + realloc(elem->store_prop, sizeof(char) * elem->nprops); + } + + /* copy the new property */ + + elem_prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + elem->props[elem->nprops - 1] = elem_prop; + elem->store_prop[elem->nprops - 1] = NAMED_PROP; + copy_property(elem_prop, prop); } /****************************************************************************** -Describe what the "other" properties are that are to be stored, and where -they are in an element. + Describe what the "other" properties are that are to be stored, and where + they are in an element. ******************************************************************************/ void ply_describe_other_properties( - PlyFile *plyfile, - PlyOtherProp *other, - int offset -) + PlyFile *plyfile, + PlyOtherProp *other, + int offset + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element (plyfile, other->name); - if (elem == NULL) { - fprintf(stderr, "ply_describe_other_properties: can't find element '%s'\n", - other->name); - return; - } - - /* create room for other properties */ - - if (elem->nprops == 0) { - elem->props = (PlyProperty **) - myalloc (sizeof (PlyProperty *) * other->nprops); - elem->store_prop = (char *) myalloc (sizeof (char) * other->nprops); - elem->nprops = 0; - } - else { - int newsize; - newsize = elem->nprops + other->nprops; - elem->props = (PlyProperty **) - realloc (elem->props, sizeof (PlyProperty *) * newsize); - elem->store_prop = (char *) - realloc (elem->store_prop, sizeof (char) * newsize); - } - - /* copy the other properties */ - - for (i = 0; i < other->nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, other->props[i]); - elem->props[elem->nprops] = prop; - elem->store_prop[elem->nprops] = OTHER_PROP; - elem->nprops++; - } - - /* save other info about other properties */ - elem->other_size = other->size; - elem->other_offset = offset; + int i; + PlyElement *elem; + PlyProperty *prop; + + /* look for appropriate element */ + elem = find_element(plyfile, other->name); + if (elem == NULL) { + fprintf(stderr, "ply_describe_other_properties: can't find element '%s'\n", + other->name); + return; + } + + /* create room for other properties */ + + if (elem->nprops == 0) { + elem->props = (PlyProperty **) + myalloc(sizeof(PlyProperty *) * other->nprops); + elem->store_prop = (char *) myalloc(sizeof(char) * other->nprops); + elem->nprops = 0; + } + else { + int newsize; + newsize = elem->nprops + other->nprops; + elem->props = (PlyProperty **) + realloc(elem->props, sizeof(PlyProperty *) * newsize); + elem->store_prop = (char *) + realloc(elem->store_prop, sizeof(char) * newsize); + } + + /* copy the other properties */ + + for (i = 0; i < other->nprops; i++) { + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + copy_property(prop, other->props[i]); + elem->props[elem->nprops] = prop; + elem->store_prop[elem->nprops] = OTHER_PROP; + elem->nprops++; + } + + /* save other info about other properties */ + elem->other_size = other->size; + elem->other_offset = offset; } /****************************************************************************** -State how many of a given element will be written. + State how many of a given element will be written. -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - nelems - number of elements of this type to be written + Entry: + plyfile - file identifier + elem_name - name of element that information is being specified about + nelems - number of elements of this type to be written ******************************************************************************/ void ply_element_count( - PlyFile *plyfile, - char *elem_name, - int nelems -) + PlyFile *plyfile, + char *elem_name, + int nelems + ) { - PlyElement *elem; + PlyElement *elem; - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr,"ply_element_count: can't find element '%s'\n",elem_name); - exit (-1); - } + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_element_count: can't find element '%s'\n", elem_name); + exit(-1); + } - elem->num = nelems; + elem->num = nelems; } /****************************************************************************** -Signal that we've described everything a PLY file's header and that the -header should be written to the file. + Signal that we've described everything a PLY file's header and that the + header should be written to the file. -Entry: - plyfile - file identifier + Entry: + plyfile - file identifier ******************************************************************************/ void ply_header_complete(PlyFile *plyfile) { - int i,j; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - - fprintf (fp, "ply\n"); - - switch (plyfile->file_type) { - case PLY_ASCII: - fprintf (fp, "format ascii 1.0\n"); - break; - case PLY_BINARY_BE: - fprintf (fp, "format binary_big_endian 1.0\n"); - break; - case PLY_BINARY_LE: - fprintf (fp, "format binary_little_endian 1.0\n"); - break; - default: - fprintf (stderr, "ply_header_complete: bad file type = %d\n", - plyfile->file_type); - exit (-1); - } - - /* write out the comments */ - - for (i = 0; i < plyfile->num_comments; i++) - fprintf (fp, "comment %s\n", plyfile->comments[i]); - - /* write out object information */ - - for (i = 0; i < plyfile->num_obj_info; i++) - fprintf (fp, "obj_info %s\n", plyfile->obj_info[i]); - - /* write out information about each element */ - - for (i = 0; i < plyfile->nelems; i++) { - - elem = plyfile->elems[i]; - fprintf (fp, "element %s %d\n", elem->name, elem->num); - - /* write out each property */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (prop->is_list) { - fprintf (fp, "property list "); - write_scalar_type (fp, prop->count_external); - fprintf (fp, " "); - write_scalar_type (fp, prop->external_type); - fprintf (fp, " %s\n", prop->name); - } - else { - fprintf (fp, "property "); - write_scalar_type (fp, prop->external_type); - fprintf (fp, " %s\n", prop->name); - } - } - } - - fprintf (fp, "end_header\n"); + int i, j; + FILE *fp = plyfile->fp; + PlyElement *elem; + PlyProperty *prop; + + fprintf(fp, "ply\n"); + + switch (plyfile->file_type) { + case PLY_ASCII: + fprintf(fp, "format ascii 1.0\n"); + break; + case PLY_BINARY_BE: + fprintf(fp, "format binary_big_endian 1.0\n"); + break; + case PLY_BINARY_LE: + fprintf(fp, "format binary_little_endian 1.0\n"); + break; + default: + fprintf(stderr, "ply_header_complete: bad file type = %d\n", + plyfile->file_type); + exit(-1); + } + + /* write out the comments */ + + for (i = 0; i < plyfile->num_comments; i++) + fprintf(fp, "comment %s\n", plyfile->comments[i]); + + /* write out object information */ + + for (i = 0; i < plyfile->num_obj_info; i++) + fprintf(fp, "obj_info %s\n", plyfile->obj_info[i]); + + /* write out information about each element */ + + for (i = 0; i < plyfile->nelems; i++) { + + elem = plyfile->elems[i]; + fprintf(fp, "element %s %d\n", elem->name, elem->num); + + /* write out each property */ + for (j = 0; j < elem->nprops; j++) { + prop = elem->props[j]; + if (prop->is_list) { + fprintf(fp, "property list "); + write_scalar_type(fp, prop->count_external); + fprintf(fp, " "); + write_scalar_type(fp, prop->external_type); + fprintf(fp, " %s\n", prop->name); + } + else { + fprintf(fp, "property "); + write_scalar_type(fp, prop->external_type); + fprintf(fp, " %s\n", prop->name); + } + } + } + + fprintf(fp, "end_header\n"); } /****************************************************************************** -Specify which elements are going to be written. This should be called -before a call to the routine ply_put_element(). + Specify which elements are going to be written. This should be called + before a call to the routine ply_put_element(). -Entry: - plyfile - file identifier - elem_name - name of element we're talking about + Entry: + plyfile - file identifier + elem_name - name of element we're talking about ******************************************************************************/ void ply_put_element_setup(PlyFile *plyfile, char *elem_name) { - PlyElement *elem; + PlyElement *elem; - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr, "ply_elements_setup: can't find element '%s'\n", elem_name); - exit (-1); - } + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_elements_setup: can't find element '%s'\n", elem_name); + exit(-1); + } - plyfile->which_elem = elem; + plyfile->which_elem = elem; } /****************************************************************************** -Write an element to the file. This routine assumes that we're -writing the type of element specified in the last call to the routine -ply_put_element_setup(). + Write an element to the file. This routine assumes that we're + writing the type of element specified in the last call to the routine + ply_put_element_setup(). -Entry: - plyfile - file identifier - elem_ptr - pointer to the element + Entry: + plyfile - file identifier + elem_ptr - pointer to the element ******************************************************************************/ void ply_put_element(PlyFile *plyfile, void *elem_ptr) { - int j,k; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - char *elem_data,*item; - char **item_ptr; - int list_count; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - char **other_ptr; - - elem = plyfile->which_elem; - elem_data = elem_ptr; - other_ptr = (char **) (((char *) elem_ptr) + elem->other_offset); - - /* write out either to an ascii or binary file */ - - if (plyfile->file_type == PLY_ASCII) { - - /* write an ascii file */ - - /* write out each property of the element */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (elem->store_prop[j] == OTHER_PROP) - elem_data = *other_ptr; - else - elem_data = elem_ptr; - if (prop->is_list) { - item = elem_data + prop->count_offset; - get_stored_item ((void *) item, prop->count_internal, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->count_external); - list_count = uint_val; - item_ptr = (char **) (elem_data + prop->offset); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for (k = 0; k < list_count; k++) { - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->external_type); - item += item_size; - } - } - else { - item = elem_data + prop->offset; - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->external_type); - } - } - - fprintf (fp, "\n"); - } - else { - - /* write a binary file */ - - /* write out each property of the element */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (elem->store_prop[j] == OTHER_PROP) - elem_data = *other_ptr; - else - elem_data = elem_ptr; - if (prop->is_list) { - item = elem_data + prop->count_offset; - item_size = ply_type_size[prop->count_internal]; - get_stored_item ((void *) item, prop->count_internal, - &int_val, &uint_val, &double_val); - write_binary_item (fp, int_val, uint_val, double_val, - prop->count_external); - list_count = uint_val; - item_ptr = (char **) (elem_data + prop->offset); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for (k = 0; k < list_count; k++) { - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_binary_item (fp, int_val, uint_val, double_val, - prop->external_type); - item += item_size; - } - } - else { - item = elem_data + prop->offset; - item_size = ply_type_size[prop->internal_type]; - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_binary_item (fp, int_val, uint_val, double_val, - prop->external_type); - } - } - - } + int j, k; + FILE *fp = plyfile->fp; + PlyElement *elem; + PlyProperty *prop; + char *elem_data, *item; + char **item_ptr; + int list_count; + int item_size; + int int_val; + unsigned int uint_val; + double double_val; + char **other_ptr; + + elem = plyfile->which_elem; + elem_data = elem_ptr; + other_ptr = (char **) (((char *) elem_ptr) + elem->other_offset); + + /* write out either to an ascii or binary file */ + + if (plyfile->file_type == PLY_ASCII) { + + /* write an ascii file */ + + /* write out each property of the element */ + for (j = 0; j < elem->nprops; j++) { + prop = elem->props[j]; + if (elem->store_prop[j] == OTHER_PROP) + elem_data = *other_ptr; + else + elem_data = elem_ptr; + if (prop->is_list) { + item = elem_data + prop->count_offset; + get_stored_item((void *) item, prop->count_internal, + &int_val, &uint_val, &double_val); + write_ascii_item(fp, int_val, uint_val, double_val, + prop->count_external); + list_count = uint_val; + item_ptr = (char **) (elem_data + prop->offset); + item = item_ptr[0]; + item_size = ply_type_size[prop->internal_type]; + for (k = 0; k < list_count; k++) { + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_ascii_item(fp, int_val, uint_val, double_val, + prop->external_type); + item += item_size; + } + } + else { + item = elem_data + prop->offset; + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_ascii_item(fp, int_val, uint_val, double_val, + prop->external_type); + } + } + + fprintf(fp, "\n"); + } + else { + + /* write a binary file */ + + /* write out each property of the element */ + for (j = 0; j < elem->nprops; j++) { + prop = elem->props[j]; + if (elem->store_prop[j] == OTHER_PROP) + elem_data = *other_ptr; + else + elem_data = elem_ptr; + if (prop->is_list) { + item = elem_data + prop->count_offset; + item_size = ply_type_size[prop->count_internal]; + get_stored_item((void *) item, prop->count_internal, + &int_val, &uint_val, &double_val); + write_binary_item(fp, int_val, uint_val, double_val, + prop->count_external); + list_count = uint_val; + item_ptr = (char **) (elem_data + prop->offset); + item = item_ptr[0]; + item_size = ply_type_size[prop->internal_type]; + for (k = 0; k < list_count; k++) { + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_binary_item(fp, int_val, uint_val, double_val, + prop->external_type); + item += item_size; + } + } + else { + item = elem_data + prop->offset; + item_size = ply_type_size[prop->internal_type]; + get_stored_item((void *) item, prop->internal_type, + &int_val, &uint_val, &double_val); + write_binary_item(fp, int_val, uint_val, double_val, + prop->external_type); + } + } + + } } /****************************************************************************** -Specify a comment that will be written in the header. + Specify a comment that will be written in the header. -Entry: - plyfile - file identifier - comment - the comment to be written + Entry: + plyfile - file identifier + comment - the comment to be written ******************************************************************************/ void ply_put_comment(PlyFile *plyfile, char *comment) { - /* (re)allocate space for new comment */ - if (plyfile->num_comments == 0) - plyfile->comments = (char **) myalloc (sizeof (char *)); - else - plyfile->comments = (char **) realloc (plyfile->comments, - sizeof (char *) * (plyfile->num_comments + 1)); - - /* add comment to list */ - plyfile->comments[plyfile->num_comments] = strdup (comment); - plyfile->num_comments++; + /* (re)allocate space for new comment */ + if (plyfile->num_comments == 0) + plyfile->comments = (char **) myalloc(sizeof(char *)); + else + plyfile->comments = (char **) realloc(plyfile->comments, + sizeof(char *) * (plyfile->num_comments + 1)); + + /* add comment to list */ + plyfile->comments[plyfile->num_comments] = strdup(comment); + plyfile->num_comments++; } /****************************************************************************** -Specify a piece of object information (arbitrary text) that will be written -in the header. + Specify a piece of object information (arbitrary text) that will be written + in the header. -Entry: - plyfile - file identifier - obj_info - the text information to be written + Entry: + plyfile - file identifier + obj_info - the text information to be written ******************************************************************************/ void ply_put_obj_info(PlyFile *plyfile, char *obj_info) { - /* (re)allocate space for new info */ - if (plyfile->num_obj_info == 0) - plyfile->obj_info = (char **) myalloc (sizeof (char *)); - else - plyfile->obj_info = (char **) realloc (plyfile->obj_info, - sizeof (char *) * (plyfile->num_obj_info + 1)); - - /* add info to list */ - plyfile->obj_info[plyfile->num_obj_info] = strdup (obj_info); - plyfile->num_obj_info++; + /* (re)allocate space for new info */ + if (plyfile->num_obj_info == 0) + plyfile->obj_info = (char **) myalloc(sizeof(char *)); + else + plyfile->obj_info = (char **) realloc(plyfile->obj_info, + sizeof(char *) * (plyfile->num_obj_info + 1)); + + /* add info to list */ + plyfile->obj_info[plyfile->num_obj_info] = strdup(obj_info); + plyfile->num_obj_info++; } @@ -703,507 +703,507 @@ void ply_put_obj_info(PlyFile *plyfile, char *obj_info) /****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. + Given a file pointer, get ready to read PLY data from the file. -Entry: - fp - the given file pointer + Entry: + fp - the given file pointer -Exit: - nelems - number of elements in object - elem_names - list of element names - returns a pointer to a PlyFile, used to refer to this file, or NULL if error + Exit: + nelems - number of elements in object + elem_names - list of element names + returns a pointer to a PlyFile, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_read(FILE *fp, int *nelems, char ***elem_names) { - int i,j; - PlyFile *plyfile; - int nwords; - char **words; - int found_format = 0; - char **elist; - PlyElement *elem; - char *orig_line; - - /* check for NULL file pointer */ - if (fp == NULL) - return (NULL); - - /* create record for this object */ - - plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); - plyfile->nelems = 0; - plyfile->comments = NULL; - plyfile->num_comments = 0; - plyfile->obj_info = NULL; - plyfile->num_obj_info = 0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* read and parse the file's header */ - - words = get_words (plyfile->fp, &nwords, &orig_line); - if (!words || !equal_strings (words[0], "ply")) - return (NULL); - - while (words) { - - /* parse words */ - - if (equal_strings (words[0], "format")) { - if (nwords != 3) - return (NULL); - if (equal_strings (words[1], "ascii")) - plyfile->file_type = PLY_ASCII; - else if (equal_strings (words[1], "binary_big_endian")) - plyfile->file_type = PLY_BINARY_BE; - else if (equal_strings (words[1], "binary_little_endian")) - plyfile->file_type = PLY_BINARY_LE; - else - return (NULL); - plyfile->version = (float)atof (words[2]); - found_format = 1; - } - else if (equal_strings (words[0], "element")) - add_element (plyfile, words); - else if (equal_strings (words[0], "property")) - add_property (plyfile, words); - else if (equal_strings (words[0], "comment")) - add_comment (plyfile, orig_line); - else if (equal_strings (words[0], "obj_info")) - add_obj_info (plyfile, orig_line); - else if (equal_strings (words[0], "end_header")) - break; - - /* free up words space */ - free (words); - - words = get_words (plyfile->fp, &nwords, &orig_line); - } - - /* create tags for each property of each element, to be used */ - /* later to say whether or not to store each property for the user */ - - for (i = 0; i < plyfile->nelems; i++) { - elem = plyfile->elems[i]; - elem->store_prop = (char *) myalloc (sizeof (char) * elem->nprops); - for (j = 0; j < elem->nprops; j++) - elem->store_prop[j] = DONT_STORE_PROP; - elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ - } - - /* set return values about the elements */ - - elist = (char **) myalloc (sizeof (char *) * plyfile->nelems); - for (i = 0; i < plyfile->nelems; i++) - elist[i] = strdup (plyfile->elems[i]->name); - - *elem_names = elist; - *nelems = plyfile->nelems; - - /* return a pointer to the file's information */ - - return (plyfile); + int i, j; + PlyFile *plyfile; + int nwords; + char **words; + int found_format = 0; + char **elist; + PlyElement *elem; + char *orig_line; + + /* check for NULL file pointer */ + if (fp == NULL) + return (NULL); + + /* create record for this object */ + + plyfile = (PlyFile *) myalloc(sizeof(PlyFile)); + plyfile->nelems = 0; + plyfile->comments = NULL; + plyfile->num_comments = 0; + plyfile->obj_info = NULL; + plyfile->num_obj_info = 0; + plyfile->fp = fp; + plyfile->other_elems = NULL; + + /* read and parse the file's header */ + + words = get_words(plyfile->fp, &nwords, &orig_line); + if (!words || !equal_strings(words[0], "ply")) + return (NULL); + + while (words) { + + /* parse words */ + + if (equal_strings(words[0], "format")) { + if (nwords != 3) + return (NULL); + if (equal_strings(words[1], "ascii")) + plyfile->file_type = PLY_ASCII; + else if (equal_strings(words[1], "binary_big_endian")) + plyfile->file_type = PLY_BINARY_BE; + else if (equal_strings(words[1], "binary_little_endian")) + plyfile->file_type = PLY_BINARY_LE; + else + return (NULL); + plyfile->version = (float)atof(words[2]); + found_format = 1; + } + else if (equal_strings(words[0], "element")) + add_element(plyfile, words); + else if (equal_strings(words[0], "property")) + add_property(plyfile, words); + else if (equal_strings(words[0], "comment")) + add_comment(plyfile, orig_line); + else if (equal_strings(words[0], "obj_info")) + add_obj_info(plyfile, orig_line); + else if (equal_strings(words[0], "end_header")) + break; + + /* free up words space */ + free(words); + + words = get_words(plyfile->fp, &nwords, &orig_line); + } + + /* create tags for each property of each element, to be used */ + /* later to say whether or not to store each property for the user */ + + for (i = 0; i < plyfile->nelems; i++) { + elem = plyfile->elems[i]; + elem->store_prop = (char *) myalloc(sizeof(char) * elem->nprops); + for (j = 0; j < elem->nprops; j++) + elem->store_prop[j] = DONT_STORE_PROP; + elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ + } + + /* set return values about the elements */ + + elist = (char **) myalloc(sizeof(char *) * plyfile->nelems); + for (i = 0; i < plyfile->nelems; i++) + elist[i] = strdup(plyfile->elems[i]->name); + + *elem_names = elist; + *nelems = plyfile->nelems; + + /* return a pointer to the file's information */ + + return (plyfile); } /****************************************************************************** -Open a polygon file for reading. + Open a polygon file for reading. -Entry: - filename - name of file to read from + Entry: + filename - name of file to read from -Exit: - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary - version - version number of PLY file - returns a file identifier, used to refer to this file, or NULL if error + Exit: + nelems - number of elements in object + elem_names - list of element names + file_type - file type, either ascii or binary + version - version number of PLY file + returns a file identifier, used to refer to this file, or NULL if error ******************************************************************************/ PlyFile *ply_open_for_reading( - char *filename, - int *nelems, - char ***elem_names, - int *file_type, - float *version -) + char *filename, + int *nelems, + char ***elem_names, + int *file_type, + float *version + ) { - FILE *fp; - PlyFile *plyfile; - char *name; + FILE *fp; + PlyFile *plyfile; + char *name; - /* tack on the extension .ply, if necessary */ + /* tack on the extension .ply, if necessary */ - name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5)); - strcpy (name, filename); - if (strlen (name) < 4 || - strcmp (name + strlen (name) - 4, ".ply") != 0) - strcat (name, ".ply"); + name = (char *) myalloc(sizeof(char) * (strlen(filename) + 5)); + strcpy(name, filename); + if (strlen(name) < 4 || + strcmp(name + strlen(name) - 4, ".ply") != 0) + strcat(name, ".ply"); - /* open the file for reading */ + /* open the file for reading */ - fp = fopen (name, "r"); - if (fp == NULL) - return (NULL); + fp = fopen(name, "r"); + if (fp == NULL) + return (NULL); - /* create the PlyFile data structure */ + /* create the PlyFile data structure */ - plyfile = ply_read (fp, nelems, elem_names); + plyfile = ply_read(fp, nelems, elem_names); - /* determine the file type and version */ + /* determine the file type and version */ - *file_type = plyfile->file_type; - *version = plyfile->version; + *file_type = plyfile->file_type; + *version = plyfile->version; - /* return a pointer to the file's information */ + /* return a pointer to the file's information */ - return (plyfile); + return (plyfile); } /****************************************************************************** -Get information about a particular element. + Get information about a particular element. -Entry: - plyfile - file identifier - elem_name - name of element to get information about + Entry: + plyfile - file identifier + elem_name - name of element to get information about -Exit: - nelems - number of elements of this type in the file - nprops - number of properties - returns a list of properties, or NULL if the file doesn't contain that elem + Exit: + nelems - number of elements of this type in the file + nprops - number of properties + returns a list of properties, or NULL if the file doesn't contain that elem ******************************************************************************/ PlyProperty **ply_get_element_description( - PlyFile *plyfile, - char *elem_name, - int *nelems, - int *nprops -) + PlyFile *plyfile, + char *elem_name, + int *nelems, + int *nprops + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - PlyProperty **prop_list; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) - return (NULL); - - *nelems = elem->num; - *nprops = elem->nprops; - - /* make a copy of the element's property list */ - prop_list = (PlyProperty **) myalloc (sizeof (PlyProperty *) * elem->nprops); - for (i = 0; i < elem->nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, elem->props[i]); - prop_list[i] = prop; - } - - /* return this duplicate property list */ - return (prop_list); + int i; + PlyElement *elem; + PlyProperty *prop; + PlyProperty **prop_list; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) + return (NULL); + + *nelems = elem->num; + *nprops = elem->nprops; + + /* make a copy of the element's property list */ + prop_list = (PlyProperty **) myalloc(sizeof(PlyProperty *) * elem->nprops); + for (i = 0; i < elem->nprops; i++) { + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + copy_property(prop, elem->props[i]); + prop_list[i] = prop; + } + + /* return this duplicate property list */ + return (prop_list); } /****************************************************************************** -Specify which properties of an element are to be returned. This should be -called before a call to the routine ply_get_element(). - -Entry: - plyfile - file identifier - elem_name - which element we're talking about - nprops - number of properties - prop_list - list of properties + Specify which properties of an element are to be returned. This should be + called before a call to the routine ply_get_element(). + + Entry: + plyfile - file identifier + elem_name - which element we're talking about + nprops - number of properties + prop_list - list of properties ******************************************************************************/ void ply_get_element_setup( - PlyFile *plyfile, - char *elem_name, - int nprops, - PlyProperty *prop_list -) + PlyFile *plyfile, + char *elem_name, + int nprops, + PlyProperty *prop_list + ) { - int i; - PlyElement *elem; - PlyProperty *prop; - int index; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - for (i = 0; i < nprops; i++) { - - /* look for actual property */ - prop = find_property (elem, prop_list[i].name, &index); - if (prop == NULL) { - fprintf (stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop_list[i].name, elem_name); - continue; - } - - /* store its description */ - prop->internal_type = prop_list[i].internal_type; - prop->offset = prop_list[i].offset; - prop->count_internal = prop_list[i].count_internal; - prop->count_offset = prop_list[i].count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - } + int i; + PlyElement *elem; + PlyProperty *prop; + int index; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + plyfile->which_elem = elem; + + /* deposit the property information into the element's description */ + for (i = 0; i < nprops; i++) { + + /* look for actual property */ + prop = find_property(elem, prop_list[i].name, &index); + if (prop == NULL) { + fprintf(stderr, "Warning: Can't find property '%s' in element '%s'\n", + prop_list[i].name, elem_name); + continue; + } + + /* store its description */ + prop->internal_type = prop_list[i].internal_type; + prop->offset = prop_list[i].offset; + prop->count_internal = prop_list[i].count_internal; + prop->count_offset = prop_list[i].count_offset; + + /* specify that the user wants this property */ + elem->store_prop[index] = STORE_PROP; + } } /****************************************************************************** -Specify a property of an element that is to be returned. This should be -called (usually multiple times) before a call to the routine ply_get_element(). -This routine should be used in preference to the less flexible old routine -called ply_get_element_setup(). - -Entry: - plyfile - file identifier - elem_name - which element we're talking about - prop - property to add to those that will be returned + Specify a property of an element that is to be returned. This should be + called (usually multiple times) before a call to the routine ply_get_element(). + This routine should be used in preference to the less flexible old routine + called ply_get_element_setup(). + + Entry: + plyfile - file identifier + elem_name - which element we're talking about + prop - property to add to those that will be returned ******************************************************************************/ void ply_get_property( - PlyFile *plyfile, - char *elem_name, - PlyProperty *prop -) + PlyFile *plyfile, + char *elem_name, + PlyProperty *prop + ) { - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property (elem, prop->name, &index); - if (prop_ptr == NULL) { - fprintf (stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem_name); - return; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; + PlyElement *elem; + PlyProperty *prop_ptr; + int index; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + plyfile->which_elem = elem; + + /* deposit the property information into the element's description */ + + prop_ptr = find_property(elem, prop->name, &index); + if (prop_ptr == NULL) { + fprintf(stderr, "Warning: Can't find property '%s' in element '%s'\n", + prop->name, elem_name); + return; + } + prop_ptr->internal_type = prop->internal_type; + prop_ptr->offset = prop->offset; + prop_ptr->count_internal = prop->count_internal; + prop_ptr->count_offset = prop->count_offset; + + /* specify that the user wants this property */ + elem->store_prop[index] = STORE_PROP; } /****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -ply_get_element_setup(). + Read one element from the file. This routine assumes that we're reading + the type of element specified in the last call to the routine + ply_get_element_setup(). -Entry: - plyfile - file identifier - elem_ptr - pointer to location where the element information should be put + Entry: + plyfile - file identifier + elem_ptr - pointer to location where the element information should be put ******************************************************************************/ void ply_get_element(PlyFile *plyfile, void *elem_ptr) { - if (plyfile->file_type == PLY_ASCII) - ascii_get_element (plyfile, (char *) elem_ptr); - else - binary_get_element (plyfile, (char *) elem_ptr); + if (plyfile->file_type == PLY_ASCII) + ascii_get_element(plyfile, (char *) elem_ptr); + else + binary_get_element(plyfile, (char *) elem_ptr); } /****************************************************************************** -Extract the comments from the header information of a PLY file. + Extract the comments from the header information of a PLY file. -Entry: - plyfile - file identifier + Entry: + plyfile - file identifier -Exit: - num_comments - number of comments returned - returns a pointer to a list of comments + Exit: + num_comments - number of comments returned + returns a pointer to a list of comments ******************************************************************************/ char **ply_get_comments(PlyFile *plyfile, int *num_comments) { - *num_comments = plyfile->num_comments; - return (plyfile->comments); + *num_comments = plyfile->num_comments; + return (plyfile->comments); } /****************************************************************************** -Extract the object information (arbitrary text) from the header information -of a PLY file. + Extract the object information (arbitrary text) from the header information + of a PLY file. -Entry: - plyfile - file identifier + Entry: + plyfile - file identifier -Exit: - num_obj_info - number of lines of text information returned - returns a pointer to a list of object info lines + Exit: + num_obj_info - number of lines of text information returned + returns a pointer to a list of object info lines ******************************************************************************/ char **ply_get_obj_info(PlyFile *plyfile, int *num_obj_info) { - *num_obj_info = plyfile->num_obj_info; - return (plyfile->obj_info); + *num_obj_info = plyfile->num_obj_info; + return (plyfile->obj_info); } /****************************************************************************** -Make ready for "other" properties of an element-- those properties that -the user has not explicitly asked for, but that are to be stashed away -in a special structure to be carried along with the element's other -information. - -Entry: - plyfile - file identifier - elem - element for which we want to save away other properties + Make ready for "other" properties of an element-- those properties that + the user has not explicitly asked for, but that are to be stashed away + in a special structure to be carried along with the element's other + information. + + Entry: + plyfile - file identifier + elem - element for which we want to save away other properties ******************************************************************************/ void setup_other_props(PlyElement *elem) { - int i; - PlyProperty *prop; - int size = 0; - int type_size; - - /* Examine each property in decreasing order of size. */ - /* We do this so that all data types will be aligned by */ - /* word, half-word, or whatever within the structure. */ - - for (type_size = 8; type_size > 0; type_size /= 2) { - - /* add up the space taken by each property, and save this information */ - /* away in the property descriptor */ - - for (i = 0; i < elem->nprops; i++) { - - /* don't bother with properties we've been asked to store explicitly */ - if (elem->store_prop[i]) - continue; - - prop = elem->props[i]; - - /* internal types will be same as external */ - prop->internal_type = prop->external_type; - prop->count_internal = prop->count_external; - - /* check list case */ - if (prop->is_list) { - - /* pointer to list */ - if (type_size == sizeof (void *)) { - prop->offset = size; - size += sizeof (void *); /* always use size of a pointer here */ - } - - /* count of number of list elements */ - if (type_size == ply_type_size[prop->count_external]) { - prop->count_offset = size; - size += ply_type_size[prop->count_external]; - } - } - /* not list */ - else if (type_size == ply_type_size[prop->external_type]) { - prop->offset = size; - size += ply_type_size[prop->external_type]; - } - } - - } - - /* save the size for the other_props structure */ - elem->other_size = size; + int i; + PlyProperty *prop; + int size = 0; + int type_size; + + /* Examine each property in decreasing order of size. */ + /* We do this so that all data types will be aligned by */ + /* word, half-word, or whatever within the structure. */ + + for (type_size = 8; type_size > 0; type_size /= 2) { + + /* add up the space taken by each property, and save this information */ + /* away in the property descriptor */ + + for (i = 0; i < elem->nprops; i++) { + + /* don't bother with properties we've been asked to store explicitly */ + if (elem->store_prop[i]) + continue; + + prop = elem->props[i]; + + /* internal types will be same as external */ + prop->internal_type = prop->external_type; + prop->count_internal = prop->count_external; + + /* check list case */ + if (prop->is_list) { + + /* pointer to list */ + if (type_size == sizeof(void *)) { + prop->offset = size; + size += sizeof(void *); /* always use size of a pointer here */ + } + + /* count of number of list elements */ + if (type_size == ply_type_size[prop->count_external]) { + prop->count_offset = size; + size += ply_type_size[prop->count_external]; + } + } + /* not list */ + else if (type_size == ply_type_size[prop->external_type]) { + prop->offset = size; + size += ply_type_size[prop->external_type]; + } + } + + } + + /* save the size for the other_props structure */ + elem->other_size = size; } /****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. The user needn't be concerned for how -these properties are stored. + Specify that we want the "other" properties of an element to be tucked + away within the user's structure. The user needn't be concerned for how + these properties are stored. -Entry: - plyfile - file identifier - elem_name - name of element that we want to store other_props in - offset - offset to where other_props will be stored inside user's structure + Entry: + plyfile - file identifier + elem_name - name of element that we want to store other_props in + offset - offset to where other_props will be stored inside user's structure -Exit: - returns pointer to structure containing description of other_props + Exit: + returns pointer to structure containing description of other_props ******************************************************************************/ PlyOtherProp *ply_get_other_properties( - PlyFile *plyfile, - char *elem_name, - int offset -) + PlyFile *plyfile, + char *elem_name, + int offset + ) { - int i; - PlyElement *elem; - PlyOtherProp *other; - PlyProperty *prop; - int nprops; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf (stderr, "ply_get_other_properties: Can't find element '%s'\n", - elem_name); - return (NULL); - } - - /* remember that this is the "current" element */ - plyfile->which_elem = elem; - - /* save the offset to where to store the other_props */ - elem->other_offset = offset; - - /* place the appropriate pointers, etc. in the element's property list */ - setup_other_props (elem); - - /* create structure for describing other_props */ - other = (PlyOtherProp *) myalloc (sizeof (PlyOtherProp)); - other->name = strdup (elem_name); + int i; + PlyElement *elem; + PlyOtherProp *other; + PlyProperty *prop; + int nprops; + + /* find information about the element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, "ply_get_other_properties: Can't find element '%s'\n", + elem_name); + return (NULL); + } + + /* remember that this is the "current" element */ + plyfile->which_elem = elem; + + /* save the offset to where to store the other_props */ + elem->other_offset = offset; + + /* place the appropriate pointers, etc. in the element's property list */ + setup_other_props(elem); + + /* create structure for describing other_props */ + other = (PlyOtherProp *) myalloc(sizeof(PlyOtherProp)); + other->name = strdup(elem_name); #if 0 - if (elem->other_offset == NO_OTHER_PROPS) { - other->size = 0; - other->props = NULL; - other->nprops = 0; - return (other); - } + if (elem->other_offset == NO_OTHER_PROPS) { + other->size = 0; + other->props = NULL; + other->nprops = 0; + return (other); + } #endif - other->size = elem->other_size; - other->props = (PlyProperty **) myalloc (sizeof(PlyProperty) * elem->nprops); + other->size = elem->other_size; + other->props = (PlyProperty **) myalloc(sizeof(PlyProperty) * elem->nprops); - /* save descriptions of each "other" property */ - nprops = 0; - for (i = 0; i < elem->nprops; i++) { - if (elem->store_prop[i]) - continue; - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, elem->props[i]); - other->props[nprops] = prop; - nprops++; - } - other->nprops = nprops; + /* save descriptions of each "other" property */ + nprops = 0; + for (i = 0; i < elem->nprops; i++) { + if (elem->store_prop[i]) + continue; + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); + copy_property(prop, elem->props[i]); + other->props[nprops] = prop; + nprops++; + } + other->nprops = nprops; #if 1 - /* set other_offset pointer appropriately if there are NO other properties */ - if (other->nprops == 0) { - elem->other_offset = NO_OTHER_PROPS; - } + /* set other_offset pointer appropriately if there are NO other properties */ + if (other->nprops == 0) { + elem->other_offset = NO_OTHER_PROPS; + } #endif - /* return structure */ - return (other); + /* return structure */ + return (other); } @@ -1217,151 +1217,151 @@ PlyOtherProp *ply_get_other_properties( /****************************************************************************** -Grab all the data for an element that a user does not want to explicitly -read in. + Grab all the data for an element that a user does not want to explicitly + read in. -Entry: - plyfile - pointer to file - elem_name - name of element whose data is to be read in - elem_count - number of instances of this element stored in the file + Entry: + plyfile - pointer to file + elem_name - name of element whose data is to be read in + elem_count - number of instances of this element stored in the file -Exit: - returns pointer to ALL the "other" element data for this PLY file + Exit: + returns pointer to ALL the "other" element data for this PLY file ******************************************************************************/ -PlyOtherElems *ply_get_other_element ( - PlyFile *plyfile, - char *elem_name, - int elem_count -) +PlyOtherElems *ply_get_other_element( + PlyFile *plyfile, + char *elem_name, + int elem_count + ) { - int i; - PlyElement *elem; - PlyOtherElems *other_elems; - OtherElem *other; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf (stderr, - "ply_get_other_element: can't find element '%s'\n", elem_name); - exit (-1); - } - - /* create room for the new "other" element, initializing the */ - /* other data structure if necessary */ - - if (plyfile->other_elems == NULL) { - plyfile->other_elems = (PlyOtherElems *) myalloc (sizeof (PlyOtherElems)); - other_elems = plyfile->other_elems; - other_elems->other_list = (OtherElem *) myalloc (sizeof (OtherElem)); - other = &(other_elems->other_list[0]); - other_elems->num_elems = 1; - } - else { - other_elems = plyfile->other_elems; - other_elems->other_list = (OtherElem *) realloc (other_elems->other_list, - sizeof (OtherElem) * other_elems->num_elems + 1); - other = &(other_elems->other_list[other_elems->num_elems]); - other_elems->num_elems++; - } - - /* count of element instances in file */ - other->elem_count = elem_count; - - /* save name of element */ - other->elem_name = strdup (elem_name); - - /* create a list to hold all the current elements */ - other->other_data = (OtherData **) - malloc (sizeof (OtherData *) * other->elem_count); - - /* set up for getting elements */ - other->other_props = ply_get_other_properties (plyfile, elem_name, - offsetof(OtherData,other_props)); - - /* grab all these elements */ - for (i = 0; i < other->elem_count; i++) { - /* grab and element from the file */ - other->other_data[i] = (OtherData *) malloc (sizeof (OtherData)); - ply_get_element (plyfile, (void *) other->other_data[i]); - } - - /* return pointer to the other elements data */ - return (other_elems); + int i; + PlyElement *elem; + PlyOtherElems *other_elems; + OtherElem *other; + + /* look for appropriate element */ + elem = find_element(plyfile, elem_name); + if (elem == NULL) { + fprintf(stderr, + "ply_get_other_element: can't find element '%s'\n", elem_name); + exit(-1); + } + + /* create room for the new "other" element, initializing the */ + /* other data structure if necessary */ + + if (plyfile->other_elems == NULL) { + plyfile->other_elems = (PlyOtherElems *) myalloc(sizeof(PlyOtherElems)); + other_elems = plyfile->other_elems; + other_elems->other_list = (OtherElem *) myalloc(sizeof(OtherElem)); + other = &(other_elems->other_list[0]); + other_elems->num_elems = 1; + } + else { + other_elems = plyfile->other_elems; + other_elems->other_list = (OtherElem *) realloc(other_elems->other_list, + sizeof(OtherElem) * other_elems->num_elems + 1); + other = &(other_elems->other_list[other_elems->num_elems]); + other_elems->num_elems++; + } + + /* count of element instances in file */ + other->elem_count = elem_count; + + /* save name of element */ + other->elem_name = strdup(elem_name); + + /* create a list to hold all the current elements */ + other->other_data = (OtherData **) + malloc(sizeof(OtherData *) * other->elem_count); + + /* set up for getting elements */ + other->other_props = ply_get_other_properties(plyfile, elem_name, + offsetof(OtherData, other_props)); + + /* grab all these elements */ + for (i = 0; i < other->elem_count; i++) { + /* grab and element from the file */ + other->other_data[i] = (OtherData *) malloc(sizeof(OtherData)); + ply_get_element(plyfile, (void *) other->other_data[i]); + } + + /* return pointer to the other elements data */ + return (other_elems); } /****************************************************************************** -Pass along a pointer to "other" elements that we want to save in a given -PLY file. These other elements were presumably read from another PLY file. + Pass along a pointer to "other" elements that we want to save in a given + PLY file. These other elements were presumably read from another PLY file. -Entry: - plyfile - file pointer in which to store this other element info - other_elems - info about other elements that we want to store + Entry: + plyfile - file pointer in which to store this other element info + other_elems - info about other elements that we want to store ******************************************************************************/ -void ply_describe_other_elements ( - PlyFile *plyfile, - PlyOtherElems *other_elems -) +void ply_describe_other_elements( + PlyFile *plyfile, + PlyOtherElems *other_elems + ) { - int i; - OtherElem *other; + int i; + OtherElem *other; - /* ignore this call if there is no other element */ - if (other_elems == NULL) - return; + /* ignore this call if there is no other element */ + if (other_elems == NULL) + return; - /* save pointer to this information */ - plyfile->other_elems = other_elems; + /* save pointer to this information */ + plyfile->other_elems = other_elems; - /* describe the other properties of this element */ + /* describe the other properties of this element */ - for (i = 0; i < other_elems->num_elems; i++) { - other = &(other_elems->other_list[i]); - ply_element_count (plyfile, other->elem_name, other->elem_count); - ply_describe_other_properties (plyfile, other->other_props, - offsetof(OtherData,other_props)); - } + for (i = 0; i < other_elems->num_elems; i++) { + other = &(other_elems->other_list[i]); + ply_element_count(plyfile, other->elem_name, other->elem_count); + ply_describe_other_properties(plyfile, other->other_props, + offsetof(OtherData, other_props)); + } } /****************************************************************************** -Write out the "other" elements specified for this PLY file. + Write out the "other" elements specified for this PLY file. -Entry: - plyfile - pointer to PLY file to write out other elements for + Entry: + plyfile - pointer to PLY file to write out other elements for ******************************************************************************/ -void ply_put_other_elements (PlyFile *plyfile) +void ply_put_other_elements(PlyFile *plyfile) { - int i,j; - OtherElem *other; + int i, j; + OtherElem *other; - /* make sure we have other elements to write */ - if (plyfile->other_elems == NULL) - return; + /* make sure we have other elements to write */ + if (plyfile->other_elems == NULL) + return; - /* write out the data for each "other" element */ + /* write out the data for each "other" element */ - for (i = 0; i < plyfile->other_elems->num_elems; i++) { + for (i = 0; i < plyfile->other_elems->num_elems; i++) { - other = &(plyfile->other_elems->other_list[i]); - ply_put_element_setup (plyfile, other->elem_name); + other = &(plyfile->other_elems->other_list[i]); + ply_put_element_setup(plyfile, other->elem_name); - /* write out each instance of the current element */ - for (j = 0; j < other->elem_count; j++) - ply_put_element (plyfile, (void *) other->other_data[j]); - } + /* write out each instance of the current element */ + for (j = 0; j < other->elem_count; j++) + ply_put_element(plyfile, (void *) other->other_data[j]); + } } /****************************************************************************** -Free up storage used by an "other" elements data structure. + Free up storage used by an "other" elements data structure. -Entry: - other_elems - data structure to free up + Entry: + other_elems - data structure to free up ******************************************************************************/ @@ -1374,1171 +1374,1172 @@ Entry: /****************************************************************************** -Close a PLY file. + Close a PLY file. -Entry: - plyfile - identifier of file to close + Entry: + plyfile - identifier of file to close ******************************************************************************/ void ply_close(PlyFile *plyfile) { - fclose (plyfile->fp); + fclose(plyfile->fp); - /* free up memory associated with the PLY file */ - free (plyfile); + /* free up memory associated with the PLY file */ + free(plyfile); } /****************************************************************************** -Get version number and file type of a PlyFile. + Get version number and file type of a PlyFile. -Entry: - ply - pointer to PLY file + Entry: + ply - pointer to PLY file -Exit: - version - version of the file - file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE + Exit: + version - version of the file + file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE ******************************************************************************/ void ply_get_info(PlyFile *ply, float *version, int *file_type) { - if (ply == NULL) - return; + if (ply == NULL) + return; - *version = ply->version; - *file_type = ply->file_type; + *version = ply->version; + *file_type = ply->file_type; } /****************************************************************************** -Compare two strings. Returns 1 if they are the same, 0 if not. + Compare two strings. Returns 1 if they are the same, 0 if not. ******************************************************************************/ int equal_strings(char *s1, char *s2) { - while (*s1 && *s2) - if (*s1++ != *s2++) - return (0); + while (*s1 && *s2) + if (*s1++ != *s2++) + return (0); - if (*s1 != *s2) - return (0); - else - return (1); + if (*s1 != *s2) + return (0); + else + return (1); } /****************************************************************************** -Find an element from the element list of a given PLY object. + Find an element from the element list of a given PLY object. -Entry: - plyfile - file id for PLY file - element - name of element we're looking for + Entry: + plyfile - file id for PLY file + element - name of element we're looking for -Exit: - returns the element, or NULL if not found + Exit: + returns the element, or NULL if not found ******************************************************************************/ PlyElement *find_element(PlyFile *plyfile, char *element) { - int i; + int i; - for (i = 0; i < plyfile->nelems; i++) - if (equal_strings (element, plyfile->elems[i]->name)) - return (plyfile->elems[i]); + for (i = 0; i < plyfile->nelems; i++) + if (equal_strings(element, plyfile->elems[i]->name)) + return (plyfile->elems[i]); - return (NULL); + return (NULL); } /****************************************************************************** -Find a property in the list of properties of a given element. + Find a property in the list of properties of a given element. -Entry: - elem - pointer to element in which we want to find the property - prop_name - name of property to find + Entry: + elem - pointer to element in which we want to find the property + prop_name - name of property to find -Exit: - index - index to position in list - returns a pointer to the property, or NULL if not found + Exit: + index - index to position in list + returns a pointer to the property, or NULL if not found ******************************************************************************/ PlyProperty *find_property(PlyElement *elem, char *prop_name, int *index) { - int i; + int i; - for (i = 0; i < elem->nprops; i++) - if (equal_strings (prop_name, elem->props[i]->name)) { - *index = i; - return (elem->props[i]); - } + for (i = 0; i < elem->nprops; i++) + if (equal_strings(prop_name, elem->props[i]->name)) { + *index = i; + return (elem->props[i]); + } - *index = -1; - return (NULL); + *index = -1; + return (NULL); } /****************************************************************************** -Read an element from an ascii file. + Read an element from an ascii file. -Entry: - plyfile - file identifier - elem_ptr - pointer to element + Entry: + plyfile - file identifier + elem_ptr - pointer to element ******************************************************************************/ void ascii_get_element(PlyFile *plyfile, char *elem_ptr) { - int j,k; - PlyElement *elem; - PlyProperty *prop; - char **words; - int nwords; - int which_word; - char *elem_data,*item; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char **store_array; - char *orig_line; - char *other_data; - int other_flag; - - other_flag = 0; + int j, k; + PlyElement *elem; + PlyProperty *prop; + char **words; + int nwords; + int which_word; + char *elem_data, *item; + char *item_ptr; + int item_size; + int int_val; + unsigned int uint_val; + double double_val; + int list_count; + int store_it; + char **store_array; + char *orig_line; + char *other_data; + int other_flag; + + other_flag = 0; other_data = NULL; item = NULL; item_size = 0; - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if (elem->other_offset != NO_OTHER_PROPS) { - char **ptr; - other_flag = 1; - /* make room for other_props */ - other_data = (char *) myalloc (elem->other_size); - /* store pointer in user's structure to the other_props */ - ptr = (char **) (elem_ptr + elem->other_offset); - *ptr = other_data; - } else { - other_flag = 0; - other_data = NULL; - item = NULL; - item_size = 0; - } - - /* read in the element */ - - words = get_words (plyfile->fp, &nwords, &orig_line); - if (words == NULL) { - fprintf (stderr, "ply_get_element: unexpected end of file\n"); - exit (-1); - } - - which_word = 0; - - for (j = 0; j < elem->nprops; j++) { - - prop = elem->props[j]; - store_it = (elem->store_prop[j] | other_flag); - - /* store either in the user's structure or in other_props */ - if (elem->store_prop[j]) - elem_data = elem_ptr; - else - elem_data = other_data; - - if (prop->is_list) { /* a list */ - - /* get and store the number of items in the list */ - get_ascii_item (words[which_word++], prop->count_external, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->count_offset; - store_item(item, prop->count_internal, int_val, uint_val, double_val); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = (char **) (elem_data + prop->offset); - - if (list_count == 0) { - if (store_it) - *store_array = NULL; - } - else { - if (store_it) { - item_ptr = (char *) myalloc (sizeof (char) * item_size * list_count); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for (k = 0; k < list_count; k++) { - get_ascii_item (words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - store_item (item, prop->internal_type, - int_val, uint_val, double_val); - item += item_size; - } - } - } - - } - else { /* not a list */ - get_ascii_item (words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->offset; - store_item (item, prop->internal_type, int_val, uint_val, double_val); - } - } - - } - - free (words); + /* the kind of element we're reading currently */ + elem = plyfile->which_elem; + + /* do we need to setup for other_props? */ + + if (elem->other_offset != NO_OTHER_PROPS) { + char **ptr; + other_flag = 1; + /* make room for other_props */ + other_data = (char *) myalloc(elem->other_size); + /* store pointer in user's structure to the other_props */ + ptr = (char **) (elem_ptr + elem->other_offset); + *ptr = other_data; + } + else { + other_flag = 0; + other_data = NULL; + item = NULL; + item_size = 0; + } + + /* read in the element */ + + words = get_words(plyfile->fp, &nwords, &orig_line); + if (words == NULL) { + fprintf(stderr, "ply_get_element: unexpected end of file\n"); + exit(-1); + } + + which_word = 0; + + for (j = 0; j < elem->nprops; j++) { + + prop = elem->props[j]; + store_it = (elem->store_prop[j] | other_flag); + + /* store either in the user's structure or in other_props */ + if (elem->store_prop[j]) + elem_data = elem_ptr; + else + elem_data = other_data; + + if (prop->is_list) { /* a list */ + + /* get and store the number of items in the list */ + get_ascii_item(words[which_word++], prop->count_external, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->count_offset; + store_item(item, prop->count_internal, int_val, uint_val, double_val); + } + + /* allocate space for an array of items and store a ptr to the array */ + list_count = int_val; + item_size = ply_type_size[prop->internal_type]; + store_array = (char **) (elem_data + prop->offset); + + if (list_count == 0) { + if (store_it) + *store_array = NULL; + } + else { + if (store_it) { + item_ptr = (char *) myalloc(sizeof(char) * item_size * list_count); + item = item_ptr; + *store_array = item_ptr; + } + + /* read items and store them into the array */ + for (k = 0; k < list_count; k++) { + get_ascii_item(words[which_word++], prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + store_item(item, prop->internal_type, + int_val, uint_val, double_val); + item += item_size; + } + } + } + + } + else { /* not a list */ + get_ascii_item(words[which_word++], prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->offset; + store_item(item, prop->internal_type, int_val, uint_val, double_val); + } + } + + } + + free(words); } /****************************************************************************** -Read an element from a binary file. + Read an element from a binary file. -Entry: - plyfile - file identifier - elem_ptr - pointer to an element + Entry: + plyfile - file identifier + elem_ptr - pointer to an element ******************************************************************************/ void binary_get_element(PlyFile *plyfile, char *elem_ptr) { - int j,k; - PlyElement *elem; - PlyProperty *prop; - FILE *fp = plyfile->fp; - char *elem_data,*item; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char **store_array; - char *other_data; - int other_flag; - - - other_flag = 0; - other_data = NULL; - item = NULL; - item_size = 0; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if (elem->other_offset != NO_OTHER_PROPS) { - char **ptr; - other_flag = 1; - /* make room for other_props */ - other_data = (char *) myalloc (elem->other_size); - /* store pointer in user's structure to the other_props */ - ptr = (char **) (elem_ptr + elem->other_offset); - *ptr = other_data; - } - else { - other_flag = 0; + int j, k; + PlyElement *elem; + PlyProperty *prop; + FILE *fp = plyfile->fp; + char *elem_data, *item; + char *item_ptr; + int item_size; + int int_val; + unsigned int uint_val; + double double_val; + int list_count; + int store_it; + char **store_array; + char *other_data; + int other_flag; + + + other_flag = 0; other_data = NULL; item = NULL; item_size = 0; - } - /* read in a number of elements */ - - for (j = 0; j < elem->nprops; j++) { - - prop = elem->props[j]; - store_it = (elem->store_prop[j] | other_flag); - - /* store either in the user's structure or in other_props */ - if (elem->store_prop[j]) - elem_data = elem_ptr; - else - elem_data = other_data; - - if (prop->is_list) { /* a list */ - - /* get and store the number of items in the list */ - get_binary_item (fp, prop->count_external, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->count_offset; - store_item(item, prop->count_internal, int_val, uint_val, double_val); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - /* The "if" was added by Afra Zomorodian 8/22/95 - * so that zipper won't crash reading plies that have additional - * properties. - */ - if (store_it) { - item_size = ply_type_size[prop->internal_type]; - } - store_array = (char **) (elem_data + prop->offset); - if (list_count == 0) { - if (store_it) - *store_array = NULL; - } - else { - if (store_it) { - item_ptr = (char *) myalloc (sizeof (char) * item_size * list_count); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for (k = 0; k < list_count; k++) { - get_binary_item (fp, prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - store_item (item, prop->internal_type, - int_val, uint_val, double_val); - item += item_size; - } - } - } - - } - else { /* not a list */ - get_binary_item (fp, prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->offset; - store_item (item, prop->internal_type, int_val, uint_val, double_val); - } - } - - } + + /* the kind of element we're reading currently */ + elem = plyfile->which_elem; + + /* do we need to setup for other_props? */ + + if (elem->other_offset != NO_OTHER_PROPS) { + char **ptr; + other_flag = 1; + /* make room for other_props */ + other_data = (char *) myalloc(elem->other_size); + /* store pointer in user's structure to the other_props */ + ptr = (char **) (elem_ptr + elem->other_offset); + *ptr = other_data; + } + else { + other_flag = 0; + other_data = NULL; + item = NULL; + item_size = 0; + } + /* read in a number of elements */ + + for (j = 0; j < elem->nprops; j++) { + + prop = elem->props[j]; + store_it = (elem->store_prop[j] | other_flag); + + /* store either in the user's structure or in other_props */ + if (elem->store_prop[j]) + elem_data = elem_ptr; + else + elem_data = other_data; + + if (prop->is_list) { /* a list */ + + /* get and store the number of items in the list */ + get_binary_item(fp, prop->count_external, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->count_offset; + store_item(item, prop->count_internal, int_val, uint_val, double_val); + } + + /* allocate space for an array of items and store a ptr to the array */ + list_count = int_val; + /* The "if" was added by Afra Zomorodian 8/22/95 + * so that zipper won't crash reading plies that have additional + * properties. + */ + if (store_it) { + item_size = ply_type_size[prop->internal_type]; + } + store_array = (char **) (elem_data + prop->offset); + if (list_count == 0) { + if (store_it) + *store_array = NULL; + } + else { + if (store_it) { + item_ptr = (char *) myalloc(sizeof(char) * item_size * list_count); + item = item_ptr; + *store_array = item_ptr; + } + + /* read items and store them into the array */ + for (k = 0; k < list_count; k++) { + get_binary_item(fp, prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + store_item(item, prop->internal_type, + int_val, uint_val, double_val); + item += item_size; + } + } + } + + } + else { /* not a list */ + get_binary_item(fp, prop->external_type, + &int_val, &uint_val, &double_val); + if (store_it) { + item = elem_data + prop->offset; + store_item(item, prop->internal_type, int_val, uint_val, double_val); + } + } + + } } /****************************************************************************** -Write to a file the word that represents a PLY data type. + Write to a file the word that represents a PLY data type. -Entry: - fp - file pointer - code - code for type + Entry: + fp - file pointer + code - code for type ******************************************************************************/ -void write_scalar_type (FILE *fp, int code) +void write_scalar_type(FILE *fp, int code) { - /* make sure this is a valid code */ + /* make sure this is a valid code */ - if (code <= PLY_START_TYPE || code >= PLY_END_TYPE) { - fprintf (stderr, "write_scalar_type: bad data code = %d\n", code); - exit (-1); - } + if (code <= PLY_START_TYPE || code >= PLY_END_TYPE) { + fprintf(stderr, "write_scalar_type: bad data code = %d\n", code); + exit(-1); + } - /* write the code to a file */ + /* write the code to a file */ - fprintf (fp, "%s", type_names[code]); + fprintf(fp, "%s", type_names[code]); } /****************************************************************************** -Get a text line from a file and break it up into words. + Get a text line from a file and break it up into words. -IMPORTANT: The calling routine call "free" on the returned pointer once -finished with it. + IMPORTANT: The calling routine call "free" on the returned pointer once + finished with it. -Entry: - fp - file to read from + Entry: + fp - file to read from -Exit: - nwords - number of words returned - orig_line - the original line of characters - returns a list of words from the line, or NULL if end-of-file + Exit: + nwords - number of words returned + orig_line - the original line of characters + returns a list of words from the line, or NULL if end-of-file ******************************************************************************/ char **get_words(FILE *fp, int *nwords, char **orig_line) { #define BIG_STRING 4096 - static char str[BIG_STRING]; - static char str_copy[BIG_STRING]; - char **words; - int max_words = 10; - int num_words = 0; - char *ptr,*ptr2; - char *result; - - words = (char **) myalloc (sizeof (char *) * max_words); - - /* read in a line */ - result = fgets (str, BIG_STRING, fp); - if (result == NULL) { - *nwords = 0; - *orig_line = NULL; - return (NULL); - } - - /* convert line-feed and tabs into spaces */ - /* (this guarentees that there will be a space before the */ - /* null character at the end of the string) */ - - str[BIG_STRING-2] = ' '; - str[BIG_STRING-1] = '\0'; - - for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) { - *ptr2 = *ptr; - if (*ptr == '\t') { - *ptr = ' '; - *ptr2 = ' '; - } - else if (*ptr == '\n') { - *ptr = ' '; - *ptr2 = '\0'; - break; - } - } - - /* find the words in the line */ - - ptr = str; - while (*ptr != '\0') { - - /* jump over leading spaces */ - while (*ptr == ' ') - ptr++; - - /* break if we reach the end */ - if (*ptr == '\0') - break; - - /* save pointer to beginning of word */ - if (num_words >= max_words) { - max_words += 10; - words = (char **) realloc (words, sizeof (char *) * max_words); - } - words[num_words++] = ptr; - - /* jump over non-spaces */ - while (*ptr != ' ') - ptr++; - - /* place a null character here to mark the end of the word */ - *ptr++ = '\0'; - } - - /* return the list of words */ - *nwords = num_words; - *orig_line = str_copy; - return (words); + static char str[BIG_STRING]; + static char str_copy[BIG_STRING]; + char **words; + int max_words = 10; + int num_words = 0; + char *ptr, *ptr2; + char *result; + + words = (char **) myalloc(sizeof(char *) * max_words); + + /* read in a line */ + result = fgets(str, BIG_STRING, fp); + if (result == NULL) { + *nwords = 0; + *orig_line = NULL; + return (NULL); + } + + /* convert line-feed and tabs into spaces */ + /* (this guarentees that there will be a space before the */ + /* null character at the end of the string) */ + + str[BIG_STRING - 2] = ' '; + str[BIG_STRING - 1] = '\0'; + + for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) { + *ptr2 = *ptr; + if (*ptr == '\t') { + *ptr = ' '; + *ptr2 = ' '; + } + else if (*ptr == '\n') { + *ptr = ' '; + *ptr2 = '\0'; + break; + } + } + + /* find the words in the line */ + + ptr = str; + while (*ptr != '\0') { + + /* jump over leading spaces */ + while (*ptr == ' ') + ptr++; + + /* break if we reach the end */ + if (*ptr == '\0') + break; + + /* save pointer to beginning of word */ + if (num_words >= max_words) { + max_words += 10; + words = (char **) realloc(words, sizeof(char *) * max_words); + } + words[num_words++] = ptr; + + /* jump over non-spaces */ + while (*ptr != ' ') + ptr++; + + /* place a null character here to mark the end of the word */ + *ptr++ = '\0'; + } + + /* return the list of words */ + *nwords = num_words; + *orig_line = str_copy; + return (words); } /****************************************************************************** -Return the value of an item, given a pointer to it and its type. + Return the value of an item, given a pointer to it and its type. -Entry: - item - pointer to item - type - data type that "item" points to + Entry: + item - pointer to item + type - data type that "item" points to -Exit: - returns a double-precision float that contains the value of the item + Exit: + returns a double-precision float that contains the value of the item ******************************************************************************/ double get_item_value(char *item, int type) { - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch (type) { - case PLY_CHAR: - pchar = (char *) item; - int_value = *pchar; - return ((double) int_value); - case PLY_UCHAR: - puchar = (unsigned char *) item; - int_value = *puchar; - return ((double) int_value); - case PLY_SHORT: - pshort = (short int *) item; - int_value = *pshort; - return ((double) int_value); - case PLY_USHORT: - pushort = (unsigned short int *) item; - int_value = *pushort; - return ((double) int_value); - case PLY_INT: - pint = (int *) item; - int_value = *pint; - return ((double) int_value); - case PLY_UINT: - puint = (unsigned int *) item; - uint_value = *puint; - return ((double) uint_value); - case PLY_FLOAT: - pfloat = (float *) item; - double_value = *pfloat; - return (double_value); - case PLY_DOUBLE: - pdouble = (double *) item; - double_value = *pdouble; - return (double_value); - default: - fprintf (stderr, "get_item_value: bad type = %d\n", type); - exit (-1); - } + unsigned char *puchar; + char *pchar; + short int *pshort; + unsigned short int *pushort; + int *pint; + unsigned int *puint; + float *pfloat; + double *pdouble; + int int_value; + unsigned int uint_value; + double double_value; + + switch (type) { + case PLY_CHAR: + pchar = (char *) item; + int_value = *pchar; + return ((double) int_value); + case PLY_UCHAR: + puchar = (unsigned char *) item; + int_value = *puchar; + return ((double) int_value); + case PLY_SHORT: + pshort = (short int *) item; + int_value = *pshort; + return ((double) int_value); + case PLY_USHORT: + pushort = (unsigned short int *) item; + int_value = *pushort; + return ((double) int_value); + case PLY_INT: + pint = (int *) item; + int_value = *pint; + return ((double) int_value); + case PLY_UINT: + puint = (unsigned int *) item; + uint_value = *puint; + return ((double) uint_value); + case PLY_FLOAT: + pfloat = (float *) item; + double_value = *pfloat; + return (double_value); + case PLY_DOUBLE: + pdouble = (double *) item; + double_value = *pdouble; + return (double_value); + default: + fprintf(stderr, "get_item_value: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Write out an item to a file as raw binary bytes. - -Entry: - fp - file to write to - int_val - integer version of item - uint_val - unsigned integer version of item - double_val - double-precision float version of item - type - data type to write out + Write out an item to a file as raw binary bytes. + + Entry: + fp - file to write to + int_val - integer version of item + uint_val - unsigned integer version of item + double_val - double-precision float version of item + type - data type to write out ******************************************************************************/ void write_binary_item( - FILE *fp, - int int_val, - unsigned int uint_val, - double double_val, - int type -) + FILE *fp, + int int_val, + unsigned int uint_val, + double double_val, + int type + ) { - unsigned char uchar_val; - char char_val; - unsigned short ushort_val; - short short_val; - float float_val; - - switch (type) { - case PLY_CHAR: - char_val = (char)int_val; - fwrite (&char_val, 1, 1, fp); - break; - case PLY_SHORT: - short_val = (short)int_val; - fwrite (&short_val, 2, 1, fp); - break; - case PLY_INT: - fwrite (&int_val, 4, 1, fp); - break; - case PLY_UCHAR: - uchar_val = (unsigned char) uint_val; - fwrite (&uchar_val, 1, 1, fp); - break; - case PLY_USHORT: - ushort_val = (unsigned short)uint_val; - fwrite (&ushort_val, 2, 1, fp); - break; - case PLY_UINT: - fwrite (&uint_val, 4, 1, fp); - break; - case PLY_FLOAT: - float_val = (float) double_val; - fwrite (&float_val, 4, 1, fp); - break; - case PLY_DOUBLE: - fwrite (&double_val, 8, 1, fp); - break; - default: - fprintf (stderr, "write_binary_item: bad type = %d\n", type); - exit (-1); - } + unsigned char uchar_val; + char char_val; + unsigned short ushort_val; + short short_val; + float float_val; + + switch (type) { + case PLY_CHAR: + char_val = (char)int_val; + fwrite(&char_val, 1, 1, fp); + break; + case PLY_SHORT: + short_val = (short)int_val; + fwrite(&short_val, 2, 1, fp); + break; + case PLY_INT: + fwrite(&int_val, 4, 1, fp); + break; + case PLY_UCHAR: + uchar_val = (unsigned char) uint_val; + fwrite(&uchar_val, 1, 1, fp); + break; + case PLY_USHORT: + ushort_val = (unsigned short)uint_val; + fwrite(&ushort_val, 2, 1, fp); + break; + case PLY_UINT: + fwrite(&uint_val, 4, 1, fp); + break; + case PLY_FLOAT: + float_val = (float) double_val; + fwrite(&float_val, 4, 1, fp); + break; + case PLY_DOUBLE: + fwrite(&double_val, 8, 1, fp); + break; + default: + fprintf(stderr, "write_binary_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Write out an item to a file as ascii characters. - -Entry: - fp - file to write to - int_val - integer version of item - uint_val - unsigned integer version of item - double_val - double-precision float version of item - type - data type to write out + Write out an item to a file as ascii characters. + + Entry: + fp - file to write to + int_val - integer version of item + uint_val - unsigned integer version of item + double_val - double-precision float version of item + type - data type to write out ******************************************************************************/ void write_ascii_item( - FILE *fp, - int int_val, - unsigned int uint_val, - double double_val, - int type -) + FILE *fp, + int int_val, + unsigned int uint_val, + double double_val, + int type + ) { - switch (type) { - case PLY_CHAR: - case PLY_SHORT: - case PLY_INT: - fprintf (fp, "%d ", int_val); - break; - case PLY_UCHAR: - case PLY_USHORT: - case PLY_UINT: - fprintf (fp, "%u ", uint_val); - break; - case PLY_FLOAT: - case PLY_DOUBLE: - fprintf (fp, "%g ", double_val); - break; - default: - fprintf (stderr, "write_ascii_item: bad type = %d\n", type); - exit (-1); - } + switch (type) { + case PLY_CHAR: + case PLY_SHORT: + case PLY_INT: + fprintf(fp, "%d ", int_val); + break; + case PLY_UCHAR: + case PLY_USHORT: + case PLY_UINT: + fprintf(fp, "%u ", uint_val); + break; + case PLY_FLOAT: + case PLY_DOUBLE: + fprintf(fp, "%g ", double_val); + break; + default: + fprintf(stderr, "write_ascii_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Write out an item to a file as ascii characters. + Write out an item to a file as ascii characters. -Entry: - fp - file to write to - item - pointer to item to write - type - data type that "item" points to + Entry: + fp - file to write to + item - pointer to item to write + type - data type that "item" points to -Exit: - returns a double-precision float that contains the value of the written item + Exit: + returns a double-precision float that contains the value of the written item ******************************************************************************/ double old_write_ascii_item(FILE *fp, char *item, int type) { - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch (type) { - case PLY_CHAR: - pchar = (char *) item; - int_value = *pchar; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_UCHAR: - puchar = (unsigned char *) item; - int_value = *puchar; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_SHORT: - pshort = (short int *) item; - int_value = *pshort; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_USHORT: - pushort = (unsigned short int *) item; - int_value = *pushort; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_INT: - pint = (int *) item; - int_value = *pint; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_UINT: - puint = (unsigned int *) item; - uint_value = *puint; - fprintf (fp, "%u ", uint_value); - return ((double) uint_value); - case PLY_FLOAT: - pfloat = (float *) item; - double_value = *pfloat; - fprintf (fp, "%g ", double_value); - return (double_value); - case PLY_DOUBLE: - pdouble = (double *) item; - double_value = *pdouble; - fprintf (fp, "%g ", double_value); - return (double_value); - default: - fprintf (stderr, "old_write_ascii_item: bad type = %d\n", type); - exit (-1); - } + unsigned char *puchar; + char *pchar; + short int *pshort; + unsigned short int *pushort; + int *pint; + unsigned int *puint; + float *pfloat; + double *pdouble; + int int_value; + unsigned int uint_value; + double double_value; + + switch (type) { + case PLY_CHAR: + pchar = (char *) item; + int_value = *pchar; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_UCHAR: + puchar = (unsigned char *) item; + int_value = *puchar; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_SHORT: + pshort = (short int *) item; + int_value = *pshort; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_USHORT: + pushort = (unsigned short int *) item; + int_value = *pushort; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_INT: + pint = (int *) item; + int_value = *pint; + fprintf(fp, "%d ", int_value); + return ((double) int_value); + case PLY_UINT: + puint = (unsigned int *) item; + uint_value = *puint; + fprintf(fp, "%u ", uint_value); + return ((double) uint_value); + case PLY_FLOAT: + pfloat = (float *) item; + double_value = *pfloat; + fprintf(fp, "%g ", double_value); + return (double_value); + case PLY_DOUBLE: + pdouble = (double *) item; + double_value = *pdouble; + fprintf(fp, "%g ", double_value); + return (double_value); + default: + fprintf(stderr, "old_write_ascii_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Get the value of an item that is in memory, and place the result -into an integer, an unsigned integer and a double. + Get the value of an item that is in memory, and place the result + into an integer, an unsigned integer and a double. -Entry: - ptr - pointer to the item - type - data type supposedly in the item + Entry: + ptr - pointer to the item + type - data type supposedly in the item -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value + Exit: + int_val - integer value + uint_val - unsigned integer value + double_val - double-precision floating point value ******************************************************************************/ void get_stored_item( - void *ptr, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val -) + void *ptr, + int type, + int *int_val, + unsigned int *uint_val, + double *double_val + ) { - switch (type) { - case PLY_CHAR: - *int_val = *((char *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UCHAR: - *uint_val = *((unsigned char *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_SHORT: - *int_val = *((short int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_USHORT: - *uint_val = *((unsigned short int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_INT: - *int_val = *((int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UINT: - *uint_val = *((unsigned int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_FLOAT: - *double_val = *((float *) ptr); - *int_val = (int)*double_val; - *uint_val = (unsigned int)*double_val; - break; - case PLY_DOUBLE: - *double_val = *((double *) ptr); - *int_val = (int)*double_val; - *uint_val =(unsigned int) *double_val; - break; - default: - fprintf (stderr, "get_stored_item: bad type = %d\n", type); - exit (-1); - } + switch (type) { + case PLY_CHAR: + *int_val = *((char *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UCHAR: + *uint_val = *((unsigned char *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_SHORT: + *int_val = *((short int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_USHORT: + *uint_val = *((unsigned short int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_INT: + *int_val = *((int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UINT: + *uint_val = *((unsigned int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_FLOAT: + *double_val = *((float *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int)*double_val; + break; + case PLY_DOUBLE: + *double_val = *((double *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int) *double_val; + break; + default: + fprintf(stderr, "get_stored_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Get the value of an item from a binary file, and place the result -into an integer, an unsigned integer and a double. + Get the value of an item from a binary file, and place the result + into an integer, an unsigned integer and a double. -Entry: - fp - file to get item from - type - data type supposedly in the word + Entry: + fp - file to get item from + type - data type supposedly in the word -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value + Exit: + int_val - integer value + uint_val - unsigned integer value + double_val - double-precision floating point value ******************************************************************************/ void get_binary_item( - FILE *fp, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val -) + FILE *fp, + int type, + int *int_val, + unsigned int *uint_val, + double *double_val + ) { - char c[8]; - void *ptr; - - ptr = (void *) c; - - switch (type) { - case PLY_CHAR: - fread (ptr, 1, 1, fp); - *int_val = *((char *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UCHAR: - fread (ptr, 1, 1, fp); - *uint_val = *((unsigned char *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_SHORT: - fread (ptr, 2, 1, fp); - *int_val = *((short int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_USHORT: - fread (ptr, 2, 1, fp); - *uint_val = *((unsigned short int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_INT: - fread (ptr, 4, 1, fp); - *int_val = *((int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UINT: - fread (ptr, 4, 1, fp); - *uint_val = *((unsigned int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_FLOAT: - fread (ptr, 4, 1, fp); - *double_val = *((float *) ptr); - *int_val = (int)*double_val; - *uint_val =(unsigned int) *double_val; - break; - case PLY_DOUBLE: - fread (ptr, 8, 1, fp); - *double_val = *((double *) ptr); - *int_val = (int)*double_val; - *uint_val = (unsigned int)*double_val; - break; - default: - fprintf (stderr, "get_binary_item: bad type = %d\n", type); - exit (-1); - } + char c[8]; + void *ptr; + + ptr = (void *) c; + + switch (type) { + case PLY_CHAR: + fread(ptr, 1, 1, fp); + *int_val = *((char *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UCHAR: + fread(ptr, 1, 1, fp); + *uint_val = *((unsigned char *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_SHORT: + fread(ptr, 2, 1, fp); + *int_val = *((short int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_USHORT: + fread(ptr, 2, 1, fp); + *uint_val = *((unsigned short int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_INT: + fread(ptr, 4, 1, fp); + *int_val = *((int *) ptr); + *uint_val = *int_val; + *double_val = *int_val; + break; + case PLY_UINT: + fread(ptr, 4, 1, fp); + *uint_val = *((unsigned int *) ptr); + *int_val = *uint_val; + *double_val = *uint_val; + break; + case PLY_FLOAT: + fread(ptr, 4, 1, fp); + *double_val = *((float *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int) *double_val; + break; + case PLY_DOUBLE: + fread(ptr, 8, 1, fp); + *double_val = *((double *) ptr); + *int_val = (int)*double_val; + *uint_val = (unsigned int)*double_val; + break; + default: + fprintf(stderr, "get_binary_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Extract the value of an item from an ascii word, and place the result -into an integer, an unsigned integer and a double. + Extract the value of an item from an ascii word, and place the result + into an integer, an unsigned integer and a double. -Entry: - word - word to extract value from - type - data type supposedly in the word + Entry: + word - word to extract value from + type - data type supposedly in the word -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value + Exit: + int_val - integer value + uint_val - unsigned integer value + double_val - double-precision floating point value ******************************************************************************/ void get_ascii_item( - char *word, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val -) + char *word, + int type, + int *int_val, + unsigned int *uint_val, + double *double_val + ) { - switch (type) { - case PLY_CHAR: - case PLY_UCHAR: - case PLY_SHORT: - case PLY_USHORT: - case PLY_INT: - *int_val = atoi (word); - *uint_val = *int_val; - *double_val = *int_val; - break; - - case PLY_UINT: - *uint_val = strtoul (word, (char **) NULL, 10); - *int_val = *uint_val; - *double_val = *uint_val; - break; - - case PLY_FLOAT: - case PLY_DOUBLE: - *double_val = atof (word); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - - default: - fprintf (stderr, "get_ascii_item: bad type = %d\n", type); - exit (-1); - } + switch (type) { + case PLY_CHAR: + case PLY_UCHAR: + case PLY_SHORT: + case PLY_USHORT: + case PLY_INT: + *int_val = atoi(word); + *uint_val = *int_val; + *double_val = *int_val; + break; + + case PLY_UINT: + *uint_val = strtoul(word, (char **) NULL, 10); + *int_val = *uint_val; + *double_val = *uint_val; + break; + + case PLY_FLOAT: + case PLY_DOUBLE: + *double_val = atof(word); + *int_val = (int) *double_val; + *uint_val = (unsigned int) *double_val; + break; + + default: + fprintf(stderr, "get_ascii_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Store a value into a place being pointed to, guided by a data type. + Store a value into a place being pointed to, guided by a data type. -Entry: - item - place to store value - type - data type - int_val - integer version of value - uint_val - unsigned integer version of value - double_val - double version of value + Entry: + item - place to store value + type - data type + int_val - integer version of value + uint_val - unsigned integer version of value + double_val - double version of value -Exit: - item - pointer to stored value + Exit: + item - pointer to stored value ******************************************************************************/ -void store_item ( - char *item, - int type, - int int_val, - unsigned int uint_val, - double double_val -) +void store_item( + char *item, + int type, + int int_val, + unsigned int uint_val, + double double_val + ) { - unsigned char *puchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - - switch (type) { - case PLY_CHAR: - *item = (char) int_val; - break; - case PLY_UCHAR: - puchar = (unsigned char *) item; - *puchar = (unsigned char)uint_val; - break; - case PLY_SHORT: - pshort = (short *) item; - *pshort = (short)int_val; - break; - case PLY_USHORT: - pushort = (unsigned short *) item; - *pushort = (unsigned short)uint_val; - break; - case PLY_INT: - pint = (int *) item; - *pint = int_val; - break; - case PLY_UINT: - puint = (unsigned int *) item; - *puint = uint_val; - break; - case PLY_FLOAT: - pfloat = (float *) item; - *pfloat = (float)double_val; - break; - case PLY_DOUBLE: - pdouble = (double *) item; - *pdouble = double_val; - break; - default: - fprintf (stderr, "store_item: bad type = %d\n", type); - exit (-1); - } + unsigned char *puchar; + short int *pshort; + unsigned short int *pushort; + int *pint; + unsigned int *puint; + float *pfloat; + double *pdouble; + + switch (type) { + case PLY_CHAR: + *item = (char) int_val; + break; + case PLY_UCHAR: + puchar = (unsigned char *) item; + *puchar = (unsigned char)uint_val; + break; + case PLY_SHORT: + pshort = (short *) item; + *pshort = (short)int_val; + break; + case PLY_USHORT: + pushort = (unsigned short *) item; + *pushort = (unsigned short)uint_val; + break; + case PLY_INT: + pint = (int *) item; + *pint = int_val; + break; + case PLY_UINT: + puint = (unsigned int *) item; + *puint = uint_val; + break; + case PLY_FLOAT: + pfloat = (float *) item; + *pfloat = (float)double_val; + break; + case PLY_DOUBLE: + pdouble = (double *) item; + *pdouble = double_val; + break; + default: + fprintf(stderr, "store_item: bad type = %d\n", type); + exit(-1); + } } /****************************************************************************** -Add an element to a PLY file descriptor. + Add an element to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - words - list of words describing the element - nwords - number of words in the list + Entry: + plyfile - PLY file descriptor + words - list of words describing the element + nwords - number of words in the list ******************************************************************************/ -void add_element (PlyFile *plyfile, char **words) +void add_element(PlyFile *plyfile, char **words) { - PlyElement *elem; - - /* create the new element */ - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - elem->name = strdup (words[1]); - elem->num = atoi (words[2]); - elem->nprops = 0; - - /* make room for new element in the object's list of elements */ - if (plyfile->nelems == 0) - plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *)); - else - plyfile->elems = (PlyElement **) realloc (plyfile->elems, - sizeof (PlyElement *) * (plyfile->nelems + 1)); - - /* add the new element to the object's list */ - plyfile->elems[plyfile->nelems] = elem; - plyfile->nelems++; + PlyElement *elem; + + /* create the new element */ + elem = (PlyElement *) myalloc(sizeof(PlyElement)); + elem->name = strdup(words[1]); + elem->num = atoi(words[2]); + elem->nprops = 0; + + /* make room for new element in the object's list of elements */ + if (plyfile->nelems == 0) + plyfile->elems = (PlyElement **) myalloc(sizeof(PlyElement *)); + else + plyfile->elems = (PlyElement **) realloc(plyfile->elems, + sizeof(PlyElement *) * (plyfile->nelems + 1)); + + /* add the new element to the object's list */ + plyfile->elems[plyfile->nelems] = elem; + plyfile->nelems++; } /****************************************************************************** -Return the type of a property, given the name of the property. + Return the type of a property, given the name of the property. -Entry: - name - name of property type + Entry: + name - name of property type -Exit: - returns integer code for property, or 0 if not found + Exit: + returns integer code for property, or 0 if not found ******************************************************************************/ int get_prop_type(char *type_name) { - int i; + int i; - for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++) - if (equal_strings (type_name, type_names[i])) - return (i); + for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++) + if (equal_strings(type_name, type_names[i])) + return (i); - /* if we get here, we didn't find the type */ - return (0); + /* if we get here, we didn't find the type */ + return (0); } /****************************************************************************** -Add a property to a PLY file descriptor. + Add a property to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - words - list of words describing the property - nwords - number of words in the list + Entry: + plyfile - PLY file descriptor + words - list of words describing the property + nwords - number of words in the list ******************************************************************************/ -void add_property (PlyFile *plyfile, char **words) +void add_property(PlyFile *plyfile, char **words) { - PlyProperty *prop; - PlyElement *elem; + PlyProperty *prop; + PlyElement *elem; - /* create the new property */ + /* create the new property */ - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); + prop = (PlyProperty *) myalloc(sizeof(PlyProperty)); - if (equal_strings (words[1], "list")) { /* is a list */ - prop->count_external = get_prop_type (words[2]); - prop->external_type = get_prop_type (words[3]); - prop->name = strdup (words[4]); - prop->is_list = 1; - } - else { /* not a list */ - prop->external_type = get_prop_type (words[1]); - prop->name = strdup (words[2]); - prop->is_list = 0; - } + if (equal_strings(words[1], "list")) { /* is a list */ + prop->count_external = get_prop_type(words[2]); + prop->external_type = get_prop_type(words[3]); + prop->name = strdup(words[4]); + prop->is_list = 1; + } + else { /* not a list */ + prop->external_type = get_prop_type(words[1]); + prop->name = strdup(words[2]); + prop->is_list = 0; + } - /* add this property to the list of properties of the current element */ + /* add this property to the list of properties of the current element */ - elem = plyfile->elems[plyfile->nelems - 1]; + elem = plyfile->elems[plyfile->nelems - 1]; - if (elem->nprops == 0) - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *)); - else - elem->props = (PlyProperty **) realloc (elem->props, - sizeof (PlyProperty *) * (elem->nprops + 1)); + if (elem->nprops == 0) + elem->props = (PlyProperty **) myalloc(sizeof(PlyProperty *)); + else + elem->props = (PlyProperty **) realloc(elem->props, + sizeof(PlyProperty *) * (elem->nprops + 1)); - elem->props[elem->nprops] = prop; - elem->nprops++; + elem->props[elem->nprops] = prop; + elem->nprops++; } /****************************************************************************** -Add a comment to a PLY file descriptor. + Add a comment to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - line - line containing comment + Entry: + plyfile - PLY file descriptor + line - line containing comment ******************************************************************************/ -void add_comment (PlyFile *plyfile, char *line) +void add_comment(PlyFile *plyfile, char *line) { - int i; + int i; - /* skip over "comment" and leading spaces and tabs */ - i = 7; - while (line[i] == ' ' || line[i] == '\t') - i++; + /* skip over "comment" and leading spaces and tabs */ + i = 7; + while (line[i] == ' ' || line[i] == '\t') + i++; - ply_put_comment (plyfile, &line[i]); + ply_put_comment(plyfile, &line[i]); } /****************************************************************************** -Add a some object information to a PLY file descriptor. + Add a some object information to a PLY file descriptor. -Entry: - plyfile - PLY file descriptor - line - line containing text info + Entry: + plyfile - PLY file descriptor + line - line containing text info ******************************************************************************/ -void add_obj_info (PlyFile *plyfile, char *line) +void add_obj_info(PlyFile *plyfile, char *line) { - int i; + int i; - /* skip over "obj_info" and leading spaces and tabs */ - i = 8; - while (line[i] == ' ' || line[i] == '\t') - i++; + /* skip over "obj_info" and leading spaces and tabs */ + i = 8; + while (line[i] == ' ' || line[i] == '\t') + i++; - ply_put_obj_info (plyfile, &line[i]); + ply_put_obj_info(plyfile, &line[i]); } /****************************************************************************** -Copy a property. + Copy a property. ******************************************************************************/ void copy_property(PlyProperty *dest, PlyProperty *src) { - dest->name = strdup (src->name); - dest->external_type = src->external_type; - dest->internal_type = src->internal_type; - dest->offset = src->offset; - - dest->is_list = src->is_list; - dest->count_external = src->count_external; - dest->count_internal = src->count_internal; - dest->count_offset = src->count_offset; + dest->name = strdup(src->name); + dest->external_type = src->external_type; + dest->internal_type = src->internal_type; + dest->offset = src->offset; + + dest->is_list = src->is_list; + dest->count_external = src->count_external; + dest->count_internal = src->count_internal; + dest->count_offset = src->count_offset; } /****************************************************************************** -Allocate some memory. + Allocate some memory. -Entry: - size - amount of memory requested (in bytes) - lnum - line number from which memory was requested - fname - file name from which memory was requested + Entry: + size - amount of memory requested (in bytes) + lnum - line number from which memory was requested + fname - file name from which memory was requested ******************************************************************************/ static char *my_alloc(int size, int lnum, char *fname) { - char *ptr; + char *ptr; - ptr = (char *) malloc (size); + ptr = (char *) malloc(size); - if (ptr == 0) { - fprintf(stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname); - } + if (ptr == 0) { + fprintf(stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname); + } - return (ptr); + return (ptr); } diff --git a/intern/container/CTR_UHeap.h b/intern/container/CTR_UHeap.h index 8711d4375cb..8330faa2f54 100644 --- a/intern/container/CTR_UHeap.h +++ b/intern/container/CTR_UHeap.h @@ -53,47 +53,47 @@ class CTR_UHeapable { -public : - int & +public: + int & HeapPos( - ) { + ) { return m_ind; }; - float & + float & HeapKey( - ) { + ) { return m_key; }; const - float & + float & HeapKey( - ) const { + ) const { return m_key; }; const - int & + int & HeapPos( - ) const { + ) const { return m_ind; }; -private : +private: float m_key; int m_ind; -protected : +protected: CTR_UHeapable( - ) : m_key (0), - m_ind (0) + ) : m_key(0), + m_ind(0) { }; ~CTR_UHeapable( - ) { + ) { }; }; @@ -104,50 +104,50 @@ class CTR_UHeap : public MEM_NonCopyable public: static - CTR_UHeap * + CTR_UHeap * New( - ) { + ) { return new CTR_UHeap(); } - void + void MakeHeap( - HeapType *base - ) { + HeapType *base + ) { int i; - int start = Parent(m_vector.size()-1); - for (i = start; i >=0; --i) { - DownHeap(base,i); + int start = Parent(m_vector.size() - 1); + for (i = start; i >= 0; --i) { + DownHeap(base, i); } }; - void + void Insert( - HeapType *base, - int elem - ) { + HeapType *base, + int elem + ) { // add element to vector m_vector.push_back(elem); - base[elem].HeapPos() = m_vector.size()-1; + base[elem].HeapPos() = m_vector.size() - 1; // push the element up the heap - UpHeap(base,m_vector.size()-1); + UpHeap(base, m_vector.size() - 1); } // access to the vector for initial loading of elements - std::vector<int> & + std::vector<int> & HeapVector( - ) { + ) { return m_vector; }; - void + void Remove( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { // exchange with last element - pop last // element and move up or down the heap as appropriate @@ -155,37 +155,38 @@ public: assert(false); } - if (i != int(m_vector.size())-1) { + if (i != int(m_vector.size()) - 1) { - Swap(base,i,m_vector.size() - 1); + Swap(base, i, m_vector.size() - 1); m_vector.pop_back(); if (!m_vector.empty()) { - UpHeap(base,i); - DownHeap(base,i); + UpHeap(base, i); + DownHeap(base, i); } - } else { + } + else { m_vector.pop_back(); } } - int + int Top( - ) const { + ) const { if (m_vector.empty()) return -1; return m_vector[0]; } - void + void SC_Heap( - HeapType *base - ) { + HeapType *base + ) { int i; - for (i = 1; i < int(m_vector.size()) ; i++) { + for (i = 1; i < int(m_vector.size()); i++) { - CTR_UHeapable * elem = base + m_vector[i]; - CTR_UHeapable * p_elem = base + m_vector[Parent(i)]; + CTR_UHeapable *elem = base + m_vector[i]; + CTR_UHeapable *p_elem = base + m_vector[Parent(i)]; assert(p_elem->HeapKey() >= elem->HeapKey()); assert(elem->HeapPos() == i); @@ -195,27 +196,27 @@ public: ~CTR_UHeap( - ) { + ) { }; private: CTR_UHeap( - ) { + ) { }; std::vector<int> m_vector; private: - void + void Swap( - HeapType *base, - int i, - int j - ) { - std::swap(m_vector[i],m_vector[j]); + HeapType *base, + int i, + int j + ) { + std::swap(m_vector[i], m_vector[j]); CTR_UHeapable *heap_i = base + m_vector[i]; CTR_UHeapable *heap_j = base + m_vector[j]; @@ -225,77 +226,78 @@ private: heap_j->HeapPos() = j; } - int + int Parent( - unsigned int i - ) { - return (i-1) >> 1; + unsigned int i + ) { + return (i - 1) >> 1; } - int + int Left( - int i - ) { - return (i<<1)+1; + int i + ) { + return (i << 1) + 1; } - int + int Right( - int i - ) { - return (i<<1)+2; + int i + ) { + return (i << 1) + 2; } - float + float HeapVal( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { return base[m_vector[i]].HeapKey(); } - void + void DownHeap( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { int heap_size = m_vector.size(); int l = Left(i); int r = Right(i); int largest; - if (l < heap_size && HeapVal(base,l) > HeapVal(base,i)) { + if (l < heap_size && HeapVal(base, l) > HeapVal(base, i)) { largest = l; - } else { + } + else { largest = i; } - if (r < heap_size && HeapVal(base,r) > HeapVal(base,largest)) { + if (r < heap_size && HeapVal(base, r) > HeapVal(base, largest)) { largest = r; } if (largest != i) { // exchange i and largest - Swap(base,i,largest); - DownHeap(base,largest); + Swap(base, i, largest); + DownHeap(base, largest); } } - void + void UpHeap( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { // swap parents untill it's found a place in the heap < it's parent or // top of heap while (i > 0) { int p = Parent(i); - if (HeapVal(base,i) < HeapVal(base,p)) { + if (HeapVal(base, i) < HeapVal(base, p)) { break; } - Swap(base,p,i); + Swap(base, p, i); i = p; } } diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 1190ee185fd..5ec5cb929d6 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -254,6 +254,16 @@ static void xml_read_film(const XMLReadState& state, pugi::xml_node node) static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node) { Integrator *integrator = state.scene->integrator; + + xml_read_bool(&integrator->progressive, node, "progressive"); + + if(!integrator->progressive) { + xml_read_int(&integrator->diffuse_samples, node, "diffuse_samples"); + xml_read_int(&integrator->glossy_samples, node, "glossy_samples"); + xml_read_int(&integrator->transmission_samples, node, "transmission_samples"); + xml_read_int(&integrator->ao_samples, node, "ao_samples"); + xml_read_int(&integrator->mesh_light_samples, node, "mesh_light_samples"); + } xml_read_int(&integrator->min_bounce, node, "min_bounce"); xml_read_int(&integrator->max_bounce, node, "max_bounce"); @@ -267,8 +277,10 @@ static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node) xml_read_bool(&integrator->transparent_shadows, node, "transparent_shadows"); xml_read_bool(&integrator->no_caustics, node, "no_caustics"); + xml_read_float(&integrator->filter_glossy, node, "blur_glossy"); xml_read_int(&integrator->seed, node, "seed"); + xml_read_float(&integrator->sample_clamp, node, "sample_clamp"); } /* Camera */ diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index b4673ec6206..e2f82096901 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -336,7 +336,7 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): cls.fisheye_fov = FloatProperty( name="Field of View", description="Field of view for the fisheye lens", - min=0.1745, soft_max=2*math.pi, max=10.0*math.pi, + min=0.1745, soft_max=2 * math.pi, max=10.0 * math.pi, subtype='ANGLE', default=math.pi, ) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index bda8249c17e..5234db5255e 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -85,6 +85,7 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel): sub.prop(cscene, "ao_samples", text="AO") sub.prop(cscene, "mesh_light_samples", text="Mesh Light") + class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel): bl_label = "Light Paths" bl_options = {'DEFAULT_CLOSED'} @@ -545,6 +546,7 @@ class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel): if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'): layout.prop(lamp, "color") + class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel): bl_label = "Spot Shape" bl_context = "data" @@ -569,6 +571,7 @@ class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel): col = split.column() col.prop(lamp, "show_cone") + class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel): bl_label = "Surface" bl_context = "world" diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 12d7d00fb61..d09e43bd76d 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -218,7 +218,7 @@ void BlenderSession::render() } buffer_params.passes = passes; - scene->film->passes = passes; + scene->film->tag_passes_update(scene, passes); scene->film->tag_update(scene); scene->integrator->tag_update(scene); diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake index 7d12e261068..23a919530f9 100644 --- a/intern/cycles/cmake/external_libs.cmake +++ b/intern/cycles/cmake/external_libs.cmake @@ -11,10 +11,10 @@ if(WITH_CYCLES_TEST) include_directories(${GLUT_INCLUDE_DIR}) endif() -if(WITH_BUILTIN_GLEW) - set(CYCLES_GLEW_LIBRARY extern_glew) -else() +if(WITH_SYSTEM_GLEW) set(CYCLES_GLEW_LIBRARY ${GLEW_LIBRARY}) +else() + set(CYCLES_GLEW_LIBRARY extern_glew) endif() ########################################################################### diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 035821fadde..fdf25ca7908 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -20,6 +20,7 @@ #include "device.h" #include "film.h" #include "integrator.h" +#include "mesh.h" #include "scene.h" #include "util_algorithm.h" @@ -296,6 +297,16 @@ bool Film::modified(const Film& film) && Pass::equals(passes, film.passes)); } +void Film::tag_passes_update(Scene *scene, const vector<Pass>& passes_) +{ + if(Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) + scene->mesh_manager->tag_update(scene); + else if(Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) + scene->mesh_manager->tag_update(scene); + + passes = passes_; +} + void Film::tag_update(Scene *scene) { need_update = true; diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h index c7d2ee24388..52d1a8428f8 100644 --- a/intern/cycles/render/film.h +++ b/intern/cycles/render/film.h @@ -56,6 +56,7 @@ public: void device_free(Device *device, DeviceScene *dscene); bool modified(const Film& film); + void tag_passes_update(Scene *scene, const vector<Pass>& passes_); void tag_update(Scene *scene); }; diff --git a/intern/elbeem/intern/controlparticles.cpp b/intern/elbeem/intern/controlparticles.cpp index 7f43ba60614..526fac0cc6b 100644 --- a/intern/elbeem/intern/controlparticles.cpp +++ b/intern/elbeem/intern/controlparticles.cpp @@ -665,11 +665,11 @@ int ControlParticles::initFromBinaryFile(string filename) { int ptype=0; float psize=0.0; ntlVec3Gfx ppos,pvel; - gzread(gzf, &ptype, sizeof( ptype )); - gzread(gzf, &psize, sizeof( float )); + gzread(gzf, &ptype, sizeof(ptype)); + gzread(gzf, &psize, sizeof(float)); - for(int j=0; j<3; j++) { gzread(gzf, &ppos[j], sizeof( float )); } - for(int j=0; j<3; j++) { gzread(gzf, &pvel[j], sizeof( float )); } + for (int j=0; j<3; j++) { gzread(gzf, &ppos[j], sizeof(float)); } + for (int j=0; j<3; j++) { gzread(gzf, &pvel[j], sizeof(float)); } ControlParticle p; p.reset(); diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 9dbbb46ce40..703c528bdea 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -40,7 +40,6 @@ #endif #include <libswscale/swscale.h> -#include <libavcodec/opt.h> #if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105)) #define FFMPEG_HAVE_AVIO 1 @@ -76,6 +75,20 @@ #define FFMPEG_FFV1_ALPHA_SUPPORTED #endif +#if ((LIBAVFORMAT_VERSION_MAJOR < 53) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR < 24)) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR < 24) && (LIBAVFORMAT_VERSION_MICRO < 2))) +#define avformat_close_input(x) av_close_input_file(*(x)) +#endif + +#if ((LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR > 32)) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR == 24) && (LIBAVFORMAT_VERSION_MICRO >= 100))) +void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); + +static inline +void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) +{ + ff_update_cur_dts(s, ref_st, timestamp); +} +#endif + #ifndef FFMPEG_HAVE_AVIO #define AVIO_FLAG_WRITE URL_WRONLY #define avio_open url_fopen diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.cpp b/intern/ghost/intern/GHOST_SystemPathsX11.cpp index 95f82fe0e60..cb2e351ab7a 100644 --- a/intern/ghost/intern/GHOST_SystemPathsX11.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsX11.cpp @@ -61,7 +61,7 @@ GHOST_SystemPathsX11::~GHOST_SystemPathsX11() const GHOST_TUns8 *GHOST_SystemPathsX11::getSystemDir(int, const char *versionstr) const { /* no prefix assumes a portable build which only uses bundled scripts */ - if(static_path) { + if (static_path) { static char system_path[PATH_MAX]; snprintf(system_path, sizeof(system_path), "%s/blender/%s", static_path, versionstr); return (GHOST_TUns8*)system_path; @@ -76,10 +76,10 @@ const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *ver /* in blender 2.64, we migrate to XDG. to ensure the copy previous settings * operator works we give a different path depending on the requested version */ - if(version < 264) { + if (version < 264) { const char *home = getenv("HOME"); - if(home) { + if (home) { snprintf(user_path, sizeof(user_path), "%s/.blender/%s", home, versionstr); return (GHOST_TUns8*)user_path; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index a647f82a325..c2456fed800 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -639,8 +639,8 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow) { GHOST_TInt32 x_screen, y_screen; - GHOST_SystemWin32 *system = ((GHOST_SystemWin32 * ) getSystem()); - GHOST_WindowWin32 *window = ( GHOST_WindowWin32 * ) Iwindow; + GHOST_SystemWin32 *system = (GHOST_SystemWin32 *) getSystem(); + GHOST_WindowWin32 *window = (GHOST_WindowWin32 *) Iwindow; system->getCursorPosition(x_screen, y_screen); diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c index 4086fbba730..c32d78f0358 100644 --- a/intern/ghost/test/gears/GHOST_C-Test.c +++ b/intern/ghost/test/gears/GHOST_C-Test.c @@ -526,7 +526,6 @@ int main(int argc, char **argv) /* Dispose the system */ GHOST_DisposeSystem(shSystem); - GHOST_DisposeEventConsumer(consumer); return 0; } diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp index c51b72ad271..d338f11ddde 100644 --- a/intern/ghost/test/gears/GHOST_Test.cpp +++ b/intern/ghost/test/gears/GHOST_Test.cpp @@ -435,7 +435,7 @@ Application::Application(GHOST_ISystem *system) m_secondaryWindow = system->createWindow(title2, 340, 64, 320, 200, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL, false, false); if (!m_secondaryWindow) { - cout << "could not create secondary window\n"; + std::cout << "could not create secondary window\n"; exit(-1); } diff --git a/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp b/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp index 0ec1ccddb15..cfa6a207e1c 100644 --- a/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp +++ b/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp @@ -58,12 +58,12 @@ public: MEM_CacheLimiterCClass(MEM_CacheLimiter_Destruct_Func data_destructor_, MEM_CacheLimiter_DataSize_Func data_size) : data_destructor(data_destructor_), cache(data_size) { } - ~MEM_CacheLimiterCClass(); + ~MEM_CacheLimiterCClass(); handle_t * insert(void * data); void destruct(void * data, - list_t::iterator it); + list_t::iterator it); cache_t * get_cache() { return &cache; @@ -79,9 +79,9 @@ private: class MEM_CacheLimiterHandleCClass { public: MEM_CacheLimiterHandleCClass(void * data_, - MEM_CacheLimiterCClass * parent_) - : data(data_), parent(parent_) { } - ~MEM_CacheLimiterHandleCClass(); + MEM_CacheLimiterCClass * parent_) + : data(data_), parent(parent_) { } + ~MEM_CacheLimiterHandleCClass(); void set_iter(list_t::iterator it_) { it = it_; } diff --git a/intern/raskter/raskter.c b/intern/raskter/raskter.c index 910cd4c6a3d..4552db10ccb 100644 --- a/intern/raskter/raskter.c +++ b/intern/raskter/raskter.c @@ -67,7 +67,8 @@ struct r_fill_context { * just the poly. Since the DEM code could end up being coupled with this, we'll keep it separate * for now. */ -static void preprocess_all_edges(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, struct e_status *open_edge) { +static void preprocess_all_edges(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, struct e_status *open_edge) +{ int i; int xbeg; int ybeg; @@ -165,7 +166,8 @@ static void preprocess_all_edges(struct r_fill_context *ctx, struct poly_vert *v * for speed, but waiting on final design choices for curve-data before eliminating data the DEM code will need * if it ends up being coupled with this function. */ -static int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, float intensity) { +static int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, float intensity) +{ int x_curr; /* current pixel position in X */ int y_curr; /* current scan line being drawn */ int yp; /* y-pixel's position in frame buffer */ @@ -757,18 +759,21 @@ int PLX_raskterize_feather(float (*base_verts)[2], int num_base_verts, float (*f return i; /* Return the value returned by the rasterizer. */ } -int get_range_expanded_pixel_coord(float normalized_value, int max_value) { +int get_range_expanded_pixel_coord(float normalized_value, int max_value) +{ return (int)((normalized_value * (float)(max_value)) + 0.5f); } -float get_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y) { +float get_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y) +{ if(pos_x < 0 || pos_x >= buf_x || pos_y < 0 || pos_y >= buf_y) { return 0.0f; } return buf[(pos_y * buf_y) + buf_x]; } -float get_pixel_intensity_bilinear(float *buf, int buf_x, int buf_y, float u, float v) { +float get_pixel_intensity_bilinear(float *buf, int buf_x, int buf_y, float u, float v) +{ int a; int b; int a_plus_1; @@ -794,14 +799,16 @@ float get_pixel_intensity_bilinear(float *buf, int buf_x, int buf_y, float u, fl } -void set_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y, float intensity) { +void set_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y, float intensity) +{ if(pos_x < 0 || pos_x >= buf_x || pos_y < 0 || pos_y >= buf_y) { return; } buf[(pos_y * buf_y) + buf_x] = intensity; } #define __PLX__FAKE_AA__ -int PLX_antialias_buffer(float *buf, int buf_x, int buf_y) { +int PLX_antialias_buffer(float *buf, int buf_x, int buf_y) +{ #ifdef __PLX__FAKE_AA__ #ifdef __PLX_GREY_AA__ int i=0; diff --git a/release/datafiles/clkernelstoh.py b/release/datafiles/clkernelstoh.py index 8fb5d4e6bae..9c24c9e2d03 100755 --- a/release/datafiles/clkernelstoh.py +++ b/release/datafiles/clkernelstoh.py @@ -61,9 +61,9 @@ fpout.write("const char * clkernelstoh_%s = " % filename) lines = fpin.readlines() for line in lines: - fpout.write("\"") - fpout.write(line.rstrip()) - fpout.write("\\n\" \\\n") + fpout.write("\"") + fpout.write(line.rstrip()) + fpout.write("\\n\" \\\n") fpout.write("\"\\0\";\n") fpin.close() diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 695bb8cb6b6..f90c04eda02 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -183,8 +183,8 @@ def modules(module_cache): del modules_stale mod_list = list(module_cache.values()) - mod_list.sort(key=lambda mod: (mod.bl_info['category'], - mod.bl_info['name'], + mod_list.sort(key=lambda mod: (mod.bl_info["category"], + mod.bl_info["name"], )) return mod_list diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index 097a0296a8e..06c449afd41 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -887,9 +887,9 @@ if __name__ == "__main__": # Example, should be called externally # (class, from, to) replace_ls = [ - ('AnimVizMotionPaths', 'frame_after', 'frame_after'), - ('AnimVizMotionPaths', 'frame_before', 'frame_before'), - ('AnimVizOnionSkinning', 'frame_after', 'frame_after'), + ("AnimVizMotionPaths", "frame_after", "frame_after"), + ("AnimVizMotionPaths", "frame_before", "frame_before"), + ("AnimVizOnionSkinning", "frame_after", "frame_after"), ] update_data_paths(replace_ls) diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py index 5a09f664637..8762ea0e287 100755 --- a/release/scripts/modules/blend_render_info.py +++ b/release/scripts/modules/blend_render_info.py @@ -36,14 +36,14 @@ def read_blend_rend_chunk(path): import struct - blendfile = open(path, 'rb') + blendfile = open(path, "rb") head = blendfile.read(7) if head[0:2] == b'\x1f\x8b': # gzip magic import gzip blendfile.close() - blendfile = gzip.open(path, 'rb') + blendfile = gzip.open(path, "rb") head = blendfile.read(7) if head != b'BLENDER': @@ -80,7 +80,7 @@ def read_blend_rend_chunk(path): scene_name = scene_name[:scene_name.index(b'\0')] try: - scene_name = str(scene_name, 'utf8') + scene_name = str(scene_name, "utf8") except TypeError: pass diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 621484fc896..34b7a9ea7b6 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -63,11 +63,11 @@ def main(): #~ if "-d" in sys.argv: # Enable this to measure start up speed if 0: import cProfile - cProfile.run('import bpy; bpy.utils.load_scripts()', 'blender.prof') + cProfile.run("import bpy; bpy.utils.load_scripts()", "blender.prof") import pstats - p = pstats.Stats('blender.prof') - p.sort_stats('cumulative').print_stats(100) + p = pstats.Stats("blender.prof") + p.sort_stats("cumulative").print_stats(100) else: utils.load_scripts() diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py index d01b706cc37..056fcdb519e 100644 --- a/release/scripts/modules/bpy/ops.py +++ b/release/scripts/modules/bpy/ops.py @@ -74,7 +74,7 @@ class BPyOpsSubMod(object): eg. bpy.ops.object ''' - __keys__ = ('module',) + __keys__ = ("module",) def __init__(self, module): self.module = module @@ -111,7 +111,7 @@ class BPyOpsSubModOp(object): eg. bpy.ops.object.somefunc ''' - __keys__ = ('module', 'func') + __keys__ = ("module", "func") def _get_doc(self): return op_as_string(self.idname()) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 4e8179775d5..da12975e4a6 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -489,7 +489,7 @@ def keyconfig_set(filepath): try: keyfile = open(filepath) - exec(compile(keyfile.read(), filepath, 'exec'), {"__file__": filepath}) + exec(compile(keyfile.read(), filepath, "exec"), {"__file__": filepath}) keyfile.close() except: import traceback diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py index c21b750fd1f..36994d3fddd 100644 --- a/release/scripts/modules/bpy_extras/image_utils.py +++ b/release/scripts/modules/bpy_extras/image_utils.py @@ -71,7 +71,7 @@ def load_image(imagepath, def _image_load_placeholder(path): name = bpy.path.basename(path) if type(name) == bytes: - name = name.decode('utf-8', "replace") + name = name.decode("utf-8", "replace") image = bpy.data.images.new(name, 128, 128) # allow the path to be resolved later image.filepath = path diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index f8b0abd03ea..dbff90c2447 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -171,7 +171,7 @@ def keyconfig_export(wm, kc, filepath): # First add all user_modified keymaps (found in keyconfigs.user.keymaps list), # then add all remaining keymaps from the currently active custom keyconfig. # - # This will create a final list of keymaps that can be used as a 'diff' against + # This will create a final list of keymaps that can be used as a "diff" against # the default blender keyconfig, recreating the current setup from a fresh blender # without needing to export keymaps which haven't been edited. diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index 3ce45154765..fa83b1861d2 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -414,7 +414,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True): fill = tessellate_polygon([[v[0] for v in loop] for loop in loop_list]) #draw_loops(loop_list) - #raise 'done loop' + #raise Exception("done loop") # map to original indices fill = [[vert_map[i] for i in reversed(f)] for f in fill] diff --git a/release/scripts/modules/bpyml_ui.py b/release/scripts/modules/bpyml_ui.py index 4828b3649d3..a7e2e7bc04a 100644 --- a/release/scripts/modules/bpyml_ui.py +++ b/release/scripts/modules/bpyml_ui.py @@ -73,7 +73,7 @@ def _call_recursive(context, base, py_node): value = eval(value, {"context": _bpy.context}) setattr(base, py_node[TAG], value) else: - value = py_node[ARGS]['value'] # have to have this + value = py_node[ARGS]["value"] # have to have this setattr(base, py_node[TAG], value) else: args = _parse_rna_args(base, py_node) diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index 4ddde0de17c..b5985d2c851 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -96,7 +96,10 @@ def get_console(console_id): namespace["__builtins__"] = sys.modules["builtins"] namespace["bpy"] = bpy + + # weak! - but highly convenient namespace["C"] = bpy.context + namespace["D"] = bpy.data replace_help(namespace) @@ -305,6 +308,7 @@ def banner(context): 'OUTPUT') add_scrollback("Convenience Imports: from mathutils import *; " "from math import *", 'OUTPUT') + add_scrollback("Convenience Variables: C = bpy.context, D = bpy.data", 'OUTPUT') add_scrollback("", 'OUTPUT') sc.prompt = PROMPT diff --git a/release/scripts/modules/console_shell.py b/release/scripts/modules/console_shell.py index 772d46c8bf3..c27524ffe44 100644 --- a/release/scripts/modules/console_shell.py +++ b/release/scripts/modules/console_shell.py @@ -20,7 +20,7 @@ import os import bpy -language_id = 'shell' +language_id = "shell" def add_scrollback(text, text_type): diff --git a/release/scripts/modules/graphviz_export.py b/release/scripts/modules/graphviz_export.py index b60952a2f88..88f8b15a728 100644 --- a/release/scripts/modules/graphviz_export.py +++ b/release/scripts/modules/graphviz_export.py @@ -172,7 +172,7 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr fileobject.close() ''' - print(".", end='') + print(".", end="") import sys sys.stdout.flush() ''' diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 4116bfda0c7..7eccda74e14 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -66,9 +66,9 @@ def rna_id_ignore(rna_id): def range_str(val): if val < -10000000: - return '-inf' + return "-inf" elif val > 10000000: - return 'inf' + return "inf" elif type(val) == float: return '%g' % val else: @@ -305,8 +305,8 @@ class InfoPropertyRNA: return type_str def __str__(self): - txt = '' - txt += ' * ' + self.identifier + ': ' + self.description + txt = "" + txt += " * " + self.identifier + ": " + self.description return txt @@ -398,7 +398,7 @@ class InfoOperatorRNA: return None, None -def _GetInfoRNA(bl_rna, cls, parent_id=''): +def _GetInfoRNA(bl_rna, cls, parent_id=""): if bl_rna is None: return None @@ -641,7 +641,7 @@ if __name__ == "__main__": props = [(prop.identifier, prop) for prop in v.properties] for prop_id, prop in sorted(props): - # if prop.type == 'boolean': + # if prop.type == "boolean": # continue prop_type = prop.type if prop.array_length > 0: diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 710035dc29f..5354fd1c776 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -352,7 +352,7 @@ def xml_file_run(context, filepath, rna_map): def xml_file_write(context, filepath, rna_map): - file = open(filepath, 'w', encoding='utf-8') + file = open(filepath, "w", encoding="utf-8") fw = file.write fw("<bpy>\n") diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 0fa80a8f855..6fc50bcfe0d 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -27,7 +27,7 @@ import sys def cutPoint(text, length): - "Returns position of the last space found before 'length' chars" + """Returns position of the last space found before 'length' chars""" l = length c = text[l] while c != ' ': @@ -98,7 +98,7 @@ def write_sysinfo(op): output.write(lilies) ffmpeg = bpy.app.ffmpeg if ffmpeg.supported: - for lib in ['avcodec', 'avdevice', 'avformat', 'avutil', 'swscale']: + for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"): output.write("%r:%r%r\n" % (lib, " " * (10 - len(lib)), getattr(ffmpeg, lib + "_version_string"))) else: diff --git a/release/scripts/presets/interface_theme/back_to_black.xml b/release/scripts/presets/interface_theme/back_to_black.xml index 866c4ab412d..24f135e8548 100644 --- a/release/scripts/presets/interface_theme/back_to_black.xml +++ b/release/scripts/presets/interface_theme/back_to_black.xml @@ -2,7 +2,7 @@ <Theme> <view_3d> <ThemeView3D object_active="#ff8c19" - editmesh_active="#ffffff80" + editmesh_active="#ff020080" act_spline="#db2512" handle_align="#803060" handle_sel_align="#f090a0" @@ -461,7 +461,7 @@ <ThemeTextEditor cursor="#ff0000" syntax_special="#969629" line_numbers_background="#191919" - selected_text="#ffffff" + selected_text="#202020" syntax_builtin="#cf3d99" syntax_comment="#249d60" syntax_numbers="#3c68ff" diff --git a/release/scripts/presets/operator/wm.collada_export/second_life_rigged.py b/release/scripts/presets/operator/wm.collada_export/second_life_rigged.py new file mode 100644 index 00000000000..2c695a22ff9 --- /dev/null +++ b/release/scripts/presets/operator/wm.collada_export/second_life_rigged.py @@ -0,0 +1,16 @@ +import bpy +op = bpy.context.active_operator + +op.apply_modifiers = True +op.export_mesh_type = 0 +op.export_mesh_type_selection = 'view' +op.selected = True +op.include_children = False +op.include_armatures = True +op.deform_bones_only = True +op.active_uv_only = True +op.include_uv_textures = True +op.use_texture_copies = True +op.use_object_instantiation = False +op.sort_by_name = True +op.second_life = True diff --git a/release/scripts/presets/operator/wm.collada_export/second_life.py b/release/scripts/presets/operator/wm.collada_export/second_life_static.py index be9656428ab..081788b7e9d 100644 --- a/release/scripts/presets/operator/wm.collada_export/second_life.py +++ b/release/scripts/presets/operator/wm.collada_export/second_life_static.py @@ -1,10 +1,16 @@ import bpy op = bpy.context.active_operator -op.selected = True op.apply_modifiers = True -op.include_armatures = False +op.export_mesh_type = 0 +op.export_mesh_type_selection = 'view' +op.selected = True op.include_children = False +op.include_armatures = False +op.deform_bones_only = False +op.active_uv_only = True +op.include_uv_textures = True +op.use_texture_copies = True op.use_object_instantiation = False op.sort_by_name = True -op.second_life = True +op.second_life = False diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 5a428467f12..98bad276109 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -227,7 +227,7 @@ class BakeAction(Operator): self.frame_start = scene.frame_start self.frame_end = scene.frame_end self.bake_types = {'POSE'} if context.mode == 'POSE' else {'OBJECT'} - + wm = context.window_manager return wm.invoke_props_dialog(self) diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py index ff87f98658d..82a54077bdc 100644 --- a/release/scripts/startup/bl_operators/console.py +++ b/release/scripts/startup/bl_operators/console.py @@ -77,7 +77,7 @@ class ConsoleBanner(Operator): # default to python if not sc.language: - sc.language = 'python' + sc.language = "python" module = _lang_module_get(sc) banner = getattr(module, "banner", None) diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index fbf0e47f0c8..a2c632a0244 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -34,7 +34,8 @@ class SelectPattern(Operator): pattern = StringProperty( name="Pattern", - description="Name filter using '*', '?' and '[abc]' unix style wildcards", + description="Name filter using '*', '?' and " + "'[abc]' unix style wildcards", maxlen=64, default="*", ) @@ -130,8 +131,8 @@ class SelectCamera(Operator): class SelectHierarchy(Operator): - '''Select object relative to the active object's position ''' \ - '''in the hierarchy''' + """Select object relative to the active object's position """ + """in the hierarchy""" bl_idname = "object.select_hierarchy" bl_label = "Select Hierarchy" bl_options = {'REGISTER', 'UNDO'} @@ -277,8 +278,8 @@ class SubdivisionSet(Operator): class ShapeTransfer(Operator): - '''Copy another selected objects active shape to this one by ''' \ - '''applying the relative offsets''' + """Copy another selected objects active shape to this one by """ + """applying the relative offsets""" bl_idname = "object.shape_key_transfer" bl_label = "Transfer Shape Key" diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index a062ac6f4c5..62844d11443 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -174,6 +174,7 @@ class QuickExplode(Operator): if self.style == 'BLEND' and len(mesh_objects) != 2: self.report({'ERROR'}, "Select two mesh objects") + self.style = 'EXPLODE' return {'CANCELLED'} elif not mesh_objects: self.report({'ERROR'}, "Select at least one mesh object") @@ -241,10 +242,10 @@ class QuickExplode(Operator): if obj == to_obj: tex_slot.alpha_factor = -1.0 elem = tex.color_ramp.elements[1] - elem.color = mat.diffuse_color else: elem = tex.color_ramp.elements[0] - elem.color = mat.diffuse_color + # Keep already defined alpha! + elem.color[:3] = mat.diffuse_color else: tex_slot.use_map_color_diffuse = False diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 4171b8b3c2c..bf5a57fb39a 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8-80 compliant> +# <pep8 compliant> import bpy from bpy.types import Menu, Operator diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 1e18825a155..ac4aa96f655 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -107,7 +107,6 @@ def boundsEdgeLoop(edges): # print len(faces), minx, maxx, miny , maxy for ed in edges: for pt in ed: - print 'ass' x= pt[0] y= pt[1] if x<minx: x= minx @@ -502,7 +501,6 @@ def mergeUvIslands(islandList): It gives about 10% speedup with minimal errors. ''' - #print 'ass' # Move the test along its width + SMALL_NUM #boxLeft += sourceIsland[4] + SMALL_NUM boxLeft += sourceIsland[4] @@ -832,7 +830,7 @@ def main(context, USER_ONLY_SELECTED_FACES = False if not obList: - raise('error, no selected mesh objects') + raise Exception("error, no selected mesh objects") # Reuse variable if len(obList) == 1: diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 4d95c2d5d03..fc19a989032 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -138,7 +138,7 @@ def execute_context_assign(self, context): class BRUSH_OT_active_index_set(Operator): - '''Set active sculpt/paint brush from it's number''' + """Set active sculpt/paint brush from it's number""" bl_idname = "brush.active_index_set" bl_label = "Set Brush Number" @@ -371,8 +371,8 @@ class WM_OT_context_toggle_enum(Operator): class WM_OT_context_cycle_int(Operator): - '''Set a context value. Useful for cycling active material, ''' - '''vertex keys, groups' etc''' + """Set a context value. Useful for cycling active material, """ + """vertex keys, groups' etc""" bl_idname = "wm.context_cycle_int" bl_label = "Context Int Cycle" bl_options = {'UNDO', 'INTERNAL'} @@ -799,7 +799,6 @@ class WM_OT_path_open(Operator): return {'FINISHED'} - def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""): id_split = doc_id.split(".") url = rna = None @@ -832,7 +831,7 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""): url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop)) else: rna = ("bpy.types.%s.%s" % (class_name, class_prop)) - + return url if do_url else rna @@ -1061,7 +1060,7 @@ class WM_OT_properties_edit(Operator): prop_ui["soft_min"] = prop_ui["min"] = prop_type(self.min) prop_ui["soft_max"] = prop_ui["max"] = prop_type(self.max) - prop_ui['description'] = self.description + prop_ui["description"] = self.description # otherwise existing buttons which reference freed # memory may crash blender [#26510] @@ -1597,10 +1596,11 @@ class WM_OT_addon_disable(Operator): addon_utils.disable(self.module) return {'FINISHED'} + class WM_OT_theme_install(Operator): "Install a theme" bl_idname = "wm.theme_install" - bl_label = "Install Theme..." + bl_label = "Install Theme..." overwrite = BoolProperty( name="Overwrite", @@ -1624,10 +1624,10 @@ class WM_OT_theme_install(Operator): import os import shutil import traceback - + xmlfile = self.filepath - path_themes = bpy.utils.user_resource('SCRIPTS','presets/interface_theme',create=True) + path_themes = bpy.utils.user_resource('SCRIPTS', "presets/interface_theme", create=True) if not path_themes: self.report({'ERROR'}, "Failed to get themes path") @@ -1642,7 +1642,7 @@ class WM_OT_theme_install(Operator): try: shutil.copyfile(xmlfile, path_dest) - bpy.ops.script.execute_preset(filepath=path_dest,menu_idname="USERPREF_MT_interface_theme_presets") + bpy.ops.script.execute_preset(filepath=path_dest, menu_idname="USERPREF_MT_interface_theme_presets") except: traceback.print_exc() @@ -1650,7 +1650,6 @@ class WM_OT_theme_install(Operator): return {'FINISHED'} - def invoke(self, context, event): wm = context.window_manager wm.fileselect_add(self) diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py index 0f09893647a..e6d9affee93 100644 --- a/release/scripts/startup/bl_ui/properties_data_bone.py +++ b/release/scripts/startup/bl_ui/properties_data_bone.py @@ -120,13 +120,13 @@ class BONE_PT_transform_locks(BoneButtonsPanel, Panel): pchan = ob.pose.bones[bone.name] split = layout.split(percentage=0.1) - + col = split.column(align=True) col.label(text="") col.label(text="X:") col.label(text="Y:") col.label(text="Z:") - + col = split.row() sub = col.row() sub.active = not (bone.parent and bone.use_connect) @@ -137,7 +137,7 @@ class BONE_PT_transform_locks(BoneButtonsPanel, Panel): if pchan.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}: row = layout.row() row.prop(pchan, "lock_rotations_4d", text="Lock Rotation") - + sub = row.row() sub.active = pchan.lock_rotations_4d sub.prop(pchan, "lock_rotation_w", text="W") diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 6a7415f7cec..87ac56c1104 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -406,7 +406,7 @@ class DATA_PT_text_boxes(CurveButtonsPanel, Panel): col.prop(box, "x", text="X") col.prop(box, "y", text="Y") - row.operator("font.textbox_remove", text='', icon='X', emboss=False).index = i + row.operator("font.textbox_remove", text="", icon='X', emboss=False).index = i class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 2e980f776a1..abcd27c308e 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -969,7 +969,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.label(text="Selected Vertices:") split = layout.split() - + col = split.column(align=True) col.operator("object.skin_loose_mark_clear", text="Mark Loose").action = "MARK" col.operator("object.skin_loose_mark_clear", text="Clear Loose").action = "CLEAR" @@ -983,6 +983,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "use_x_symmetry") col.prop(md, "use_y_symmetry") col.prop(md, "use_z_symmetry") - + if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index 549e2181a2b..0b6e4154050 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -50,6 +50,8 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel): physics_type = game.physics_type if physics_type == 'CHARACTER': + layout.prop(game, "use_actor") + layout.prop(ob, "hide_render", text="Invisible") # out of place but useful layout.prop(game, "step_height", slider=True) layout.prop(game, "jump_speed") layout.prop(game, "fall_speed") diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 87c62e2791f..3c30f27f16b 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -105,13 +105,13 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel): ob = context.object split = layout.split(percentage=0.1) - + col = split.column(align=True) col.label(text="") col.label(text="X:") col.label(text="Y:") col.label(text="Z:") - + col = split.row() col.column().prop(ob, "lock_location", text="Location") col.column().prop(ob, "lock_rotation", text="Rotation") @@ -120,7 +120,7 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel): if ob.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}: row = layout.row() row.prop(ob, "lock_rotations_4d", text="Lock Rotation") - + sub = row.row() sub.active = ob.lock_rotations_4d sub.prop(ob, "lock_rotation_w", text="W") diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 9200c688394..a667125d4ea 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -841,7 +841,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): row = layout.row() row.prop(part, "use_simplify_viewport") sub = row.row() - sub.active = part.viewport == True + sub.active = part.use_simplify_viewport == True sub.prop(part, "simplify_viewport") elif part.render_type == 'OBJECT': diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index a0b0a9d4232..139481c53a4 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -1082,7 +1082,7 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel): if ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}: split.prop(ffmpeg, "codec") elif rd.ffmpeg.format == 'H264': - split.prop(ffmpeg, 'use_lossless_output') + split.prop(ffmpeg, "use_lossless_output") else: split.label() @@ -1131,7 +1131,7 @@ class RENDER_PT_bake(RenderButtonsPanel, Panel): multires_bake = False if rd.bake_type in ['NORMALS', 'DISPLACEMENT']: - layout.prop(rd, 'use_bake_multires') + layout.prop(rd, "use_bake_multires") multires_bake = rd.use_bake_multires if not multires_bake: diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index af8fcc6cbdc..c9c9c36217b 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -165,7 +165,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel): row.label(text="Array Target:") row.prop(ksp, "use_entire_array", text="All Items") if ksp.use_entire_array: - row.label(text=" ") # padding + row.label(text=" ") # padding else: row.prop(ksp, "array_index", text="Index") @@ -177,7 +177,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel): col.prop(ksp, "group_method", text="") if ksp.group_method == 'NAMED': col.prop(ksp, "group") - + col = row.column(align=True) col.label(text="Keyframing Settings:") col.prop(ksp, "bl_options") diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 1d5e96cf701..5bde9538e54 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -23,6 +23,7 @@ from bpy.types import Menu, Panel from bpy.types import (Brush, Lamp, Material, + Object, ParticleSettings, Texture, World) @@ -80,6 +81,15 @@ def context_tex_datablock(context): return idblock +def id_tex_datablock(bid): + if isinstance(bid, Object): + if bid.type == 'LAMP': + return bid.data + return bid.active_material + + return bid + + class TextureButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' @@ -114,7 +124,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel): pin_id = space.pin_id if space.use_pin_id and not isinstance(pin_id, Texture): - idblock = pin_id + idblock = id_tex_datablock(pin_id) pin_id = None if not space.use_pin_id: diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index a77302ff4ae..374588939e2 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -48,7 +48,7 @@ class CLIP_HT_header(Header): sub.menu("CLIP_MT_clip") row = layout.row() - row.template_ID(sc, "clip", open='clip.open') + row.template_ID(sc, "clip", open="clip.open") if clip: tracking = clip.tracking @@ -95,7 +95,8 @@ class CLIP_HT_header(Header): row = layout.row(align=True) row.prop(dopesheet, "sort_method", text="") - row.prop(dopesheet, "use_invert_sort", text="Invert", toggle=True) + row.prop(dopesheet, "use_invert_sort", + text="Invert", toggle=True) else: layout.prop(sc, "view", text="", expand=True) @@ -121,7 +122,7 @@ class CLIP_HT_header(Header): sub.menu("CLIP_MT_clip") row = layout.row() - row.template_ID(sc, "clip", open='clip.open') + row.template_ID(sc, "clip", open="clip.open") layout.prop(sc, "mode", text="") @@ -255,7 +256,7 @@ class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel): col.prop(settings, "default_pattern_match", text="") col.separator() - col.operator('clip.track_settings_as_default', + col.operator("clip.track_settings_as_default", text="Copy From Active Track") @@ -340,9 +341,9 @@ class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel): layout.operator("clip.clean_tracks") - layout.prop(settings, 'clean_frames', text="Frames") - layout.prop(settings, 'clean_error', text="Error") - layout.prop(settings, 'clean_action', text="") + layout.prop(settings, "clean_frames", text="Frames") + layout.prop(settings, "clean_error", text="Error") + layout.prop(settings, "clean_action", text="") class CLIP_PT_tools_geometry(CLIP_PT_reconstruction_panel, Panel): @@ -553,7 +554,8 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel): row.separator() sub = row.row() - sub.prop(act_track, "use_alpha_preview", text="", toggle=True, icon='IMAGE_ALPHA') + sub.prop(act_track, "use_alpha_preview", + text="", toggle=True, icon='IMAGE_ALPHA') layout.separator() @@ -735,7 +737,9 @@ class CLIP_PT_active_mask_point(Panel): mask = sc.mask if mask and sc.mode == 'MASKEDIT': - return mask.layers.active and mask.layers.active.splines.active_point + mask_layer_active = mask.layers.active + return (mask_layer_active and + mask_layer_active.splines.active_point) return False @@ -979,7 +983,7 @@ class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel): layout.prop(clip.proxy, "quality") - layout.prop(clip, 'use_proxy_custom_directory') + layout.prop(clip, "use_proxy_custom_directory") if clip.use_proxy_custom_directory: layout.prop(clip.proxy, "directory") @@ -1053,7 +1057,8 @@ class CLIP_MT_view(Menu): for a, b in ratios: text = "Zoom %d:%d" % (a, b) - layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b + layout.operator("clip.view_zoom_ratio", + text=text).ratio = a / b else: layout.prop(sc, "show_seconds") layout.separator() @@ -1203,16 +1208,20 @@ class CLIP_MT_select(Menu): layout.separator() - layout.operator("mask.select_all").action = 'TOGGLE' - layout.operator("mask.select_all", text="Inverse").action = 'INVERT' + layout.operator("mask.select_all" + ).action = 'TOGGLE' + layout.operator("mask.select_all", + text="Inverse").action = 'INVERT' else: layout.operator("clip.select_border") layout.operator("clip.select_circle") layout.separator() - layout.operator("clip.select_all").action = 'TOGGLE' - layout.operator("clip.select_all", text="Inverse").action = 'INVERT' + layout.operator("clip.select_all" + ).action = 'TOGGLE' + layout.operator("clip.select_all", + text="Inverse").action = 'INVERT' layout.menu("CLIP_MT_select_grouped") @@ -1317,6 +1326,7 @@ class CLIP_MT_mask_animation(Menu): layout.operator("mask.shape_key_clear") layout.operator("mask.shape_key_insert") layout.operator("mask.shape_key_feather_reset") + layout.operator("mask.shape_key_rekey") class CLIP_MT_camera_presets(Menu): @@ -1349,7 +1359,7 @@ class CLIP_MT_track_color_specials(Menu): def draw(self, context): layout = self.layout - layout.operator('clip.track_copy_color', icon='COPY_ID') + layout.operator("clip.track_copy_color", icon='COPY_ID') class CLIP_MT_stabilize_2d_specials(Menu): @@ -1358,7 +1368,7 @@ class CLIP_MT_stabilize_2d_specials(Menu): def draw(self, context): layout = self.layout - layout.operator('clip.stabilize_2d_select') + layout.operator("clip.stabilize_2d_select") if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 9cf4a337483..8ddb2df352a 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -371,16 +371,16 @@ class INFO_MT_help(Menu): def draw(self, context): layout = self.layout - layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:2.6/Manual' - layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-263/' + layout.operator("wm.url_open", text="Manual", icon='HELP').url = "http://wiki.blender.org/index.php/Doc:2.6/Manual" + layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-263" layout.separator() - layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/' - layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = 'http://www.blender.org/e-shop' - layout.operator("wm.url_open", text="Developer Community", icon='URL').url = 'http://www.blender.org/community/get-involved/' - layout.operator("wm.url_open", text="User Community", icon='URL').url = 'http://www.blender.org/community/user-community/' + layout.operator("wm.url_open", text="Blender Website", icon='URL').url = "http://www.blender.org" + layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = "http://www.blender.org/e-shop" + layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/community/get-involved" + layout.operator("wm.url_open", text="User Community", icon='URL').url = "http://www.blender.org/community/user-community" layout.separator() - layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = 'http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse' + layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse" layout.separator() layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index b4100819ab0..70f0f300f86 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -205,6 +205,7 @@ class NODE_PT_properties(Panel): col.prop(snode, "backdrop_y", text="Y") col.operator("node.backimage_move", text="Move") + class NODE_PT_quality(bpy.types.Panel): bl_space_type = 'NODE_EDITOR' bl_region_type = 'UI' @@ -225,7 +226,7 @@ class NODE_PT_quality(bpy.types.Panel): layout.prop(tree, "chunk_size") layout.prop(tree, "use_opencl") - + class NODE_MT_node_color_presets(Menu): """Predefined node color""" bl_label = "Color Presets" @@ -240,8 +241,8 @@ class NODE_MT_node_color_specials(Menu): def draw(self, context): layout = self.layout - layout.operator('node.node_copy_color', icon='COPY_ID') + layout.operator("node.node_copy_color", icon='COPY_ID') + - if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 276e8e5ae1d..76053987843 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -256,7 +256,7 @@ class SEQUENCER_MT_strip(Menu): layout.operator("sequencer.rebuild_proxy") layout.separator() - layout.operator("sequencer.duplicate") + layout.operator("sequencer.duplicate_move") layout.operator("sequencer.delete") strip = act_strip(context) @@ -352,7 +352,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): def draw(self, context): layout = self.layout - + scene = context.scene frame_current = scene.frame_current strip = act_strip(context) @@ -474,7 +474,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): elif strip.type == 'TRANSFORM': layout = self.layout col = layout.column() - + col.prop(strip, "interpolation") col.prop(strip, "translation_unit") col = layout.column(align=True) @@ -483,7 +483,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): col.prop(strip, "translate_start_y", text="Y") layout.separator() - + col = layout.column(align=True) col.prop(strip, "use_uniform_scale") if (strip.use_uniform_scale): @@ -568,10 +568,10 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): split = layout.split(percentage=0.2) split.label(text="Path:") split.prop(strip, "filepath", text="") - + layout.prop(strip, "mpeg_preseek") layout.prop(strip, "stream_index") - + layout.prop(strip, "use_translation", text="Image Offset") if strip.use_translation: col = layout.column(align=True) @@ -740,13 +740,13 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): col = layout.column() col.label(text="Distortion:") col.prop(strip, "undistort") - + split = layout.split(percentage=0.65) col = split.column() col.prop(strip, "use_reverse_frames", text="Backwards") col.prop(strip, "use_deinterlace") - + col = split.column() col.label(text="Flip:") col.prop(strip, "use_flip_x", text="X") diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 2d349931dc4..7a147bac38c 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -245,7 +245,7 @@ class USERPREF_PT_interface(Panel): col.prop(view, "show_splash") - if os.name == 'nt': + if os.name == "nt": col.prop(view, "quit_dialog") @@ -419,7 +419,7 @@ class USERPREF_PT_system(Panel): col.separator() col.separator() - if hasattr(system, 'compute_device'): + if hasattr(system, "compute_device"): col.label(text="Compute Device:") col.row().prop(system, "compute_device_type", expand=True) sub = col.row() @@ -1094,7 +1094,7 @@ class USERPREF_PT_addons(Panel): rowsub = row.row() rowsub.active = is_enabled - rowsub.label(text='%s: %s' % (info['category'], info["name"])) + rowsub.label(text='%s: %s' % (info["category"], info["name"])) if info["warning"]: rowsub.label(icon='ERROR') diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 2b3df32aeaf..0f756913cdb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -979,7 +979,9 @@ class VIEW3D_MT_object_group(Menu): layout = self.layout layout.operator("group.create") + # layout.operator_menu_enum("group.objects_remove", "group") # BUGGY layout.operator("group.objects_remove") + layout.operator("group.objects_remove_all") layout.separator() @@ -2401,7 +2403,7 @@ class VIEW3D_PT_view3d_display(Panel): col.prop(gs, "material_mode", text="") col.prop(view, "show_textured_solid") - col.prop(view, "show_backface_culling") + col.prop(view, "show_backface_culling") layout.separator() @@ -2568,7 +2570,7 @@ class VIEW3D_PT_background_image(Panel): has_bg = True elif bg.source == 'MOVIE_CLIP': - box.prop(bg, 'use_camera_clip') + box.prop(bg, "use_camera_clip") column = box.column() column.active = not bg.use_camera_clip diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index a1f616cc237..f3365da6ad6 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -676,6 +676,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row.prop(brush, "jitter", slider=True) row.prop(brush, "use_pressure_jitter", toggle=True, text="") + col.prop(brush, "vertex_tool", text="Blend") + # Vertex Paint Mode # elif context.vertex_paint_object and brush: col = layout.column() @@ -695,6 +697,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): #row.prop(brush, "jitter", slider=True) #row.prop(brush, "use_pressure_jitter", toggle=True, text="") + col.prop(brush, "vertex_tool", text="Blend") + class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel): bl_label = "Texture" @@ -987,7 +991,7 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel): col.prop(mesh, "use_mirror_topology") col.prop(wpaint, "input_samples") - + self.unified_paint_settings(col, context) # Commented out because the Apply button isn't an operator yet, making these settings useless @@ -1138,7 +1142,7 @@ class VIEW3D_MT_tools_projectpaint_stencil(Menu): class VIEW3D_PT_tools_particlemode(View3DPanel, Panel): - '''default tools for particle mode''' + """default tools for particle mode""" bl_context = "particlemode" bl_label = "Options" diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index e00982bae72..3d04db56d43 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -452,7 +452,7 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) return AVI_ERROR_FORMAT; } - movie->header = (AviMainHeader *) MEM_mallocN(sizeof (AviMainHeader), "movieheader"); + movie->header = (AviMainHeader *) MEM_mallocN(sizeof(AviMainHeader), "movieheader"); if (GET_FCC(movie->fp) != FCC("AVI ") || GET_FCC(movie->fp) != FCC("LIST") || @@ -769,7 +769,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) if (movie->fp == NULL) return AVI_ERROR_OPEN; - movie->offset_table = (int64_t *) MEM_mallocN((1 + streams * 2) * sizeof (int64_t), "offsettable"); + movie->offset_table = (int64_t *) MEM_mallocN((1 + streams * 2) * sizeof(int64_t), "offsettable"); for (i = 0; i < 1 + streams * 2; i++) movie->offset_table[i] = -1L; diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index faa996b9888..5fe28d2b254 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 11 +#define BLENDER_SUBVERSION 13 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index baa530c0599..e2263a5edb7 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -70,6 +70,7 @@ char BKE_imtype_valid_depths(const char imtype); char BKE_imtype_from_arg(const char *arg); void BKE_imformat_defaults(struct ImageFormatData *im_format); +void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf); struct anim *openanim(const char *name, int flags, int streamindex); diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 0e93869a8b0..0682b16536c 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -122,6 +122,7 @@ void BKE_mask_update_display(struct Mask *mask, float ctime); void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe); void BKE_mask_evaluate(struct Mask *mask, const float ctime, const int do_newframe); +void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const int do_newframe); void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe); void BKE_mask_parent_init(struct MaskParent *parent); void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u); @@ -170,7 +171,8 @@ void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, i /* rasterization */ int BKE_mask_get_duration(struct Mask *mask); void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, int do_mask_aa); + const short do_aspect_correct, const short do_mask_aa, + const short do_feather); #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT) #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT) diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 221ae99a0ec..739b63ca174 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -63,8 +63,8 @@ void BKE_movieclip_get_cache_segments(struct MovieClip *clip, struct MovieClipUs void BKE_movieclip_build_proxy_frame(struct MovieClip *clip, int clip_flag, struct MovieDistortion *distortion, int cfra, int *build_sizes, int build_count, int undistorted); -int BKE_movieclip_remap_scene_to_clip_frame(struct MovieClip *clip, int framenr); -int BKE_movieclip_remap_clip_to_scene_frame(struct MovieClip *clip, int framenr); +float BKE_movieclip_remap_scene_to_clip_frame(struct MovieClip *clip, float framenr); +float BKE_movieclip_remap_clip_to_scene_frame(struct MovieClip *clip, float framenr); /* cacheing flags */ #define MOVIECLIP_CACHE_SKIP (1 << 0) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index d26a722b628..35bf4c0961f 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1627,7 +1627,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, int nextLvl = curLvl + 1; int ptrIdx, cornerIdx, i; int vertDataSize = ss->meshIFC.vertDataSize; - void *q = ss->q, *r = ss->r; + float *q = ss->q, *r = ss->r; #pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { @@ -1642,11 +1642,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, for (x = 0; x < gridSize - 1; x++) { int fx = 1 + 2 * x; int fy = 1 + 2 * y; - void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0); - void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0); - void *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1); - void *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1); - void *co = FACE_getIFCo(f, nextLvl, S, fx, fy); + const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0); + const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0); + const float *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1); + const float *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1); + float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); VertDataAvg4(co, co0, co1, co2, co3, ss); } @@ -1660,11 +1660,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, for (S = 0; S < f->numVerts; S++) { for (x = 0; x < gridSize - 1; x++) { int fx = x * 2 + 1; - void *co0 = FACE_getIECo(f, curLvl, S, x + 0); - void *co1 = FACE_getIECo(f, curLvl, S, x + 1); - void *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx); - void *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1); - void *co = FACE_getIECo(f, nextLvl, S, fx); + const float *co0 = FACE_getIECo(f, curLvl, S, x + 0); + const float *co1 = FACE_getIECo(f, curLvl, S, x + 1); + const float *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx); + const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1); + float *co = FACE_getIECo(f, nextLvl, S, fx); VertDataAvg4(co, co0, co1, co2, co3, ss); } @@ -1679,11 +1679,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, for (y = 0; y < gridSize - 1; y++) { int fx = x * 2; int fy = y * 2 + 1; - void *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0); - void *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1); - void *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy); - void *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy); - void *co = FACE_getIFCo(f, nextLvl, S, fx, fy); + const float *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0); + const float *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1); + const float *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy); + const float *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy); + float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); VertDataAvg4(co, co0, co1, co2, co3, ss); } @@ -1694,11 +1694,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, for (x = 0; x < gridSize - 1; x++) { int fx = x * 2 + 1; int fy = y * 2; - void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y); - void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y); - void *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1); - void *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1); - void *co = FACE_getIFCo(f, nextLvl, S, fx, fy); + const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y); + const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y); + const float *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1); + const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1); + float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); VertDataAvg4(co, co0, co1, co2, co3, ss); } @@ -1718,9 +1718,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, if (_edge_isBoundary(e) || sharpness > 1.0f) { for (x = 0; x < edgeSize - 1; x++) { int fx = x * 2 + 1; - void *co0 = EDGE_getCo(e, curLvl, x + 0); - void *co1 = EDGE_getCo(e, curLvl, x + 1); - void *co = EDGE_getCo(e, nextLvl, fx); + const float *co0 = EDGE_getCo(e, curLvl, x + 0); + const float *co1 = EDGE_getCo(e, curLvl, x + 1); + float *co = EDGE_getCo(e, nextLvl, fx); VertDataCopy(co, co0, ss); VertDataAdd(co, co1, ss); @@ -1730,9 +1730,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, else { for (x = 0; x < edgeSize - 1; x++) { int fx = x * 2 + 1; - void *co0 = EDGE_getCo(e, curLvl, x + 0); - void *co1 = EDGE_getCo(e, curLvl, x + 1); - void *co = EDGE_getCo(e, nextLvl, fx); + const float *co0 = EDGE_getCo(e, curLvl, x + 0); + const float *co1 = EDGE_getCo(e, curLvl, x + 1); + float *co = EDGE_getCo(e, nextLvl, fx); int numFaces = 0; VertDataCopy(q, co0, ss); @@ -1766,8 +1766,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, */ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = (CCGVert *) effectedV[ptrIdx]; - void *co = VERT_getCo(v, curLvl); - void *nCo = VERT_getCo(v, nextLvl); + const float *co = VERT_getCo(v, curLvl); + float *nCo = VERT_getCo(v, nextLvl); int sharpCount = 0, allSharp = 1; float avgSharpness = 0.0; int j, seam = VERT_seam(v), seamEdges = 0; @@ -1878,11 +1878,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, /* r = co * 0.75 + q * 0.25 */ VertDataCopy(r, co, ss); - VertDataMulN(r, .75f, ss); - VertDataMulN(q, .25f, ss); + VertDataMulN(r, 0.75f, ss); + VertDataMulN(q, 0.25f, ss); VertDataAdd(r, q, ss); - /* nCo = nCo + (r - nCo) * avgSharpness */ + /* nCo = nCo + (r - nCo) * avgSharpness */ VertDataSub(r, nCo, ss); VertDataMulN(r, avgSharpness, ss); VertDataAdd(nCo, r, ss); @@ -1914,14 +1914,18 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, avgSharpness = 0; } - if (_edge_isBoundary(e) && (!e->numFaces || sharpCount < 2)) { + if (_edge_isBoundary(e)) { for (x = 1; x < edgeSize - 1; x++) { int fx = x * 2; - void *co = EDGE_getCo(e, curLvl, x); - void *nCo = EDGE_getCo(e, nextLvl, fx); + const float *co = EDGE_getCo(e, curLvl, x); + float *nCo = EDGE_getCo(e, nextLvl, fx); + + /* Average previous level's endpoints */ VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1), ss); VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1), ss); VertDataMulN(r, 0.5f, ss); + + /* nCo = nCo * 0.75 + r * 0.25 */ VertDataCopy(nCo, co, ss); VertDataMulN(nCo, 0.75f, ss); VertDataMulN(r, 0.25f, ss); @@ -1931,8 +1935,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, else { for (x = 1; x < edgeSize - 1; x++) { int fx = x * 2; - void *co = EDGE_getCo(e, curLvl, x); - void *nCo = EDGE_getCo(e, nextLvl, fx); + const float *co = EDGE_getCo(e, curLvl, x); + float *nCo = EDGE_getCo(e, nextLvl, fx); int numFaces = 0; VertDataZero(q, ss); @@ -1974,7 +1978,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, #pragma omp parallel private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) { - void *q, *r; + float *q, *r; #pragma omp critical { @@ -2018,8 +2022,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, for (y = 1; y < gridSize - 1; y++) { int fx = x * 2; int fy = y * 2; - void *co = FACE_getIFCo(f, curLvl, S, x, y); - void *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy); + const float *co = FACE_getIFCo(f, curLvl, S, x, y); + float *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy); VertDataAvg4(q, FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1), @@ -2049,8 +2053,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, */ for (x = 1; x < gridSize - 1; x++) { int fx = x * 2; - void *co = FACE_getIECo(f, curLvl, S, x); - void *nCo = FACE_getIECo(f, nextLvl, S, fx); + const float *co = FACE_getIECo(f, curLvl, S, x); + float *nCo = FACE_getIECo(f, nextLvl, S, fx); VertDataAvg4(q, FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1), @@ -2106,7 +2110,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss); VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss); for (x = 1; x < gridSize - 1; x++) { - void *co = FACE_getIECo(f, nextLvl, S, x); + float *co = FACE_getIECo(f, nextLvl, S, x); VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co, ss); VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co, ss); } @@ -2327,7 +2331,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataMulN(q, 0.25f, ss); VertDataAdd(r, q, ss); - /* nCo = nCo + (r - nCo) * avgSharpness */ + /* nCo = nCo + (r - nCo) * avgSharpness */ VertDataSub(r, nCo, ss); VertDataMulN(r, avgSharpness, ss); VertDataAdd(nCo, r, ss); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9af1d5f52c4..96959398bc2 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1588,7 +1588,11 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { pchanp = BKE_pose_channel_find_name(frompose, pchan->name); - if (pchan->bone->layer & layer_protected) { + if (UNLIKELY(pchanp == NULL)) { + /* happens for proxies that become invalid because of a missing link + * for regulat cases it shouldn't happen at all */ + } + else if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; /* copy posechannel to temp, but restore important pointers */ diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 014b3f5e40b..edb3120cf87 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -920,7 +920,8 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa) return state; } -//static int boid_condition_is_true(BoidCondition *cond) { +//static int boid_condition_is_true(BoidCondition *cond) +//{ // /* TODO */ // return 0; //} diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b681426f8a7..f9e72be4fc1 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -106,7 +106,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ); * ******************************************************************************/ /** - * cloth_init - creates a new cloth simulation. + * cloth_init - creates a new cloth simulation. * * 1. create object * 2. fill object with standard values or with the GUI settings if given @@ -821,8 +821,9 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { if ( dvert->dw[j].def_nr == (clmd->coll_parms->vgroup_selfcol-1)) { - if( dvert->dw [j].weight > 0.0) + if (dvert->dw [j].weight > 0.0f) { verts->flags |= CLOTH_VERT_FLAG_NOSELFCOLL; + } } } /* @@ -1007,7 +1008,7 @@ int cloth_add_spring(ClothModifierData *clmd, unsigned int indexA, unsigned int if (cloth) { // TODO: look if this spring is already there - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) return 0; @@ -1079,7 +1080,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) cloth->springs = NULL; - edgelist = MEM_callocN ( sizeof ( LinkNode * ) * numverts, "cloth_edgelist_alloc" ); + edgelist = MEM_callocN ( sizeof (LinkNode *) * numverts, "cloth_edgelist_alloc" ); if (!edgelist) return 0; @@ -1096,7 +1097,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) // structural springs for ( i = 0; i < numedges; i++ ) { - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if ( spring ) { spring->ij = MIN2(medge[i].v1, medge[i].v2); @@ -1154,7 +1155,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) // if ( mface[i].v4 ) --> Quad face - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); @@ -1192,7 +1193,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)) && (index2 != tspring2->ij)) { - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); @@ -1229,7 +1230,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) tspring2 = search2->link; if (tspring->ij == tspring2->kl) { - spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); + spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 44f524304d2..1bd650ef568 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -643,12 +643,12 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis { int i; - *collisions = ( CollPair* ) MEM_mallocN ( sizeof ( CollPair ) * numresult * 64, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision + *collisions = (CollPair *) MEM_mallocN(sizeof(CollPair) * numresult * 64, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision *collisions_index = *collisions; for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, - overlap+i, *collisions_index, dt ); + overlap+i, *collisions_index, dt ); } } @@ -841,9 +841,11 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo } } - if( ( cloth->verts[i].flags & CLOTH_VERT_FLAG_NOSELFCOLL ) || - ( cloth->verts[j].flags & CLOTH_VERT_FLAG_NOSELFCOLL ) ) + if ((cloth->verts[i].flags & CLOTH_VERT_FLAG_NOSELFCOLL) || + (cloth->verts[j].flags & CLOTH_VERT_FLAG_NOSELFCOLL)) + { continue; + } sub_v3_v3v3(temp, verts[i].tx, verts[j].tx); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 623d4b8a931..674a2d98d07 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1713,7 +1713,7 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si t02 = x1 * x2 + y1 * y2; if (fabs(t02) >= 1.0) - t02 = .5 * M_PI; + t02 = 0.5 * M_PI; else t02 = (saacos(t02)) / 2.0f; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index eaf4c898b86..ea396b6d88c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -32,7 +32,7 @@ #include <string.h> #include <fcntl.h> #include <math.h> -#ifndef WIN32 +#ifndef WIN32 #include <unistd.h> #else #include <io.h> @@ -112,25 +112,25 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { struct ImBuf *tbuf1, *tbuf2; - + if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; ibuf->flags |= IB_fields; - + if (ibuf->rect) { /* make copies */ tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect); tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect); - + ibuf->x *= 2; - + IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - + ibuf->x /= 2; IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y); IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y); - + IMB_freeImBuf(tbuf1); IMB_freeImBuf(tbuf2); } @@ -140,25 +140,25 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ { struct ImBuf *tbuf1, *tbuf2; - + if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; ibuf->flags |= IB_fields; - + if (ibuf->rect) { /* make copies */ tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect); tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect); - + ibuf->x *= 2; - + IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - + ibuf->x /= 2; IMB_rectcpy(ibuf, tbuf2, 0, 0, 0, 0, tbuf2->x, tbuf2->y); IMB_rectcpy(ibuf, tbuf1, 0, tbuf2->y, 0, 0, tbuf1->x, tbuf1->y); - + IMB_freeImBuf(tbuf1); IMB_freeImBuf(tbuf2); } @@ -181,27 +181,27 @@ void BKE_image_de_interlace(Image *ima, int odd) static void image_free_buffers(Image *ima) { ImBuf *ibuf; - + while ((ibuf = ima->ibufs.first)) { BLI_remlink(&ima->ibufs, ibuf); - + if (ibuf->userdata) { MEM_freeN(ibuf->userdata); ibuf->userdata = NULL; } IMB_freeImBuf(ibuf); } - + if (ima->anim) IMB_free_anim(ima->anim); ima->anim = NULL; if (ima->rr) { RE_FreeRenderResult(ima->rr); ima->rr = NULL; - } - + } + GPU_free_image(ima); - + ima->ok = IMA_OK; } @@ -232,16 +232,16 @@ void BKE_image_free(Image *ima) static Image *image_alloc(const char *name, short source, short type) { Image *ima; - + ima = BKE_libblock_alloc(&G.main->image, ID_IM, name); if (ima) { ima->ok = IMA_OK; - + ima->xrep = ima->yrep = 1; ima->aspx = ima->aspy = 1.0; ima->gen_x = 1024; ima->gen_y = 1024; ima->gen_type = 1; /* no defines yet? */ - + ima->source = source; ima->type = type; } @@ -283,10 +283,10 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) { if (ibuf) { ImBuf *link; - + if (index != IMA_NO_INDEX) index = IMA_MAKE_INDEX(frame, index); - + /* insert based on index */ for (link = ima->ibufs.first; link; link = link->next) if (link->index >= index) @@ -316,7 +316,7 @@ Image *BKE_image_copy(Image *ima) nima->flag = ima->flag; nima->tpageflag = ima->tpageflag; - + nima->gen_x = ima->gen_x; nima->gen_y = ima->gen_y; nima->gen_type = ima->gen_type; @@ -500,15 +500,15 @@ void BKE_image_make_local(struct Image *ima) void BKE_image_merge(Image *dest, Image *source) { ImBuf *ibuf; - + /* sanity check */ if (dest && source && dest != source) { - + while ((ibuf = source->ibufs.first)) { BLI_remlink(&source->ibufs, ibuf); image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index)); } - + BKE_libblock_free(&G.main->image, source); } } @@ -565,7 +565,7 @@ Image *BKE_image_load_exists(const char *filepath) { Image *ima; char str[FILE_MAX], strtest[FILE_MAX]; - + BLI_strncpy(str, filepath, sizeof(str)); BLI_path_abs(str, G.main->name); @@ -574,7 +574,7 @@ Image *BKE_image_load_exists(const char *filepath) if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); BLI_path_abs(strtest, G.main->name); - + if (BLI_path_cmp(strtest, str) == 0) { if (ima->anim == NULL || ima->id.us == 0) { BLI_strncpy(ima->name, filepath, sizeof(ima->name)); /* for stringcode */ @@ -596,7 +596,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char ImBuf *ibuf; unsigned char *rect = NULL; float *rect_float = NULL; - + if (floatbuf) { ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); rect_float = (float *)ibuf->rect_float; @@ -607,10 +607,10 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char rect = (unsigned char *)ibuf->rect; ibuf->profile = IB_PROFILE_SRGB; } - + BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; - + switch (uvtestgrid) { case 1: BKE_image_buf_fill_checker(rect, rect_float, width, height); @@ -630,19 +630,19 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch { /* on save, type is changed to FILE in editsima.c */ Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); - + if (ima) { ImBuf *ibuf; - + /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */ ima->gen_x = width; ima->gen_y = height; ima->gen_type = uvtestgrid; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - + ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - + ima->ok = IMA_OK_LOADED; } @@ -670,31 +670,31 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf) void BKE_image_memorypack(Image *ima) { ImBuf *ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); - + if (ibuf == NULL) return; if (ima->packedfile) { freePackedFile(ima->packedfile); ima->packedfile = NULL; } - + ibuf->ftype = PNG; ibuf->planes = R_IMF_PLANES_RGBA; - + IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem); if (ibuf->encodedbuffer == NULL) { printf("memory save for pack error\n"); } else { PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile"); - + pf->data = ibuf->encodedbuffer; pf->size = ibuf->encodedsize; ima->packedfile = pf; ibuf->encodedbuffer = NULL; ibuf->encodedsize = 0; ibuf->userflags &= ~IB_BITMAPDIRTY; - + if (ima->source == IMA_SRC_GENERATED) { ima->source = IMA_SRC_FILE; ima->type = IMA_TYPE_IMAGE; @@ -709,7 +709,7 @@ void BKE_image_tag_time(Image *ima) } #if 0 -static void tag_all_images_time() +static void tag_all_images_time() { Image *ima; int ctime = (int)PIL_check_seconds_timer(); @@ -728,9 +728,9 @@ void free_old_images(void) Image *ima; static int lasttime = 0; int ctime = (int)PIL_check_seconds_timer(); - - /* - * Run garbage collector once for every collecting period of time + + /* + * Run garbage collector once for every collecting period of time * if textimeout is 0, that's the option to NOT run the collector */ if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) @@ -739,7 +739,7 @@ void free_old_images(void) /* of course not! */ if (G.rendering) return; - + lasttime = ctime; ima = G.main->image.first; @@ -767,11 +767,11 @@ static uintptr_t image_mem_size(Image *ima) uintptr_t size = 0; size = 0; - + /* viewers have memory depending on other rules, has no valid rect pointer */ if (ima->source == IMA_SRC_VIEWER) return 0; - + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { if (ibuf->rect) size += MEM_allocN_len(ibuf->rect); else if (ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float); @@ -811,25 +811,25 @@ void BKE_image_free_all_textures(void) Tex *tex; Image *ima; /* unsigned int totsize = 0; */ - + for (ima = G.main->image.first; ima; ima = ima->id.next) ima->id.flag &= ~LIB_DOIT; - + for (tex = G.main->tex.first; tex; tex = tex->id.next) if (tex->ima) tex->ima->id.flag |= LIB_DOIT; - + for (ima = G.main->image.first; ima; ima = ima->id.next) { if (ima->ibufs.first && (ima->id.flag & LIB_DOIT)) { ImBuf *ibuf; - + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { /* escape when image is painted on */ if (ibuf->userflags & IB_BITMAPDIRTY) break; - + #if 0 - if (ibuf->mipmap[0]) + if (ibuf->mipmap[0]) totsize += 1.33 * ibuf->x * ibuf->y * 4; else totsize += ibuf->x * ibuf->y * 4; @@ -855,20 +855,20 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame) continue; if (except_frame != IMA_INDEX_FRAME(ibuf->index)) { BLI_remlink(&ima->ibufs, ibuf); - + if (ibuf->userdata) { MEM_freeN(ibuf->userdata); ibuf->userdata = NULL; } IMB_freeImBuf(ibuf); - } + } } } void BKE_image_all_free_anim_ibufs(int cfra) { Image *ima; - + for (ima = G.main->image.first; ima; ima = ima->id.next) if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) BKE_image_free_anim_ibufs(ima, cfra); @@ -921,7 +921,7 @@ char BKE_ftype_to_imtype(const int ftype) { if (ftype == 0) return R_IMF_IMTYPE_TARGA; - else if (ftype == IMAGIC) + else if (ftype == IMAGIC) return R_IMF_IMTYPE_IRIS; #ifdef WITH_HDR else if (ftype & RADHDR) @@ -1108,7 +1108,7 @@ char BKE_imtype_from_arg(const char *imtype_arg) int BKE_add_image_extension(char *string, const char imtype) { const char *extension = NULL; - + if (imtype == R_IMF_IMTYPE_IRIS) { if (!BLI_testextensie(string, ".rgb")) extension = ".rgb"; @@ -1192,7 +1192,7 @@ int BKE_add_image_extension(char *string, const char imtype) else { return BLI_ensure_extension(string, FILE_MAX, extension); } - + } else { return FALSE; @@ -1208,6 +1208,106 @@ void BKE_imformat_defaults(ImageFormatData *im_format) im_format->compress = 90; } +void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf) +{ + BKE_imformat_defaults(im_format); + + // file type + + if (imbuf->ftype == IMAGIC) + im_format->imtype = R_IMF_IMTYPE_IRIS; + +#ifdef WITH_HDR + else if (imbuf->ftype == RADHDR) + im_format->imtype = R_IMF_IMTYPE_RADHDR; +#endif + + else if (imbuf->ftype == PNG) + im_format->imtype = R_IMF_IMTYPE_PNG; + +#ifdef WITH_DDS + else if (imbuf->ftype == DDS) + im_format->imtype = R_IMF_IMTYPE_DDS; +#endif + + else if (imbuf->ftype == BMP) + im_format->imtype = R_IMF_IMTYPE_BMP; + +#ifdef WITH_TIFF + else if (imbuf->ftype & TIF) { + im_format->imtype = R_IMF_IMTYPE_TIFF; + if (imbuf->ftype & TIF_16BIT) + im_format->depth = R_IMF_CHAN_DEPTH_16; + } +#endif + +#ifdef WITH_OPENEXR + else if (imbuf->ftype & OPENEXR) { + im_format->imtype = R_IMF_IMTYPE_OPENEXR; + if (imbuf->ftype & OPENEXR_HALF) + im_format->depth = R_IMF_CHAN_DEPTH_16; + if (imbuf->ftype & OPENEXR_COMPRESS) + im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression + if (imbuf->zbuf_float) + im_format->flag |= R_IMF_FLAG_ZBUF; + } +#endif + +#ifdef WITH_CINEON + else if (imbuf->ftype == CINEON) + im_format->imtype = R_IMF_IMTYPE_CINEON; + else if (imbuf->ftype == DPX) + im_format->imtype = R_IMF_IMTYPE_DPX; +#endif + + else if (imbuf->ftype == TGA) { + im_format->imtype = R_IMF_IMTYPE_TARGA; + } + else if (imbuf->ftype == RAWTGA) { + im_format->imtype = R_IMF_IMTYPE_RAWTGA; + } + +#ifdef WITH_OPENJPEG + else if (imbuf->ftype & JP2) { + im_format->imtype = R_IMF_IMTYPE_JP2; + im_format->quality = imbuf->ftype & ~JPG_MSK; + + if (imbuf->ftype & JP2_16BIT) + im_format->depth = R_IMF_CHAN_DEPTH_16; + else if (imbuf->ftype & JP2_12BIT) + im_format->depth = R_IMF_CHAN_DEPTH_12; + + if (imbuf->ftype & JP2_YCC) + im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC; + + if (imbuf->ftype & JP2_CINE) { + im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET; + if (imbuf->ftype & JP2_CINE_48FPS) + im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48; + } + } +#endif + + else { + im_format->imtype = R_IMF_IMTYPE_JPEG90; + im_format->quality = imbuf->ftype & ~JPG_MSK; + } + + // planes + switch (imbuf->channels) { + case 0: + case 4: im_format->planes = R_IMF_PLANES_RGBA; + break; + case 3: im_format->planes = R_IMF_PLANES_RGB; + break; + case 1: im_format->planes = R_IMF_PLANES_BW; + break; + default: im_format->planes = R_IMF_PLANES_RGB; + break; + } + +} + /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { char file[512]; @@ -1235,7 +1335,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->file[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_NOTE) { /* Never do prefix for Note */ BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata); @@ -1243,7 +1343,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->note[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_DATE) { t = time(NULL); tl = localtime(&t); @@ -1253,7 +1353,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->date[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_MARKER) { char *name = BKE_scene_find_last_marker_name(scene, CFRA); @@ -1265,7 +1365,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->marker[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_TIME) { int f = (int)(scene->r.cfra % scene->r.frs_sec); int s = (int)(scene->r.cfra / scene->r.frs_sec); @@ -1292,11 +1392,11 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->time[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_FRAME) { char fmtstr[32]; int digits = 1; - + if (scene->r.efra > 9) digits = 1 + (int) log10(scene->r.efra); @@ -1332,10 +1432,10 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->scene[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_SEQSTRIP) { Sequence *seq = seq_foreground_frame_get(scene, scene->r.cfra); - + if (seq) BLI_strncpy(text, seq->name + 2, sizeof(text)); else BLI_strncpy(text, "<none>", sizeof(text)); @@ -1373,7 +1473,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec if (!rect && !rectf) return; - + stampdata(scene, camera, &stamp_data, 1); /* TODO, do_versions */ @@ -1382,7 +1482,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* set before return */ BLF_size(mono, scene->r.stamp_font_id, 72); - + BLF_buffer(mono, rectf, rect, width, height, channels); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad = BLF_width_max(mono); @@ -1424,7 +1524,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; } - + /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { BLF_width_and_height(mono, stamp_data.date, &w, &h); h = h_fixed; @@ -1469,7 +1569,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* space width. */ x += w + pad; } - + /* Left bottom corner */ if (stamp_data.time[0]) { BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed; @@ -1484,7 +1584,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* space width. */ x += w + pad; } - + if (stamp_data.frame[0]) { BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed; @@ -1519,7 +1619,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); } - + if (stamp_data.scene[0]) { BLF_width_and_height(mono, stamp_data.scene, &w, &h); h = h_fixed; @@ -1533,7 +1633,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.scene); } - + if (stamp_data.strip[0]) { BLF_width_and_height(mono, stamp_data.strip, &w, &h); h = h_fixed; @@ -1560,10 +1660,10 @@ void BKE_imbuf_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) struct StampData stamp_data; if (!ibuf) return; - + /* fill all the data values, no prefix */ stampdata(scene, camera, &stamp_data, 0); - + if (stamp_data.file[0]) IMB_metadata_change_field(ibuf, "File", stamp_data.file); if (stamp_data.note[0]) IMB_metadata_change_field(ibuf, "Note", stamp_data.note); if (stamp_data.date[0]) IMB_metadata_change_field(ibuf, "Date", stamp_data.date); @@ -1647,10 +1747,10 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) if (imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= OPENEXR_HALF; ibuf->ftype |= (imf->exr_codec & OPENEXR_COMPRESS); - + if (!(imf->flag & R_IMF_FLAG_ZBUF)) ibuf->zbuf_float = NULL; /* signal for exr saving */ - + } #endif #ifdef WITH_CINEON @@ -1671,14 +1771,14 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) else if (imtype == R_IMF_IMTYPE_JP2) { if (quality < 10) quality = 90; ibuf->ftype = JP2 | quality; - + if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->ftype |= JP2_16BIT; } else if (imf->depth == R_IMF_CHAN_DEPTH_12) { ibuf->ftype |= JP2_12BIT; } - + if (imf->jp2_flag & R_IMF_JP2_FLAG_YCC) { ibuf->ftype |= JP2_YCC; } @@ -1695,14 +1795,14 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) if (quality < 10) quality = 90; ibuf->ftype = JPG | quality; } - + BLI_make_existing_file(name); - + ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { perror(name); } - + return(ok); } @@ -1749,7 +1849,7 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int if (use_ext) BKE_add_image_extension(string, imtype); - + } /* used by sequencer too */ @@ -1757,7 +1857,7 @@ struct anim *openanim(const char *name, int flags, int streamindex) { struct anim *anim; struct ImBuf *ibuf; - + anim = IMB_open_anim(name, flags, streamindex); if (anim == NULL) return NULL; @@ -1771,14 +1871,14 @@ struct anim *openanim(const char *name, int flags, int streamindex) return NULL; } IMB_freeImBuf(ibuf); - + return(anim); } /* ************************* New Image API *************** */ -/* Notes about Image storage +/* Notes about Image storage * - packedfile * -> written in .blend * - filename @@ -1801,15 +1901,15 @@ struct anim *openanim(const char *name, int flags, int streamindex) Image *BKE_image_verify_viewer(int type, const char *name) { Image *ima; - + for (ima = G.main->image.first; ima; ima = ima->id.next) if (ima->source == IMA_SRC_VIEWER) if (ima->type == type) break; - + if (ima == NULL) ima = image_alloc(name, IMA_SRC_VIEWER, type); - + /* happens on reload, imagewindow cannot be image user when hidden*/ if (ima->id.us == 0) id_us_plus(&ima->id); @@ -1885,7 +1985,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) { if (ima == NULL) return; - + switch (signal) { case IMA_SIGNAL_FREE: image_free_buffers(ima); @@ -1935,10 +2035,10 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } else image_free_buffers(ima); - + if (iuser) iuser->ok = 1; - + break; case IMA_SIGNAL_USER_NEW_IMAGE: if (iuser) { @@ -1952,7 +2052,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } break; } - + /* don't use notifiers because they are not 100% sure to succeeded * this also makes sure all scenes are accounted for. */ { @@ -1972,13 +2072,13 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) { RenderLayer *rl; RenderPass *rpass = NULL; - + if (rr == NULL) return NULL; - + if (iuser) { short index = 0, rl_index = 0, rp_index; - + for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) { rp_index = 0; for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++, rp_index++) @@ -1987,10 +2087,10 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) if (rpass) break; } - + if (rpass) iuser->multi_index = index; - else + else iuser->multi_index = 0; } if (rpass == NULL) { @@ -1998,7 +2098,7 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) if (rl) rpass = rl->passes.first; } - + return rpass; } @@ -2050,7 +2150,7 @@ void BKE_image_backup_render(Scene *scene, Image *ima) /* in that case we have to build a render-result */ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) { - + ima->rr = RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); #ifdef WITH_OPENEXR @@ -2076,9 +2176,9 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) } /* timer */ ima->lastused = clock() / CLOCKS_PER_SEC; - + ima->ok = IMA_OK_LOADED; - + } static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) @@ -2086,14 +2186,14 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) struct ImBuf *ibuf; char name[FILE_MAX]; int flag; - + /* XXX temp stuff? */ if (ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe = frame; BKE_image_user_file_path(iuser, ima, name); - + flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; @@ -2114,7 +2214,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) #ifdef WITH_OPENEXR /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ if (ibuf->ftype == OPENEXR && ibuf->userdata) { - image_create_multilayer(ima, ibuf, frame); + image_create_multilayer(ima, ibuf, frame); ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); ibuf = NULL; @@ -2130,27 +2230,27 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) } else ima->ok = 0; - + if (iuser) iuser->ok = ima->ok; - + return ibuf; } static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int frame) { struct ImBuf *ibuf = NULL; - + /* either we load from RenderResult, or we have to load a new one */ - + /* check for new RenderResult */ if (ima->rr == NULL || frame != ima->rr->framenr) { /* copy to survive not found multilayer image */ RenderResult *oldrr = ima->rr; - + ima->rr = NULL; ibuf = image_load_sequence_file(ima, iuser, frame); - + if (ibuf) { /* actually an error */ ima->type = IMA_TYPE_IMAGE; printf("error, multi is normal image\n"); @@ -2168,7 +2268,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f } if (ima->rr) { RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); - + if (rpass) { // printf("load from pass %s\n", rpass->name); /* since we free render results, we copy the rect */ @@ -2178,19 +2278,19 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f ibuf->mall = IB_rectfloat; ibuf->channels = rpass->channels; ibuf->profile = IB_PROFILE_LINEAR_RGB; - + image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame); - + } // else printf("pass not found\n"); } else ima->ok = 0; - + if (iuser) iuser->ok = ima->ok; - + return ibuf; } @@ -2198,35 +2298,35 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) { struct ImBuf *ibuf = NULL; - + ima->lastframe = frame; - + if (ima->anim == NULL) { char str[FILE_MAX]; - + BKE_image_user_file_path(iuser, ima, str); /* FIXME: make several stream accessible in image editor, too*/ ima->anim = openanim(str, IB_rect, 0); - + /* let's initialize this user */ if (ima->anim && iuser && iuser->frames == 0) iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); } - + if (ima->anim) { int dur = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); int fra = frame - 1; - + if (fra < 0) fra = 0; if (fra > (dur - 1)) fra = dur - 1; ibuf = IMB_makeSingleUser( IMB_anim_absolute(ima->anim, fra, IMB_TC_RECORD_RUN, IMB_PROXY_NONE)); - + if (ibuf) { image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); @@ -2236,10 +2336,10 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) } else ima->ok = 0; - + if (iuser) iuser->ok = ima->ok; - + return ibuf; } @@ -2249,35 +2349,35 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) struct ImBuf *ibuf; char str[FILE_MAX]; int assign = 0, flag; - + /* always ensure clean ima */ image_free_buffers(ima); - + /* is there a PackedFile with this image ? */ if (ima->packedfile) { flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, "<packed data>"); - } + } else { flag = IB_rect | IB_multilayer | IB_metadata; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - + /* get the right string */ BKE_image_user_frame_calc(iuser, cfra, 0); BKE_image_user_file_path(iuser, ima, str); - + /* read ibuf */ ibuf = IMB_loadiffname(str, flag); } - + if (ibuf) { /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ if (ibuf->ftype == OPENEXR && ibuf->userdata) { - image_create_multilayer(ima, ibuf, cfra); + image_create_multilayer(ima, ibuf, cfra); ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); ibuf = NULL; @@ -2288,7 +2388,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* check if the image is a font image... */ detectBitmapFont(ibuf); - + /* make packed file for autopack */ if ((ima->packedfile == NULL) && (G.fileflags & G_AUTOPACK)) ima->packedfile = newPackedFile(NULL, str, ID_BLEND_PATH(G.main, &ima->id)); @@ -2296,20 +2396,20 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) } else ima->ok = 0; - + if (assign) image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); if (iuser) iuser->ok = ima->ok; - + return ibuf; } static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) { ImBuf *ibuf = NULL; - + if (ima->rr == NULL) { ibuf = image_load_image_file(ima, iuser, 0); if (ibuf) { /* actually an error */ @@ -2322,9 +2422,9 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) if (rpass) { ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); - + image_initialize_after_load(ima, ibuf); - + ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; ibuf->channels = rpass->channels; @@ -2333,12 +2433,12 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } } - + if (ibuf == NULL) ima->ok = 0; if (iuser) iuser->ok = ima->ok; - + return ibuf; } @@ -2379,7 +2479,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ } else memset(&rres, 0, sizeof(RenderResult)); - + if (!(rres.rectx > 0 && rres.recty > 0)) { if (from_render) RE_ReleaseResultImage(re); @@ -2434,7 +2534,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->x = rres.rectx; ibuf->y = rres.recty; - + /* free rect buffer if float buffer changes, so it can be recreated with * the updated result, and also in case we got byte buffer from sequencer, * so we don't keep reference to freed buffer */ @@ -2443,7 +2543,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if (rect) ibuf->rect = rect; - + if (rectf) { ibuf->rect_float = rectf; ibuf->flags |= IB_rectfloat; @@ -2499,13 +2599,13 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame if (ima->type == IMA_TYPE_IMAGE) { frame = iuser ? iuser->framenr : ima->lastframe; ibuf = image_get_ibuf(ima, 0, frame); - + /* XXX temp stuff? */ if (ima->lastframe != frame) { ima->tpageflag |= IMA_TPAGE_REFRESH; } ima->lastframe = frame; - } + } else if (ima->type == IMA_TYPE_MULTILAYER) { frame = iuser ? iuser->framenr : ima->lastframe; index = iuser ? iuser->multi_index : IMA_NO_INDEX; @@ -2552,7 +2652,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) * things in a threadsafe way for image_get_ibuf_threadsafe to work correct. * That means, the last two steps must be, 1) add the ibuf to the list and * 2) set ima/iuser->ok to 0 to IMA_OK_LOADED */ - + if (lock_r) *lock_r = NULL; @@ -2565,7 +2665,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) } else if (ima->ok == 0) return NULL; - + /* try to get the ibuf without locking */ ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); @@ -2607,14 +2707,14 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) } } else if (ima->source == IMA_SRC_FILE) { - + if (ima->type == IMA_TYPE_IMAGE) ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ /* no else; on load the ima type can change */ if (ima->type == IMA_TYPE_MULTILAYER) /* keeps render result, stores ibufs in listbase, allows saving */ ibuf = image_get_ibuf_multilayer(ima, iuser); - + } else if (ima->source == IMA_SRC_GENERATED) { /* generated is: ibuf is allocated dynamically */ @@ -2724,12 +2824,12 @@ void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr) { if (iuser) { const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr); - + /* allows image users to handle redraws */ if (iuser->flag & IMA_ANIM_ALWAYS) if (framenr != iuser->framenr) iuser->flag |= IMA_ANIM_REFRESHED; - + iuser->framenr = framenr; if (iuser->ok == 0) iuser->ok = 1; } @@ -2765,7 +2865,7 @@ int BKE_image_has_alpha(struct Image *image) ImBuf *ibuf; void *lock; int planes; - + ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); planes = (ibuf ? ibuf->planes : 0); BKE_image_release_ibuf(image, lock); diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 4aef47159df..4755fccff99 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -186,7 +186,7 @@ DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts) DO_INLINE lfVector *create_lfvector(unsigned int verts) { // TODO: check if memory allocation was successfull */ - return (lfVector *)MEM_callocN (verts * sizeof(lfVector), "cloth_implicit_alloc_vector"); + return (lfVector *)MEM_callocN(verts * sizeof(lfVector), "cloth_implicit_alloc_vector"); // return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector)); } /* delete long vector */ @@ -514,7 +514,7 @@ static void print_bfmatrix(fmatrix3x3 *m3) DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs) { // TODO: check if memory allocation was successfull */ - fmatrix3x3 *temp = (fmatrix3x3 *)MEM_callocN (sizeof (fmatrix3x3) * (verts + springs), "cloth_implicit_alloc_matrix"); + fmatrix3x3 *temp = (fmatrix3x3 *)MEM_callocN(sizeof(fmatrix3x3) * (verts + springs), "cloth_implicit_alloc_matrix"); temp[0].vcount = verts; temp[0].scount = springs; return temp; @@ -720,7 +720,7 @@ int implicit_init(Object *UNUSED(ob), ClothModifierData *clmd) verts = cloth->verts; // create implicit base - id = (Implicit_Data *)MEM_callocN (sizeof(Implicit_Data), "implicit vecmat"); + id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat"); cloth->implicit = id; /* process diagonal elements */ diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index bbc1874c2ae..f51fee674cf 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -46,6 +46,7 @@ /* since we have versioning code here */ #define DNA_DEPRECATED_ALLOW +#include "DNA_actuator_types.h" #include "DNA_anim_types.h" #include "DNA_constraint_types.h" #include "DNA_camera_types.h" @@ -1753,6 +1754,24 @@ void do_versions_ipos_to_animato(Main *main) ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; ob->ipo = NULL; + + { + /* If we have any empty action actuators, assume they were + converted IPO Actuators using the object IPO */ + bActuator *act; + bActionActuator *aa; + + for (act = ob->actuators.first; act; act = act->next) { + /* Any actuators set to ACT_IPO at this point are actually Action Actuators that + need this converted IPO to finish converting the actuator. */ + if (act->type == ACT_IPO) + { + aa = (bActionActuator*)act->data; + aa->act = ob->adt->action; + act->type = ACT_ACTION; + } + } + } } } diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index e3495a15871..d5b1d3c98c8 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -212,7 +212,7 @@ Lattice *BKE_lattice_copy(Lattice *lt) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; - ltn->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + ltn->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(ltn->dvert, lt->dvert, tot); } diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 48db916b4ba..d85722931a7 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1160,12 +1160,13 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[ if (ob) { MovieTrackingTrack *track = BKE_tracking_track_get_named(tracking, ob, parent->sub_parent); + float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime); MovieClipUser user = {0}; user.framenr = ctime; if (track) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, ctime); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); float marker_pos_ofs[2]; add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); BKE_mask_coord_from_movieclip(clip, &user, r_co, marker_pos_ofs); @@ -1452,7 +1453,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) // printf("SPLINE ALLOC %p %d\n", spline->points_deform, allocated_points); if (spline->points_deform == NULL || allocated_points != spline->tot_point) { - printf("alloc new deform spline\n"); + // printf("alloc new deform spline\n"); if (spline->points_deform) { int i; @@ -1472,51 +1473,46 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) } } -void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) +void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do_newframe) { - MaskLayer *masklay; - - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + /* animation if available */ + if (do_newframe) { + MaskLayerShape *masklay_shape_a; + MaskLayerShape *masklay_shape_b; + int found; - /* animation if available */ - if (do_newframe) { - MaskLayerShape *masklay_shape_a; - MaskLayerShape *masklay_shape_b; - int found; - - if ((found = BKE_mask_layer_shape_find_frame_range(masklay, ctime, - &masklay_shape_a, &masklay_shape_b))) - { - if (found == 1) { + if ((found = BKE_mask_layer_shape_find_frame_range(masklay, ctime, + &masklay_shape_a, &masklay_shape_b))) + { + if (found == 1) { #if 0 - printf("%s: exact %d %d (%d)\n", __func__, (int)ctime, BLI_countlist(&masklay->splines_shapes), - masklay_shape_a->frame); + printf("%s: exact %d %d (%d)\n", __func__, (int)ctime, BLI_countlist(&masklay->splines_shapes), + masklay_shape_a->frame); #endif - BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a); - } - else if (found == 2) { - float w = masklay_shape_b->frame - masklay_shape_a->frame; + BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a); + } + else if (found == 2) { + float w = masklay_shape_b->frame - masklay_shape_a->frame; #if 0 - printf("%s: tween %d %d (%d %d)\n", __func__, (int)ctime, BLI_countlist(&masklay->splines_shapes), - masklay_shape_a->frame, masklay_shape_b->frame); + printf("%s: tween %d %d (%d %d)\n", __func__, (int)ctime, BLI_countlist(&masklay->splines_shapes), + masklay_shape_a->frame, masklay_shape_b->frame); #endif - BKE_mask_layer_shape_to_mask_interp(masklay, masklay_shape_a, masklay_shape_b, - (ctime - masklay_shape_a->frame) / w); - } - else { - /* always fail, should never happen */ - BLI_assert(found == 2); - } + BKE_mask_layer_shape_to_mask_interp(masklay, masklay_shape_a, masklay_shape_b, + (ctime - masklay_shape_a->frame) / w); + } + else { + /* always fail, should never happen */ + BLI_assert(found == 2); } } - /* animation done... */ } + /* animation done... */ - BKE_mask_calc_handles(mask); + BKE_mask_layer_calc_handles(masklay); - - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + /* update deform */ + { MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { @@ -1560,6 +1556,15 @@ void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) } } +void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) +{ + MaskLayer *masklay; + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + BKE_mask_layer_evaluate(masklay, ctime, do_newframe); + } +} + /* the purpose of this function is to ensure spline->points_deform is never out of date. * for now re-evaluate all. eventually this might work differently */ void BKE_mask_update_display(Mask *mask, float ctime) @@ -2089,7 +2094,8 @@ int BKE_mask_get_duration(Mask *mask) /* rasterization */ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, int do_mask_aa) + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) { MaskLayer *masklay; @@ -2118,9 +2124,15 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, &tot_diff_point); if (tot_diff_point) { - diff_feather_points = - BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, - &tot_diff_feather_points); + if (do_feather) { + diff_feather_points = + BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, + &tot_diff_feather_points); + } + else { + tot_diff_feather_points = 0; + diff_feather_points = NULL; + } if (do_aspect_correct) { if (width != height) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index d0b9e73e295..e3b13ca0f17 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -444,7 +444,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) for (i = 0; i < copycount; i++) { if (src[i].dw) { dst[i].dw = MEM_callocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight"); - memcpy(dst[i].dw, src[i].dw, sizeof (MDeformWeight) * src[i].totweight); + memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight); } } @@ -957,7 +957,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll } final++; - (*alledge) = medge = MEM_callocN(sizeof (MEdge) * final, "BKE_mesh_make_edges mdge"); + (*alledge) = medge = MEM_callocN(sizeof(MEdge) * final, "BKE_mesh_make_edges mdge"); (*_totedge) = final; for (a = totedge, ed = edsort; a > 1; a--, ed++) { diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 68adb599c6c..44169cd3d6a 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -451,6 +451,21 @@ static MovieClip *movieclip_alloc(const char *name) return clip; } +static void movieclip_load_get_szie(MovieClip *clip) +{ + int width, height; + MovieClipUser user = {0}; + + user.framenr = 1; + BKE_movieclip_get_size(clip, &user, &width, &height); + + if (width && height) { + clip->tracking.camera.principal[0] = ((float)width) / 2.0f; + clip->tracking.camera.principal[1] = ((float)height) / 2.0f; + + } +} + /* checks if image was already loaded, then returns same image * otherwise creates new. * does not load ibuf itself @@ -458,8 +473,7 @@ static MovieClip *movieclip_alloc(const char *name) MovieClip *BKE_movieclip_file_add(const char *name) { MovieClip *clip; - MovieClipUser user = {0}; - int file, len, width, height; + int file, len; const char *libname; char str[FILE_MAX], strtest[FILE_MAX]; @@ -502,11 +516,9 @@ MovieClip *BKE_movieclip_file_add(const char *name) else clip->source = MCLIP_SRC_SEQUENCE; - user.framenr = 1; - BKE_movieclip_get_size(clip, &user, &width, &height); - if (width && height) { - clip->tracking.camera.principal[0] = ((float)width) / 2.0f; - clip->tracking.camera.principal[1] = ((float)height) / 2.0f; + movieclip_load_get_szie(clip); + if (clip->lastsize[0]) { + int width = clip->lastsize[0]; clip->tracking.camera.focal = 24.0f * width / clip->tracking.camera.sensor_width; } @@ -1022,6 +1034,9 @@ void BKE_movieclip_reload(MovieClip *clip) else clip->source = MCLIP_SRC_SEQUENCE; + clip->lastsize[0] = clip->lastsize[1] = 0; + movieclip_load_get_szie(clip); + movieclip_calc_length(clip); } @@ -1255,12 +1270,12 @@ void BKE_movieclip_unlink(Main *bmain, MovieClip *clip) clip->id.us = 0; } -int BKE_movieclip_remap_scene_to_clip_frame(MovieClip *clip, int framenr) +float BKE_movieclip_remap_scene_to_clip_frame(MovieClip *clip, float framenr) { - return framenr - clip->start_frame + 1; + return framenr - (float) clip->start_frame + 1.0f; } -int BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, int framenr) +float BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, float framenr) { - return framenr + clip->start_frame - 1; + return framenr + (float) clip->start_frame - 1.0f; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index bd3690e2174..a5e081d122d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2098,4 +2098,3 @@ void clear_scene_in_nodes(Main *bmain, Scene *sce) } } } - diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1d045d4142d..877563ddd53 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1465,7 +1465,7 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[][3]) 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 - 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); } @@ -3111,7 +3111,8 @@ static Object *obrel_armature_find(Object *ob) return ob_arm; } -static int obrel_is_recursive_child(Object *ob, Object *child) { +static int obrel_is_recursive_child(Object *ob, Object *child) +{ Object *par; for (par = child->parent; par; par = par->parent) { if (par == ob) { diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 3d3a5ed7556..13ea70d652d 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -199,7 +199,7 @@ static float Ph(struct Ocean *o, float kx, float kz) } // damp out the waves going in the direction opposite the wind - tmp = (o->_wx * kx + o->_wz * kz) / sqrtf(k2); + tmp = (o->_wx * kx + o->_wz * kz) / sqrtf(k2); if (tmp < 0) { tmp *= o->_damp_reflections; } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f7e3e103e99..ef3fd5c93d0 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -96,7 +96,7 @@ Paint *paint_get_active_from_context(const bContext *C) obact = sce->basact->object; if (CTX_wm_space_image(C) != NULL) { - if (obact->mode == OB_MODE_EDIT) { + if (obact && obact->mode == OB_MODE_EDIT) { if (ts->use_uv_sculpt) return &ts->uvsculpt->paint; else diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 6c7336958b5..569e69f2d51 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4114,7 +4114,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) if (ptype&readMask) { activeParts++; - gzread(gzf, &(pa->size), sizeof( float )); + gzread(gzf, &(pa->size), sizeof(float)); pa->size /= 10.0f; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 91023513d4d..a3fa8f8be89 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -842,7 +842,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p if (psys->part->rotmode != PART_ROT_VEL || psys->part->avemode == PART_AVE_RAND || - psys->part->avefac != 0.0f) + psys->part->avefac != 0.0f) { pid->data_types |= (1 << BPHYS_DATA_AVELOCITY); } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index ddf30ecfa81..8cb47118e7d 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2082,7 +2082,9 @@ static ImBuf *seq_render_mask_strip( context.rectx, context.recty, maskbuf, TRUE, - FALSE /*XXX- TODO: make on/off for anti-aliasing*/); + FALSE, /*XXX- TODO: make on/off for anti-aliasing */ + TRUE /*XXX- TODO: make on/off for feather */ + ); fp_src = maskbuf; fp_dst = ibuf->rect_float; @@ -2106,7 +2108,9 @@ static ImBuf *seq_render_mask_strip( context.rectx, context.recty, maskbuf, TRUE, - FALSE /*XXX- TODO: mask on/off for anti-aliasing*/); + FALSE, /*XXX- TODO: make on/off for anti-aliasing */ + TRUE /*XXX- TODO: make on/off for feather */ + ); fp_src = maskbuf; ub_dst = (unsigned char *)ibuf->rect; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ebc31517524..32def1be647 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1856,7 +1856,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM BKE_ptcache_write(&pid, framenr); tend(); - // printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, ( float ) tval() ); + // printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, (float) tval() ); } } diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index b32400586a8..a5c04387b68 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -216,7 +216,7 @@ void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4 } void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingObject *object, - int framenr, int winx, int winy, float mat[4][4]) + int framenr, int winx, int winy, float mat[4][4]) { MovieReconstructedCamera *camera; float lens = tracking->camera.focal * tracking->camera.sensor_width / (float)winx; @@ -1416,13 +1416,13 @@ void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking * distortion->intrinsics = libmv_CameraIntrinsicsNew(camera->focal, camera->principal[0], camera->principal[1] * aspy, camera->k1, camera->k2, camera->k3, - calibration_width, calibration_height * aspy); + calibration_width, calibration_height * aspy); } else { libmv_CameraIntrinsicsUpdate(distortion->intrinsics, camera->focal, camera->principal[0], camera->principal[1] * aspy, camera->k1, camera->k2, camera->k3, - calibration_width, calibration_height * aspy); + calibration_width, calibration_height * aspy); } #else (void) distortion; @@ -1559,7 +1559,7 @@ ImBuf *BKE_tracking_undistort_frame(MovieTracking *tracking, ImBuf *ibuf, int ca camera->intrinsics = BKE_tracking_distortion_new(); return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, calibration_width, - calibration_height, overscan, TRUE); + calibration_height, overscan, TRUE); } ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int calibration_width, @@ -1571,7 +1571,7 @@ ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int cali camera->intrinsics = BKE_tracking_distortion_new(); return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, calibration_width, - calibration_height, overscan, FALSE); + calibration_height, overscan, FALSE); } /*********************** Image sampling *************************/ @@ -1579,14 +1579,14 @@ ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int cali static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int grayscale) { BKE_tracking_disable_channels(ibuf, track->flag & TRACK_DISABLE_RED, - track->flag & TRACK_DISABLE_GREEN, - track->flag & TRACK_DISABLE_BLUE, grayscale); + track->flag & TRACK_DISABLE_GREEN, + track->flag & TRACK_DISABLE_BLUE, grayscale); } ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *search_ibuf, - MovieTrackingTrack *track, MovieTrackingMarker *marker, - int use_mask, int num_samples_x, int num_samples_y, - float pos[2]) + MovieTrackingTrack *track, MovieTrackingMarker *marker, + int use_mask, int num_samples_x, int num_samples_y, + float pos[2]) { #ifdef WITH_LIBMV ImBuf *pattern_ibuf; @@ -1662,7 +1662,7 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels); pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker, - FALSE, num_samples_x, num_samples_y, NULL); + FALSE, num_samples_x, num_samples_y, NULL); IMB_freeImBuf(search_ibuf); @@ -1712,7 +1712,7 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov * out, do a partial grayscale conversion so the display is better. */ void BKE_tracking_disable_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, - int grayscale) + int grayscale) { int x, y; float scale; @@ -2396,7 +2396,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context) ImBuf *destination_ibuf; int frame_delta = context->backwards ? -1 : 1; int curfra = BKE_movieclip_remap_scene_to_clip_frame(context->clip, context->user.framenr); - int nextfra; + /* int nextfra; */ /* UNUSED */ int a, ok = FALSE, map_size; int frame_width, frame_height; @@ -2414,7 +2414,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context) if (!destination_ibuf) return FALSE; - nextfra = curfra + frame_delta; + /* nextfra = curfra + frame_delta; */ /* UNUSED */ frame_width = destination_ibuf->x; frame_height = destination_ibuf->y; @@ -2471,9 +2471,9 @@ int BKE_tracking_context_step(MovieTrackingContext *context) /* run the tracker! */ tracked = libmv_trackRegion(&options, track_context->search_area, - track_context->search_area_width, - track_context->search_area_height, - patch_new, width, height, + track_context->search_area_width, + track_context->search_area_height, + patch_new, width, height, src_pixel_x, src_pixel_y, &result, dst_pixel_x, dst_pixel_y); @@ -2483,7 +2483,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context) #pragma omp critical { tracking_insert_new_marker(context, track, marker, curfra, tracked, - frame_width, frame_height, dst_pixel_x, dst_pixel_y); + frame_width, frame_height, dst_pixel_x, dst_pixel_y); } ok = TRUE; @@ -3059,7 +3059,7 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImB MEM_freeN(pixels); detect_retrieve_libmv_features(tracking, tracksbase, features, framenr, - ibuf->x, ibuf->y, layer, place_outside_layer); + ibuf->x, ibuf->y, layer, place_outside_layer); libmv_destroyFeatures(features); #else diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 40471514b48..b3101638a4e 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -42,8 +42,8 @@ #include <libavformat/avformat.h> #include <libavcodec/avcodec.h> #include <libavutil/rational.h> +#include <libavutil/samplefmt.h> #include <libswscale/swscale.h> -#include <libavcodec/opt.h> #include "MEM_guardedalloc.h" @@ -615,7 +615,7 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex c->sample_rate = rd->ffcodecdata.audio_mixrate; c->bit_rate = ffmpeg_audio_bitrate * 1000; - c->sample_fmt = SAMPLE_FMT_S16; + c->sample_fmt = AV_SAMPLE_FMT_S16; c->channels = rd->ffcodecdata.audio_channels; codec = avcodec_find_encoder(c->codec_id); if (!codec) { @@ -657,11 +657,21 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex } /* essential functions -- start, append, end */ +static void ffmpeg_dict_set_int(AVDictionary **dict, const char *key, int value) +{ + char buffer[32]; + + BLI_snprintf(buffer, sizeof(buffer), "%d", value); + + av_dict_set(dict, key, buffer, 0); +} + static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, ReportList *reports) { /* Handle to the output file */ AVFormatContext *of; AVOutputFormat *fmt; + AVDictionary *opts = NULL; char name[256]; const char **exts; @@ -707,13 +717,14 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report of->oformat = fmt; of->packet_size = rd->ffcodecdata.mux_packet_size; if (ffmpeg_audio_codec != CODEC_ID_NONE) { - of->mux_rate = rd->ffcodecdata.mux_rate; + ffmpeg_dict_set_int(&opts, "muxrate", rd->ffcodecdata.mux_rate); } else { - of->mux_rate = 0; + av_dict_set(&opts, "muxrate", "0", 0); } - of->preload = (int)(0.5 * AV_TIME_BASE); + ffmpeg_dict_set_int(&opts, "preload", (int)(0.5 * AV_TIME_BASE)); + of->max_delay = (int)(0.7 * AV_TIME_BASE); fmt->audio_codec = ffmpeg_audio_codec; @@ -776,6 +787,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report fmt->audio_codec = CODEC_ID_PCM_S16LE; if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) { BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!"); + av_dict_free(&opts); return 0; } } @@ -785,6 +797,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report printf("alloc video stream %p\n", video_stream); if (!video_stream) { BKE_report(reports, RPT_ERROR, "Error initializing video stream."); + av_dict_free(&opts); return 0; } } @@ -793,27 +806,26 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of); if (!audio_stream) { BKE_report(reports, RPT_ERROR, "Error initializing audio stream."); + av_dict_free(&opts); return 0; } } - if (av_set_parameters(of, NULL) < 0) { - BKE_report(reports, RPT_ERROR, "Error setting output parameters."); - return 0; - } if (!(fmt->flags & AVFMT_NOFILE)) { if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) { BKE_report(reports, RPT_ERROR, "Could not open file for writing."); + av_dict_free(&opts); return 0; } } - - if (av_write_header(of) < 0) { + if (avformat_write_header(of, NULL) < 0) { BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination."); + av_dict_free(&opts); return 0; } outfile = of; av_dump_format(of, 0, name, 1); + av_dict_free(&opts); return 1; } @@ -1194,7 +1206,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char char name_[128]; char *name; char *param; - IDProperty *prop; + IDProperty *prop = NULL; avcodec_get_context_defaults(&c); @@ -1222,9 +1234,11 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char } if (param && o->type != FF_OPT_TYPE_CONST && o->unit) { p = my_av_find_opt(&c, param, o->unit, 0, 0); - prop = BKE_ffmpeg_property_add(rd, - (char *) type, p - c.av_class->option, - o - c.av_class->option); + if (p) { + prop = BKE_ffmpeg_property_add(rd, + (char *) type, p - c.av_class->option, + o - c.av_class->option); + } } else { prop = BKE_ffmpeg_property_add(rd, diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 74f5e7fc2bd..9b68406cc54 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -89,7 +89,16 @@ void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen); void BLI_split_file_part(const char *string, char *file, const size_t filelen); void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file); char *BLI_path_basename(char *path); -int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); + +typedef enum bli_rebase_state { + BLI_REBASE_NO_SRCDIR = 0, + BLI_REBASE_OK = 1, + BLI_REBASE_IDENTITY = 2 +} bli_rebase_state; + +int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); +#define BKE_rebase_path BLI_rebase_path /* remove after a 2012 */ + char *BLI_last_slash(const char *string); int BLI_add_slash(char *string); void BLI_del_slash(char *string); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index a265505cc8f..19985c56b84 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -399,7 +399,7 @@ int BLI_kdtree_range_search(KDTree *tree, float range, const float co[3], const } else { dist2 = squared_distance(root->co, co, root->nor, nor); - if (dist2 <= range2) + if (dist2 <= range2) add_in_range(&foundstack, found++, &totfoundstack, root->index, dist2, root->co); if (root->left) diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index feaa60b40b2..5da719cd500 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -63,35 +63,35 @@ typedef struct BoxVert { #define TL 2 #define BR 3 -#define BOXLEFT(b) ((b)->v[BL]->x) -#define BOXRIGHT(b) ((b)->v[TR]->x) -#define BOXBOTTOM(b) ((b)->v[BL]->y) -#define BOXTOP(b) ((b)->v[TR]->y) -#define BOXAREA(b) ((b)->w * (b)->h) - -#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \ - ((b)->v[BR]->x = (b)->v[TR]->x) -#define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \ - ((b)->v[BR]->y = (b)->v[BL]->y) +#define BOXLEFT(b) ((b)->v[BL]->x) +#define BOXRIGHT(b) ((b)->v[TR]->x) +#define BOXBOTTOM(b) ((b)->v[BL]->y) +#define BOXTOP(b) ((b)->v[TR]->y) +#define BOXAREA(b) ((b)->w * (b)->h) + +#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \ + ((b)->v[BR]->x = (b)->v[TR]->x) +#define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \ + ((b)->v[BR]->y = (b)->v[BL]->y) #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) -#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ - (b)->v[BL]->x = f; \ - UPDATE_V34X(b) -#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \ - (b)->v[TR]->x = f; \ - UPDATE_V34X(b) -#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \ - (b)->v[BL]->y = f; \ - UPDATE_V34Y(b) -#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \ - (b)->v[TR]->y = f; \ - UPDATE_V34Y(b) +#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ + (b)->v[BL]->x = f; \ + UPDATE_V34X(b) +#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \ + (b)->v[TR]->x = f; \ + UPDATE_V34X(b) +#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \ + (b)->v[BL]->y = f; \ + UPDATE_V34Y(b) +#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \ + (b)->v[TR]->y = f; \ + UPDATE_V34Y(b) #define BOXINTERSECT(b1, b2) \ - !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \ - BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \ - BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ - BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) + !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \ + BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \ + BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ + BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) #define MIN2(x, y) ((x) < (y) ? (x) : (y)) #define MAX2(x, y) ((x) > (y) ? (x) : (y)) diff --git a/source/blender/blenlib/intern/fnmatch.c b/source/blender/blenlib/intern/fnmatch.c index e29f31897c0..60e898a3f19 100644 --- a/source/blender/blenlib/intern/fnmatch.c +++ b/source/blender/blenlib/intern/fnmatch.c @@ -25,8 +25,8 @@ #endif #include <errno.h> -#include <BLI_fnmatch.h> #include <ctype.h> +#include "BLI_fnmatch.h" /* Comment out all this code if we are using the GNU C Library, and are not diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index ef2eb25a891..a0e72af8131 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -136,7 +136,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf onpoints[j]++; if (k < npoints[j] - 1) { - if (ftoutline.tags[l] == FT_Curve_Tag_Conic && + if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { onpoints[j]++; diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 417c557af8a..23d70bd148b 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -222,6 +222,12 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack) r_col[2] = ((pack) >> 16) & 0xFF; } +/* XXX - investigate when/why rgb_to_bw & rgb_to_grayscale are different, + * and why we use both! whats the purpose of this? */ +MINLINE float rgb_to_bw(const float rgb[3]) +{ + return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2]; +} MINLINE float rgb_to_grayscale(const float rgb[3]) { @@ -233,6 +239,7 @@ MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]) return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255; } +/* luma from defined by 'YCC_JFIF', see #rgb_to_ycc */ MINLINE float rgb_to_luma(const float rgb[3]) { return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2]; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 1bda7b5ee7e..46a0ac630c1 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1547,31 +1547,40 @@ char *BLI_path_basename(char *path) /** * Produce image export path. - * - * Fails returning 0 if image filename is empty or if destination path - * matches image path (i.e. both are the same file). - * - * Trailing slash in dest_dir is optional. + * + * Returns: + * 0 if image filename is empty or if destination path + * matches image path (i.e. both are the same file). + * 2 if source is identical to destination. + * 1 if rebase was successfull + * ------------------------------------------------------------- + * Hint: Trailing slash in dest_dir is optional. * * Logic: * - * - if an image is "below" current .blend file directory, rebuild the - * same dir structure in dest_dir + * - if an image is "below" current .blend file directory: + * rebuild the same dir structure in dest_dir * - * For example //textures/foo/bar.png becomes - * [dest_dir]/textures/foo/bar.png. + * Example: + * src : //textures/foo/bar.png + * dest: [dest_dir]/textures/foo/bar.png. * * - if an image is not "below" current .blend file directory, - * disregard it's path and copy it in the same directory where 3D file - * goes. + * disregard it's path and copy it into the destination + * directory. * - * For example //../foo/bar.png becomes [dest_dir]/bar.png. + * Example: + * src : //../foo/bar.png becomes + * dest: [dest_dir]/bar.png. * - * This logic will help ensure that all image paths are relative and + * This logic ensures that all image paths are relative and * that a user gets his images in one place. It'll also provide * consistent behavior across exporters. + * IMPORTANT NOTE: If base_dir contains an empty string, then + * this function returns wrong results! + * XXX: test on empty base_dir and return an error ? */ -int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir) +int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir) { char path[FILE_MAX]; char dir[FILE_MAX]; @@ -1590,7 +1599,7 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const BLI_split_dir_part(base_dir, blend_dir, sizeof(blend_dir)); if (src_dir[0] == '\0') - return 0; + return BLI_REBASE_NO_SRCDIR; BLI_strncpy(path, src_dir, sizeof(path)); @@ -1637,10 +1646,10 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const /* return 2 if src=dest */ if (BLI_path_cmp(path, dest_path) == 0) { // if (G.debug & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path); - return 2; + return BLI_REBASE_IDENTITY; } - return 1; + return BLI_REBASE_OK; } char *BLI_first_slash(char *string) diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 9795d4dea2d..ff234a971aa 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -211,7 +211,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t max { size_t len = 0; while (*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */ - len += BLI_str_utf8_from_unicode(*src++, dst+len); + len += BLI_str_utf8_from_unicode(*src++, dst + len); } dst[len]= '\0'; diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index dc4c15a82fc..d591f98ddc0 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -44,14 +44,14 @@ /* for checking system threads - BLI_system_thread_count */ #ifdef WIN32 -#include "windows.h" -#include <sys/timeb.h> +# include <windows.h> +# include <sys/timeb.h> #elif defined(__APPLE__) -#include <sys/types.h> -#include <sys/sysctl.h> +# include <sys/types.h> +# include <sys/sysctl.h> #else -#include <unistd.h> -#include <sys/time.h> +# include <unistd.h> +# include <sys/time.h> #endif #if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) @@ -576,7 +576,7 @@ void *BLI_thread_queue_pop(ThreadQueue *queue) if (!BLI_gsqueue_is_empty(queue->queue)) { BLI_gsqueue_pop(queue->queue, &work); - if(BLI_gsqueue_is_empty(queue->queue)) + if (BLI_gsqueue_is_empty(queue->queue)) pthread_cond_broadcast(&queue->finish_cond); } @@ -642,7 +642,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms) if (!BLI_gsqueue_is_empty(queue->queue)) { BLI_gsqueue_pop(queue->queue, &work); - if(BLI_gsqueue_is_empty(queue->queue)) + if (BLI_gsqueue_is_empty(queue->queue)) pthread_cond_broadcast(&queue->finish_cond); } @@ -678,7 +678,7 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue) /* wait for finish condition */ pthread_mutex_lock(&queue->mutex); - while(!BLI_gsqueue_is_empty(queue->queue)) + while (!BLI_gsqueue_is_empty(queue->queue)) pthread_cond_wait(&queue->finish_cond, &queue->mutex); pthread_mutex_unlock(&queue->mutex); diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 0088d24d741..727e42dc8de 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -49,10 +49,10 @@ enum { typedef struct VoronoiEvent { struct VoronoiEvent *next, *prev; - int type; /* type of event (site or circle) */ - float site[2]; /* site for which event was generated */ + int type; /* type of event (site or circle) */ + float site[2]; /* site for which event was generated */ - struct VoronoiParabola *parabola; /* parabola for which event was generated */ + struct VoronoiParabola *parabola; /* parabola for which event was generated */ } VoronoiEvent; typedef struct VoronoiParabola { @@ -254,9 +254,9 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f b = b1 - b2; c = c1 - c2; - disc = b*b - 4 * a * c; - x1 = (-b + sqrtf(disc)) / (2*a); - x2 = (-b - sqrtf(disc)) / (2*a); + disc = b * b - 4 * a * c; + x1 = (-b + sqrtf(disc)) / (2 * a); + x2 = (-b - sqrtf(disc)) / (2 * a); if (p[1] < r[1]) ry = MAX2(x1, x2); @@ -268,7 +268,7 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f static VoronoiParabola *voronoi_getParabolaByX(VoronoiProcess *process, float xx) { - VoronoiParabola * par = process->root; + VoronoiParabola *par = process->root; float x = 0.0f; float ly = process->current_y; @@ -371,7 +371,7 @@ static void voronoi_addParabola(VoronoiProcess *process, float site[2]) s[0] = (site[0] + fp[0]) / 2.0f; s[1] = process->height; - if(site[0] > fp[0]) + if (site[0] > fp[0]) root->edge = voronoiEdge_new(s, fp, site); else root->edge = voronoiEdge_new(s, site, fp); @@ -506,12 +506,12 @@ void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabola) void voronoi_clampEdgeVertex(int width, int height, float *coord, float *other_coord) { const float corners[4][2] = {{0.0f, 0.0f}, - {width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}}; + {width - 1, 0.0f}, + {width - 1, height - 1}, + {0.0f, height - 1}}; int i; - if (IN_RANGE_INCL(coord[0], 0, width-1) && IN_RANGE_INCL(coord[1], 0, height-1)) { + if (IN_RANGE_INCL(coord[0], 0, width - 1) && IN_RANGE_INCL(coord[1], 0, height - 1)) { return; } @@ -609,9 +609,9 @@ static int voronoi_getNextSideCoord(ListBase *edges, float coord[2], int dim, in static void voronoi_createBoundaryEdges(ListBase *edges, int width, int height) { const float corners[4][2] = {{width - 1, 0.0f}, - {width - 1, height - 1}, - {0.0f, height - 1}, - {0.0f, 0.0f}}; + {width - 1, height - 1}, + {0.0f, height - 1}, + {0.0f, 0.0f}}; int i, dim = 0, dir = 1; float coord[2] = {0.0f, 0.0f}; @@ -756,7 +756,7 @@ static void voronoi_addTriangle(int v1, int v2, int v3, int (**triangles)[3], in *triangles = MEM_callocN(sizeof(int[3]), "trianglulation triangles"); } - triangle = (int*)&(*triangles)[(*triangles_total)]; + triangle = (int *)&(*triangles)[(*triangles_total)]; triangle[0] = v1; triangle[1] = v2; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 10eb4e82912..3a8705bbbba 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -93,9 +93,9 @@ float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3 const float w[2] = {1.f - dz, dz}; return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) ) - + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) ); + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) ) + + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) ); } return 0.f; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0dac27b13cc..a45e517d6c3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6976,17 +6976,24 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo node->storage = nimf; - /* split off filename from the old path, to be used as socket sub-path */ - BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename)); - - BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path)); - nimf->format = old_data->im_format; + /* looks like storage data can be messed up somehow, stupid check here */ + if (old_data) { + /* split off filename from the old path, to be used as socket sub-path */ + BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename)); + + BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path)); + nimf->format = old_data->im_format; + } + else { + basepath[0] = '\0'; + BLI_strncpy(filename, old_image->name, sizeof(filename)); + } /* if z buffer is saved, change the image type to multilayer exr. * XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ... * i'm just assuming here that IRIZ means IRIS with z buffer ... */ - if (ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) { + if (old_data && ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) { char sockpath[FILE_MAX]; nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER; @@ -7021,7 +7028,8 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo nodeRemoveSocket(ntree, node, old_image); nodeRemoveSocket(ntree, node, old_z); - MEM_freeN(old_data); + if (old_data) + MEM_freeN(old_data); } else if (node->type==CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) { NodeImageMultiFile *nimf = node->storage; @@ -7163,6 +7171,21 @@ static void do_version_ntree_image_user_264(void *UNUSED(data), ID *UNUSED(id), } } +static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_DILATEERODE) { + if (node->storage == NULL) { + NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), __func__); + data->falloff = PROP_SMOOTH; + node->storage = data; + } + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7962,6 +7985,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 12)) { + Material *ma; + + for (ma = main->mat.first; ma; ma = ma->id.next) + if (ma->strand_widthfade == 2.0f) + ma->strand_widthfade = 0.0f; + } + + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 13)) { + bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_ntree_dilateerode_264); + } + /* default values in Freestyle settings */ { Scene *sce; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 5ed39ad5307..bfaa526b995 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2558,11 +2558,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) for (ob = main->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_IPO) { - // Create the new actuator + /* Create the new actuator */ ia = act->data; aa = MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); - // Copy values + /* Copy values */ aa->type = ia->type; aa->flag = ia->flag; aa->sta = ia->sta; @@ -2572,12 +2572,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (ob->adt) aa->act = ob->adt->action; - // Get rid of the old actuator + /* Get rid of the old actuator */ MEM_freeN(ia); - // Assign the new actuator + /* Assign the new actuator */ act->data = aa; act->type = act->otype = ACT_ACTION; + + /* Fix for converting 2.4x files: if we don't have an action, but we have an + object IPO, then leave the actuator as an IPO actuator for now and let the + IPO conversion code handle it */ + if (ob->ipo && !aa->act) + act->type = ACT_IPO; } else if (act->type == ACT_SHAPEACTION) { act->type = act->otype = ACT_ACTION; diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index a14d602c586..a51d6bd2940 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -384,7 +384,7 @@ int bmesh_elem_check(void *element, const char htype) err |= 256; if (l->e->head.htype != BM_EDGE) err |= 512; - if (l->v->head.htype != BM_VERT) + if (l->v->head.htype != BM_VERT) err |= 1024; if (!BM_vert_in_edge(l->e, l->v)) { fprintf(stderr, "%s: fatal bmesh error (vert not in edge)! (bmesh internal error)\n", __func__); diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index a8c27e0a761..123eb6829a3 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -768,7 +768,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess) /* editing the base key should update others */ if ((me->key->type == KEY_RELATIVE) && /* only need offsets for relative shape keys */ - (actkey != NULL) && /* unlikely, but the active key may not be valid if the + (actkey != NULL) && /* unlikely, but the active key may not be valid if the * bmesh and the mesh are out of sync */ (oldverts != NULL)) /* not used here, but 'oldverts' is used later for applying 'ofs' */ { diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 4ae7b6cc350..a72bfe47127 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -547,7 +547,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker) ((vert_edge_tot == 4 || vert_edge_tot == 2) && owalk.is_boundary == FALSE) || /* walk over boundary of faces but stop at corners */ - (owalk.is_boundary == TRUE && owalk.is_single == FALSE && vert_edge_tot > 2) || + (owalk.is_boundary == TRUE && owalk.is_single == FALSE && vert_edge_tot > 2) || /* initial edge was a boundary, so is this edge and vertex is only apart of this face * this lets us walk over the the boundary of an ngon which is handy */ diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 9582da4fe5c..57829f777c5 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -1114,7 +1114,7 @@ bool AnimationExporter::hasAnimations(Scene *sce) { LinkNode *node; - for(node=this->export_settings->export_set; node; node=node->next) { + for (node=this->export_settings->export_set; node; node=node->next) { Object *ob = (Object *)node->link; FCurve *fcu = 0; diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 625804e4ecd..4182a9c4c93 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -473,10 +473,10 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * { COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType(); bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; - bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; + bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; //to check if the no of curves are valid - bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE || tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); + bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE || tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) { diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 98047df8aa4..c5feb62fd80 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -80,6 +80,18 @@ bool ArmatureExporter::is_skinned_mesh(Object *ob) return bc_get_assigned_armature(ob) != NULL; } + +void ArmatureExporter::write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone) +{ + if (bc_is_root_bone(bone, this->export_settings->deform_bones_only)) + ins.addSkeleton(COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_joint_id(bone, ob_arm))); + else { + for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { + write_bone_URLs(ins, ob_arm, child); + } + } +} + bool ArmatureExporter::add_instance_controller(Object *ob) { Object *ob_arm = bc_get_assigned_armature(ob); @@ -96,11 +108,10 @@ bool ArmatureExporter::add_instance_controller(Object *ob) // write root bone URLs Bone *bone; for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) { - if (!bone->parent) - ins.addSkeleton(COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_joint_id(bone, ob_arm))); + write_bone_URLs(ins, ob_arm, bone); } - InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob); + InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only); ins.add(); return true; @@ -164,67 +175,76 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se, std::list<Object *>& child_objects) { - std::string node_id = get_joint_id(bone, ob_arm); - std::string node_name = std::string(bone->name); - std::string node_sid = get_joint_sid(bone, ob_arm); + if (!(this->export_settings->deform_bones_only && bone->flag & BONE_NO_DEFORM)) { + std::string node_id = get_joint_id(bone, ob_arm); + std::string node_name = std::string(bone->name); + std::string node_sid = get_joint_sid(bone, ob_arm); - COLLADASW::Node node(mSW); + COLLADASW::Node node(mSW); - node.setType(COLLADASW::Node::JOINT); - node.setNodeId(node_id); - node.setNodeName(node_name); - node.setNodeSid(node_sid); + node.setType(COLLADASW::Node::JOINT); + node.setNodeId(node_id); + node.setNodeName(node_name); + node.setNodeSid(node_sid); - /*if ( bone->childbase.first == NULL || BLI_countlist(&(bone->childbase))>=2) - add_blender_leaf_bone( bone, ob_arm , node ); - else{*/ - node.start(); +#if 0 + if (bone->childbase.first == NULL || BLI_countlist(&(bone->childbase)) >= 2) { + add_blender_leaf_bone( bone, ob_arm , node ); + } + else { +#endif + node.start(); - add_bone_transform(ob_arm, bone, node); + add_bone_transform(ob_arm, bone, node); - // Write nodes of childobjects, remove written objects from list - std::list<Object *>::iterator i = child_objects.begin(); + // Write nodes of childobjects, remove written objects from list + std::list<Object *>::iterator i = child_objects.begin(); - while (i != child_objects.end()) { - if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) { - float backup_parinv[4][4]; - copy_m4_m4(backup_parinv, (*i)->parentinv); + while (i != child_objects.end()) { + if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) { + float backup_parinv[4][4]; + copy_m4_m4(backup_parinv, (*i)->parentinv); - // crude, temporary change to parentinv - // so transform gets exported correctly. + // crude, temporary change to parentinv + // so transform gets exported correctly. - // Add bone tail- translation... don't know why - // bone parenting is against the tail of a bone - // and not it's head, seems arbitrary. - (*i)->parentinv[3][1] += bone->length; + // Add bone tail- translation... don't know why + // bone parenting is against the tail of a bone + // and not it's head, seems arbitrary. + (*i)->parentinv[3][1] += bone->length; - // SECOND_LIFE_COMPATIBILITY - // TODO: when such objects are animated as - // single matrix the tweak must be applied - // to the result. - if (export_settings->second_life) { - // tweak objects parentinverse to match compatibility - float temp[4][4]; + // SECOND_LIFE_COMPATIBILITY + // TODO: when such objects are animated as + // single matrix the tweak must be applied + // to the result. + if (export_settings->second_life) { + // tweak objects parentinverse to match compatibility + float temp[4][4]; - copy_m4_m4(temp, bone->arm_mat); - temp[3][0] = temp[3][1] = temp[3][2] = 0.0f; + copy_m4_m4(temp, bone->arm_mat); + temp[3][0] = temp[3][1] = temp[3][2] = 0.0f; - mult_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv); - } + mult_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv); + } - se->writeNodes(*i, sce); + se->writeNodes(*i, sce); - copy_m4_m4((*i)->parentinv, backup_parinv); - child_objects.erase(i++); + copy_m4_m4((*i)->parentinv, backup_parinv); + child_objects.erase(i++); + } + else i++; } - else i++; - } - for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { - add_bone_node(child, ob_arm, sce, se, child_objects); + for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { + add_bone_node(child, ob_arm, sce, se, child_objects); + } + node.end(); + } + else { + for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { + add_bone_node(child, ob_arm, sce, se, child_objects); + } } - node.end(); - //} } #if 0 @@ -325,7 +345,7 @@ void ArmatureExporter::export_controller(Object *ob, Object *ob_arm) Mesh *me; if (this->export_settings->apply_modifiers) { - me = bc_to_mesh_apply_modifiers(scene, ob); + me = bc_to_mesh_apply_modifiers(scene, ob, this->export_settings->export_mesh_type); } else { me = (Mesh *)ob->data; diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h index beef77af767..086c16f0cd5 100644 --- a/source/blender/collada/ArmatureExporter.h +++ b/source/blender/collada/ArmatureExporter.h @@ -53,14 +53,14 @@ class SceneExporter; // XXX exporter writes wrong data for shared armatures. A separate // controller should be written for each armature-mesh binding how do // we make controller ids then? -class ArmatureExporter: public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter +class ArmatureExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter { public: ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings); // write bone nodes - void add_armature_bones(Object *ob_arm, Scene* sce, SceneExporter* se, - std::list<Object*>& child_objects); + void add_armature_bones(Object *ob_arm, Scene *sce, SceneExporter *se, + std::list<Object *>& child_objects); bool is_skinned_mesh(Object *ob); @@ -76,7 +76,7 @@ private: const ExportSettings *export_settings; #if 0 - std::vector<Object*> written_armatures; + std::vector<Object *> written_armatures; bool already_written(Object *ob_arm); @@ -89,8 +89,8 @@ private: // Scene, SceneExporter and the list of child_objects // are required for writing bone parented objects - void add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, SceneExporter* se, - std::list<Object*>& child_objects); + void add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se, + std::list<Object *>& child_objects); void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node); @@ -100,10 +100,10 @@ private: // ob should be of type OB_MESH // both args are required - void export_controller(Object* ob, Object *ob_arm); + void export_controller(Object *ob, Object *ob_arm); void add_joints_element(ListBase *defbase, - const std::string& joints_source_id, const std::string& inv_bind_mat_source_id); + const std::string& joints_source_id, const std::string& inv_bind_mat_source_id); void add_bind_shape_mat(Object *ob); @@ -111,15 +111,17 @@ private: std::string add_inv_bind_mats_source(Object *ob_arm, ListBase *defbase, const std::string& controller_id); - Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def); + Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def); - bool is_bone_defgroup(Object *ob_arm, bDeformGroup* def); + bool is_bone_defgroup(Object *ob_arm, bDeformGroup *def); std::string add_weights_source(Mesh *me, const std::string& controller_id, - const std::list<float>& weights); + const std::list<float>& weights); void add_vertex_weights_element(const std::string& weights_source_id, const std::string& joints_source_id, - const std::list<int>& vcount, const std::list<int>& joints); + const std::list<int>& vcount, const std::list<int>& joints); + + void write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone); }; #endif diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 115f129cb88..cd2574d055e 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -279,7 +279,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: TagsMap::iterator etit; ExtraTags *et = 0; etit = uid_tags_map.find(node->getUniqueId().toAscii()); - if (etit != uid_tags_map.end()) { + if (etit != uid_tags_map.end()) { et = etit->second; //else return; diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 58a65db0489..3b7a38eb950 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -34,6 +34,7 @@ set(INC ../makesdna ../makesrna ../windowmanager + ../imbuf ../../../intern/guardedalloc ) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 6c9d277de54..ca07512f439 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -386,7 +386,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod Object *new_child = NULL; if (inodes.getCount()) { // \todo loop through instance nodes const COLLADAFW::UniqueId& id = inodes[0]->getInstanciatedObjectId(); - fprintf(stderr, "Doing %d child nodes\n", node_map.count(id)); + fprintf(stderr, "Doing %d child nodes\n", (int)node_map.count(id)); new_child = create_instance_node(object_map.find(id)->second, node_map[id], child_node, sce, is_library_node); } else { diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 3ed689628f7..f11ecc7f16d 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -27,6 +27,7 @@ #include <map> +#include <set> #include "COLLADASWEffectProfile.h" @@ -39,6 +40,8 @@ #include "DNA_world_types.h" #include "BKE_customdata.h" +#include "BKE_mesh.h" +#include "BKE_material.h" #include "collada_internal.h" #include "collada_utils.h" @@ -118,11 +121,60 @@ void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma) ep.setSpecular(cot, false, "specular"); } +void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep, + std::string &key, + COLLADASW::Sampler *sampler, + MTex *t, Image *ima, + std::string &uvname ) { + + // Image not set for texture + if (!ima) return; + + // color + if (t->mapto & (MAP_COL | MAP_COLSPEC)) { + ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse"); + } + // ambient + if (t->mapto & MAP_AMB) { + ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient"); + } + // specular + if (t->mapto & MAP_SPEC) { + ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular"); + } + // emission + if (t->mapto & MAP_EMIT) { + ep.setEmission(createTexture(ima, uvname, sampler), false, "emission"); + } + // reflective + if (t->mapto & MAP_REF) { + ep.setReflective(createTexture(ima, uvname, sampler)); + } + // alpha + if (t->mapto & MAP_ALPHA) { + ep.setTransparent(createTexture(ima, uvname, sampler)); + } + // extension: + // Normal map --> Must be stored with <extra> tag as different technique, + // since COLLADA doesn't support normal maps, even in current COLLADA 1.5. + if (t->mapto & MAP_NORM) { + COLLADASW::Texture texture(key); + texture.setTexcoord(uvname); + texture.setSampler(*sampler); + // technique FCOLLADA, with the <bump> tag, is most likely the best understood, + // most widespread de-facto standard. + texture.setProfileName("FCOLLADA"); + texture.setChildElementName("bump"); + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); + } +} + void EffectsExporter::operator()(Material *ma, Object *ob) { // create a list of indices to textures of type TEX_IMAGE std::vector<int> tex_indices; - createTextureIndices(ma, tex_indices); + if(this->export_settings->include_material_textures) + createTextureIndices(ma, tex_indices); openEffect(translate_id(id_name(ma)) + "-effect"); @@ -256,6 +308,52 @@ void EffectsExporter::operator()(Material *ma, Object *ob) } } + + std::set<Image *> uv_textures; + if (ob->type == OB_MESH && ob->totcol && this->export_settings->include_uv_textures) { + Mesh *me = (Mesh *) ob->data; + BKE_mesh_tessface_ensure(me); + for (int i = 0; i < me->pdata.totlayer; i++) { + if (me->pdata.layers[i].type == CD_MTEXPOLY) { + MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; + MFace *mface = me->mface; + for (int j = 0; j < me->totpoly; j++, mface++, txface++) { + + Material *mat = give_current_material(ob, mface->mat_nr + 1); + if (mat != ma) + continue; + + Image *ima = txface->tpage; + if (ima == NULL) + continue; + + + bool not_in_list = uv_textures.find(ima)==uv_textures.end(); + if (not_in_list) { + std::string name = id_name(ima); + std::string key(name); + key = translate_id(key); + + // create only one <sampler>/<surface> pair for each unique image + if (im_samp_map.find(key) == im_samp_map.end()) { + //<newparam> <sampler> <source> + COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D, + key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX, + key + COLLADASW::Sampler::SURFACE_SID_SUFFIX); + sampler.setImageId(key); + samplers[a] = sampler; + samp_surf[b][0] = &samplers[a]; + im_samp_map[key] = b; + b++; + a++; + uv_textures.insert(ima); + } + } + } + } + } + } + // used as fallback when MTex->uvname is "" (this is pretty common) // it is indeed the correct value to use in that case std::string active_uv(getActiveUVLayerName(ob)); @@ -265,58 +363,25 @@ void EffectsExporter::operator()(Material *ma, Object *ob) for (a = 0; a < tex_indices.size(); a++) { MTex *t = ma->mtex[tex_indices[a]]; Image *ima = t->tex->ima; - - // Image not set for texture - if (!ima) continue; - - // we assume map input is always TEXCO_UV std::string key(id_name(ima)); key = translate_id(key); int i = im_samp_map[key]; - COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0]; - //COLLADASW::Surface *surface = (COLLADASW::Surface*)samp_surf[i][1]; - std::string uvname = strlen(t->uvname) ? t->uvname : active_uv; + COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0]; + writeTextures(ep, key, sampler, t, ima, uvname); + } - // color - if (t->mapto & (MAP_COL | MAP_COLSPEC)) { - ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse"); - } - // ambient - if (t->mapto & MAP_AMB) { - ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient"); - } - // specular - if (t->mapto & MAP_SPEC) { - ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular"); - } - // emission - if (t->mapto & MAP_EMIT) { - ep.setEmission(createTexture(ima, uvname, sampler), false, "emission"); - } - // reflective - if (t->mapto & MAP_REF) { - ep.setReflective(createTexture(ima, uvname, sampler)); - } - // alpha - if (t->mapto & MAP_ALPHA) { - ep.setTransparent(createTexture(ima, uvname, sampler)); - } - // extension: - // Normal map --> Must be stored with <extra> tag as different technique, - // since COLLADA doesn't support normal maps, even in current COLLADA 1.5. - if (t->mapto & MAP_NORM) { - COLLADASW::Texture texture(key); - texture.setTexcoord(uvname); - texture.setSampler(*sampler); - // technique FCOLLADA, with the <bump> tag, is most likely the best understood, - // most widespread de-facto standard. - texture.setProfileName("FCOLLADA"); - texture.setChildElementName("bump"); - ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); - } + std::set<Image *>::iterator uv_t_iter; + for(uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++ ) { + Image *ima = *uv_t_iter; + std::string key(id_name(ima)); + key = translate_id(key); + int i = im_samp_map[key]; + COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0]; + ep.setDiffuse(createTexture(ima, active_uv, sampler), false, "diffuse"); } + // performs the actual writing ep.addProfileElements(); bool twoSided = false; diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h index 6b7caf439b7..d20cbfdfe0b 100644 --- a/source/blender/collada/EffectExporter.h +++ b/source/blender/collada/EffectExporter.h @@ -64,7 +64,12 @@ private: void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma); void writeLambert(COLLADASW::EffectProfile &ep, Material *ma); void writePhong(COLLADASW::EffectProfile &ep, Material *ma); - + void writeTextures(COLLADASW::EffectProfile &ep, + std::string &key, + COLLADASW::Sampler *sampler, + MTex *t, Image *ima, + std::string &uvname ); + bool hasEffects(Scene *sce); const ExportSettings *export_settings; diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index e856eefab99..2504c276036 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -24,25 +24,32 @@ * \ingroup collada */ -extern "C" { -#include "BLI_linklist.h" -} - #ifndef __EXPORTSETTINGS_H__ #define __EXPORTSETTINGS_H__ -struct ExportSettings -{ - public: - bool selected; - bool apply_modifiers; - bool include_armatures; - bool include_children; - bool use_object_instantiation; - bool sort_by_name; - bool second_life; - char *filepath; - LinkNode *export_set; +#include "collada.h" + +struct ExportSettings { +public: + bool apply_modifiers; + BC_export_mesh_type export_mesh_type; + + bool selected; + bool include_children; + bool include_armatures; + bool deform_bones_only; + + bool active_uv_only; + bool include_uv_textures; + bool include_material_textures; + bool use_texture_copies; + + bool use_object_instantiation; + bool sort_by_name; + bool second_life; + + char *filepath; + LinkNode *export_set; }; #endif diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 94b977ca01c..c3d1106b288 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -78,7 +78,7 @@ void GeometryExporter::operator()(Object *ob) bool use_instantiation = this->export_settings->use_object_instantiation; Mesh *me; if (this->export_settings->apply_modifiers) { - me = bc_to_mesh_apply_modifiers(mScene, ob); + me = bc_to_mesh_apply_modifiers(mScene, ob, this->export_settings->export_mesh_type); } else { me = (Mesh *)ob->data; @@ -261,8 +261,9 @@ void GeometryExporter::createPolylist(short material_index, // sets material name if (ma) { + std::string material_id = get_material_id(ma); std::ostringstream ostr; - ostr << translate_id(id_name(ma)); + ostr << translate_id(material_id); polylist.setMaterial(ostr.str()); } @@ -436,33 +437,38 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) // write <source> for each layer // each <source> will get id like meshName + "map-channel-1" + int map_index = 0; + int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1; for (int a = 0; a < num_layers; a++) { - MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); - // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, a); - - COLLADASW::FloatSourceF source(mSW); - std::string layer_id = makeTexcoordSourceId(geom_id, a); - source.setId(layer_id); - source.setArrayId(layer_id + ARRAY_ID_SUFFIX); - - source.setAccessorCount(totuv); - source.setAccessorStride(2); - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("S"); - param.push_back("T"); - - source.prepareToAppendValues(); - - for (i = 0; i < totfaces; i++) { - MFace *f = &mfaces[i]; + + if (!this->export_settings->active_uv_only || a == active_uv_index) { + MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); + // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, a); - for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) { - source.appendValues(tface[i].uv[j][0], - tface[i].uv[j][1]); + COLLADASW::FloatSourceF source(mSW); + std::string layer_id = makeTexcoordSourceId(geom_id, map_index++); + source.setId(layer_id); + source.setArrayId(layer_id + ARRAY_ID_SUFFIX); + + source.setAccessorCount(totuv); + source.setAccessorStride(2); + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + param.push_back("S"); + param.push_back("T"); + + source.prepareToAppendValues(); + + for (i = 0; i < totfaces; i++) { + MFace *f = &mfaces[i]; + + for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) { + source.appendValues(tface[i].uv[j][0], + tface[i].uv[j][1]); + } } + + source.finish(); } - - source.finish(); } } diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index c777a7d1fab..f789cfe3660 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -29,22 +29,150 @@ #include "COLLADABUURI.h" #include "COLLADASWImage.h" -#include "ImageExporter.h" -#include "MaterialExporter.h" - +extern "C" { #include "DNA_texture_types.h" +#include "DNA_image_types.h" +#include "DNA_meshdata_types.h" +#include "BKE_customdata.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_utildefines.h" #include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "IMB_imbuf_types.h" +} + +#include "ImageExporter.h" +#include "MaterialExporter.h" + ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryImages(sw), export_settings(export_settings) { } +void ImagesExporter::export_UV_Image(Image *image, bool use_copies) +{ + std::string name(id_name(image)); + std::string translated_name(translate_id(name)); + bool not_yet_exported = find(mImages.begin(), mImages.end(), translated_name) == mImages.end(); + + if (not_yet_exported) { + + ImBuf *imbuf = BKE_image_get_ibuf(image, NULL); + bool is_dirty = imbuf->userflags & IB_BITMAPDIRTY; + + ImageFormatData imageFormat; + BKE_imbuf_to_image_format(&imageFormat, imbuf); + + short image_source = image->source; + bool is_generated = image_source == IMA_SRC_GENERATED; + + char export_path[FILE_MAX]; + char source_path[FILE_MAX]; + char export_dir[FILE_MAX]; + char export_file[FILE_MAX]; + + // Destination folder for exported assets + BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir)); + + if (is_generated || is_dirty || use_copies) { + + // make absolute destination path + + BLI_strncpy(export_file, name.c_str(), sizeof(export_file)); + BKE_add_image_extension(export_file, imageFormat.imtype); + + BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file); + + // make dest directory if it doesn't exist + BLI_make_existing_file(export_path); + } + + if (is_generated || is_dirty) { + + // This image in its current state only exists in Blender memory. + // So we have to export it. The export will keep the image state intact, + // so the exported file will not be associated with the image. + + if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) { + fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path); + } + BLI_strncpy(export_path, export_file, sizeof(export_path)); + } + else { + + // make absolute source path + BLI_strncpy(source_path, image->name, sizeof(source_path)); + BLI_path_abs(source_path, G.main->name); + BLI_cleanup_path(NULL, source_path); + + if (use_copies) { + + // This image is already located on the file system. + // But we want to create copies here. + // To avoid overwroting images with same file name but + // differenet source locations + + if (BLI_copy(source_path, export_path) != 0) { + fprintf(stderr, "Collada export: Cannot copy image:\n source:%s\ndest :%s\n", source_path, export_path); + } + + BLI_strncpy(export_path, export_file, sizeof(export_path)); + + } + else { + + // Do not make any vopies, but use the source path directly as reference + // to the original image + + BLI_strncpy(export_path, source_path, sizeof(export_path)); + } + } + + COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)), translated_name, translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ + img.add(mSW); + fprintf(stdout, "Collada export: Added image: %s\n",export_file); + mImages.push_back(translated_name); + } +} + +void ImagesExporter::export_UV_Images() +{ + std::set<Image *> uv_textures; + LinkNode *node; + bool use_copies = this->export_settings->use_texture_copies; + for (node=this->export_settings->export_set; node; node=node->next) { + Object *ob = (Object *)node->link; + if (ob->type == OB_MESH && ob->totcol) { + Mesh *me = (Mesh *) ob->data; + BKE_mesh_tessface_ensure(me); + for (int i = 0; i < me->pdata.totlayer; i++) { + if (me->pdata.layers[i].type == CD_MTEXPOLY) { + MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; + MFace *mface = me->mface; + for (int j = 0; j < me->totpoly; j++, mface++, txface++) { + + Image *ima = txface->tpage; + if (ima == NULL) + continue; + + bool not_in_list = uv_textures.find(ima)==uv_textures.end(); + if (not_in_list) { + uv_textures.insert(ima); + export_UV_Image(ima, use_copies); + } + } + } + } + } + } +} + + bool ImagesExporter::hasImages(Scene *sce) { LinkNode *node; @@ -64,60 +192,51 @@ bool ImagesExporter::hasImages(Scene *sce) } } + if (ob->type == OB_MESH) { + Mesh *me = (Mesh *) ob->data; + BKE_mesh_tessface_ensure(me); + bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE); + if (has_uvs) { + int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); + for (int a = 0; a < num_layers; a++) { + MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); + Image *img = tface->tpage; + if (img) return true; + } + } + } + } return false; } void ImagesExporter::exportImages(Scene *sce) { - if (hasImages(sce)) { - openLibrary(); - MaterialFunctor mf; + openLibrary(); + + MaterialFunctor mf; + if (this->export_settings->include_material_textures) { mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set); + } - closeLibrary(); + if (this->export_settings->include_uv_textures) { + export_UV_Images(); } + + closeLibrary(); } + + void ImagesExporter::operator()(Material *ma, Object *ob) { int a; + bool use_texture_copies = this->export_settings->use_texture_copies; for (a = 0; a < MAX_MTEX; a++) { MTex *mtex = ma->mtex[a]; if (mtex && mtex->tex && mtex->tex->ima) { - Image *image = mtex->tex->ima; - std::string name(id_name(image)); - name = translate_id(name); - char rel[FILE_MAX]; - char abs[FILE_MAX]; - char src[FILE_MAX]; - char dir[FILE_MAX]; - - BLI_split_dir_part(this->export_settings->filepath, dir, sizeof(dir)); - - BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.main->name, image->name, dir); - - if (abs[0] != '\0') { - - // make absolute source path - BLI_strncpy(src, image->name, sizeof(src)); - BLI_path_abs(src, G.main->name); - - // make dest directory if it doesn't exist - BLI_make_existing_file(abs); - - if (BLI_copy(src, abs) != 0) { - fprintf(stderr, "Cannot copy image to file's directory.\n"); - } - } - - if (find(mImages.begin(), mImages.end(), name) == mImages.end()) { - COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(rel)), name, name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ - img.add(mSW); - - mImages.push_back(name); - } + export_UV_Image(image, use_texture_copies); } } } diff --git a/source/blender/collada/ImageExporter.h b/source/blender/collada/ImageExporter.h index a2abc893a56..0eaebdd5cdd 100644 --- a/source/blender/collada/ImageExporter.h +++ b/source/blender/collada/ImageExporter.h @@ -35,6 +35,7 @@ #include "COLLADASWLibraryImages.h" #include "DNA_material_types.h" +#include "DNA_image_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -49,6 +50,9 @@ public: void operator()(Material *ma, Object *ob); private: std::vector<std::string> mImages; // contains list of written images, to avoid duplicates + + void export_UV_Images(); + void export_UV_Image(Image *image, bool use_texture_copies); bool hasImages(Scene *sce); const ExportSettings *export_settings; }; diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index 788bd2a98b7..5908037d782 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -41,7 +41,7 @@ #include "collada_internal.h" #include "collada_utils.h" -void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob) +void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob, bool active_uv_only) { for (int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a + 1); @@ -52,16 +52,20 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia std::string matid(get_material_id(ma)); matid = translate_id(matid); std::ostringstream ostr; - ostr << translate_id(id_name(ma)); + ostr << matid; COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); // create <bind_vertex_input> for each uv map Mesh *me = (Mesh *)ob->data; int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE); + int map_index = 0; + int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE) -1; for (int b = 0; b < totlayer; b++) { - char *name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, b); - im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", b)); + if (!active_uv_only || b == active_uv_index) { + char *name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, map_index); + im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", map_index++)); + } } iml.push_back(im); diff --git a/source/blender/collada/InstanceWriter.h b/source/blender/collada/InstanceWriter.h index 87ddc7fb1f7..49ddf091b1c 100644 --- a/source/blender/collada/InstanceWriter.h +++ b/source/blender/collada/InstanceWriter.h @@ -35,7 +35,7 @@ class InstanceWriter { protected: - void add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob); + void add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob, bool active_uv_only); }; #endif diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index ef22a76d28e..5a1d8b7602a 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -31,7 +31,9 @@ #include "COLLADABUUtils.h" #include "collada_internal.h" -MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryMaterials(sw), export_settings(export_settings) { +MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryMaterials(sw), export_settings(export_settings) +{ + /* pass */ } void MaterialsExporter::exportMaterials(Scene *sce) @@ -49,7 +51,7 @@ void MaterialsExporter::exportMaterials(Scene *sce) bool MaterialsExporter::hasMaterials(Scene *sce) { LinkNode *node; - for(node=this->export_settings->export_set; node; node = node->next) { + for (node=this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *)node->link; int a; for (a = 0; a < ob->totcol; a++) { diff --git a/source/blender/collada/SConscript b/source/blender/collada/SConscript index 90d0d83d793..5d921681aea 100644 --- a/source/blender/collada/SConscript +++ b/source/blender/collada/SConscript @@ -32,9 +32,9 @@ defs = [] # TODO sanitize inc path building # relative paths to include dirs, space-separated, string if env['OURPLATFORM']=='darwin': - incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader [OPENCOLLADA]/GeneratedSaxParser '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) + incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../imbuf ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader [OPENCOLLADA]/GeneratedSaxParser '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) else: - incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) + incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../imbuf ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) if env['BF_BUILDINFO']: defs.append('WITH_BUILDINFO') diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index bd746e241ca..65f552d5d0c 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -141,7 +141,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) COLLADASW::InstanceGeometry instGeom(mSW); instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation))); - InstanceWriter::add_material_bindings(instGeom.getBindMaterial(), ob); + InstanceWriter::add_material_bindings(instGeom.getBindMaterial(), ob, this->export_settings->active_uv_only); instGeom.add(); } diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 0116f89361b..9b0d59d66ea 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -57,7 +57,9 @@ static const char *bc_get_joint_name(T *node) // This is used to store data passed in write_controller_data. // Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members // so that arrays don't get freed until we free them explicitly. -SkinInfo::SkinInfo() { +SkinInfo::SkinInfo() +{ + /* pass */ } SkinInfo::SkinInfo(const SkinInfo& skin) : weights(skin.weights), diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index be615f83787..d10cd7378e9 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -29,7 +29,9 @@ #include "TransformReader.h" -TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) { +TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) +{ + /* pass */ } void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob) diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 9a4fd44b9e9..f7e0f75ec5c 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -28,9 +28,9 @@ /* COLLADABU_ASSERT, may be able to remove later */ #include "COLLADABUPlatform.h" -#include "ExportSettings.h" #include "DocumentExporter.h" #include "DocumentImporter.h" +#include "ExportSettings.h" extern "C" { @@ -40,6 +40,7 @@ extern "C" /* make dummy file */ #include "BLI_fileops.h" #include "BLI_path_util.h" +#include "BLI_linklist.h" int collada_import(bContext *C, const char *filepath) { @@ -49,18 +50,25 @@ int collada_import(bContext *C, const char *filepath) return 0; } -int collada_export( - Scene *sce, - const char *filepath, - int selected, - int apply_modifiers, +int collada_export(Scene *sce, + const char *filepath, + + int apply_modifiers, + BC_export_mesh_type export_mesh_type, - int include_armatures, - int include_children, + int selected, + int include_children, + int include_armatures, + int deform_bones_only, - int use_object_instantiation, - int sort_by_name, - int second_life) + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + + int use_object_instantiation, + int sort_by_name, + int second_life) { ExportSettings export_settings; @@ -73,15 +81,24 @@ int collada_export( } /* end! */ + export_settings.filepath = (char *)filepath; - export_settings.selected = selected != 0; export_settings.apply_modifiers = apply_modifiers != 0; + export_settings.export_mesh_type = export_mesh_type; + export_settings.selected = selected != 0; + export_settings.include_children = include_children != 0; export_settings.include_armatures = include_armatures != 0; - export_settings.include_children = include_children != 0; - export_settings.second_life = second_life != 0; + export_settings.deform_bones_only = deform_bones_only != 0; + + export_settings.active_uv_only = active_uv_only != 0; + export_settings.include_uv_textures = include_uv_textures != 0; + export_settings.include_material_textures= include_material_textures != 0; + export_settings.use_texture_copies = use_texture_copies != 0; + export_settings.use_object_instantiation = use_object_instantiation != 0; export_settings.sort_by_name = sort_by_name != 0; - export_settings.filepath = (char *)filepath; + export_settings.second_life = second_life != 0; + int includeFilter = OB_REL_NONE; if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE; diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 8daf2b65fe2..13f8151da3d 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -27,28 +27,44 @@ #ifndef __COLLADA_H__ #define __COLLADA_H__ -struct bContext; -struct Scene; - +#include <stdlib.h> #ifdef __cplusplus extern "C" { #endif - /* - * both return 1 on success, 0 on error - */ - int collada_import(bContext *C, const char *filepath); - int collada_export( - Scene *sce, - const char *filepath, - int selected, - int apply_modifiers, - - int include_armatures, - int include_children, - - int use_object_instantiation, - int sort_by_name, - int second_life); + +#include "BLI_linklist.h" +#include "RNA_types.h" + +typedef enum BC_export_mesh_type { + BC_MESH_TYPE_VIEW, + BC_MESH_TYPE_RENDER +} BC_export_mesh_type; + +struct bContext; +struct Scene; + +/* + * both return 1 on success, 0 on error + */ +int collada_import(bContext *C, const char *filepath); +int collada_export(Scene *sce, + const char *filepath, + int apply_modifiers, + BC_export_mesh_type export_mesh_type, + + int selected, + int include_children, + int include_armatures, + int deform_bones_only, + + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + + int use_object_instantiation, + int sort_by_name, + int second_life); diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 0ee8419eda7..a4969735757 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -31,7 +31,9 @@ #include "BLI_linklist.h" -UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) { +UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) +{ + /* pass */ } void UnitConverter::read_asset(const COLLADAFW::FileInfo *asset) diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index aa6f0b3c515..cb9da9918be 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -34,11 +34,14 @@ #include "collada_utils.h" +extern "C" { + #include "DNA_modifier_types.h" #include "DNA_customdata_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" +#include "DNA_armature_types.h" #include "BLI_math.h" @@ -49,13 +52,13 @@ #include "BKE_mesh.h" #include "BKE_scene.h" -extern "C" { #include "BKE_DerivedMesh.h" #include "BLI_linklist.h" -} + #include "WM_api.h" // XXX hrm, see if we can do without this #include "WM_types.h" +} float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index) { @@ -135,11 +138,22 @@ Object *bc_add_object(Scene *scene, int type, const char *name) return ob; } -Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob) +Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type) { Mesh *tmpmesh; CustomDataMask mask = CD_MASK_MESH; - DerivedMesh *dm = mesh_create_derived_view(scene, ob, mask); + DerivedMesh *dm; + switch (export_mesh_type) { + case BC_MESH_TYPE_VIEW: { + dm = mesh_create_derived_view(scene, ob, mask); + break; + } + case BC_MESH_TYPE_RENDER: { + dm = mesh_create_derived_render(scene, ob, mask); + break; + } + } + tmpmesh = BKE_mesh_add("ColladaMesh"); // name is not important here DM_to_mesh(dm, tmpmesh, ob); dm->release(dm); @@ -181,6 +195,7 @@ Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *o return ancestor; } + bool bc_is_base_node(LinkNode *export_set, Object *ob) { Object *root = bc_get_highest_selected_ancestor_or_self(export_set, ob); @@ -189,30 +204,19 @@ bool bc_is_base_node(LinkNode *export_set, Object *ob) bool bc_is_in_Export_set(LinkNode *export_set, Object *ob) { - LinkNode *node = export_set; - - while (node) { - Object *element = (Object *)node->link; - - if (element == ob) - return true; - - node= node->next; - } - return false; + return (BLI_linklist_index(export_set, ob) != -1); } bool bc_has_object_type(LinkNode *export_set, short obtype) { - LinkNode *node = export_set; + LinkNode *node; - while (node) { + for (node = export_set; node; node = node->next) { Object *ob = (Object *)node->link; - + /* XXX - why is this checking for ob->data? - we could be looking for empties */ if (ob->type == obtype && ob->data) { return true; } - node= node->next; } return false; } @@ -232,19 +236,16 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set) { bool sorted = false; LinkNode *node; - for(node=export_set; node->next && !sorted; node=node->next) { + for (node = export_set; node->next && !sorted; node = node->next) { sorted = true; LinkNode *current; - for (current=export_set; current->next; current = current->next) { + for (current = export_set; current->next; current = current->next) { Object *a = (Object *)current->link; Object *b = (Object *)current->next->link; - std::string str_a (a->id.name); - std::string str_b (b->id.name); - - if (str_a.compare(str_b) > 0) { + if (strcmp(a->id.name, b->id.name) > 0) { current->link = b; current->next->link = a; sorted = false; @@ -253,3 +254,30 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set) } } } + +/* Check if a bone is the top most exportable bone in the bone hierarchy. + * When deform_bones_only == false, then only bones with NO parent + * can be root bones. Otherwise the top most deform bones in the hierarchy + * are root bones. + */ +bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) +{ + if (deform_bones_only) { + Bone *root = NULL; + Bone *bone = aBone; + while (bone) { + if (!(bone->flag & BONE_NO_DEFORM)) + root = bone; + bone = bone->parent; + } + return (aBone == root); + } + else + return !(aBone->parent); +} + +int bc_get_active_UVLayer(Object *ob) +{ + Mesh *me = (Mesh *)ob->data; + return CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); +} diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index 139a2cb93bd..5f72581f584 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -51,13 +51,13 @@ extern "C" { #include "ExportSettings.h" -typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex*> > TexIndexTextureArrayMap; +typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex *> > TexIndexTextureArrayMap; extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index); extern int bc_test_parent_loop(Object *par, Object *ob); -extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space=true); +extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true); extern Object *bc_add_object(Scene *scene, int type, const char *name); -extern Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob); +extern Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type); extern Object *bc_get_assigned_armature(Object *ob); extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob); @@ -72,5 +72,7 @@ extern char *bc_CustomData_get_layer_name(const CustomData *data, int type, int extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int type); extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); +extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only); +extern int bc_get_active_UVLayer(Object *ob); #endif diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index fbe391a554d..d0093c58d23 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -288,6 +288,10 @@ set(SRC nodes/COM_BokehBlurNode.h nodes/COM_DirectionalBlurNode.cpp nodes/COM_DirectionalBlurNode.h + operations/COM_GaussianAlphaXBlurOperation.cpp + operations/COM_GaussianAlphaXBlurOperation.h + operations/COM_GaussianAlphaYBlurOperation.cpp + operations/COM_GaussianAlphaYBlurOperation.h operations/COM_GaussianXBlurOperation.cpp operations/COM_GaussianXBlurOperation.h operations/COM_GaussianYBlurOperation.cpp diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index 4789fed2efd..4d8c83a5b2d 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -297,7 +297,7 @@ extern "C" { * - output nodes can have different priorities in the WorkScheduler. * This is implemented in the COM_execute function. */ -void COM_execute(bNodeTree *editingtree, int rendering); +void COM_execute(RenderData* rd, bNodeTree *editingtree, int rendering); #ifdef __cplusplus } diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h index 57b73c836df..e11048b23f3 100644 --- a/source/blender/compositor/COM_defines.h +++ b/source/blender/compositor/COM_defines.h @@ -67,7 +67,7 @@ typedef enum CompositorPriority { // chunk size determination #define COM_PREVIEW_SIZE 140.0f -//#define COM_OPENCL_ENABLED +#define COM_OPENCL_ENABLED //#define COM_DEBUG // workscheduler threading models diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index bb8e7d9606d..c3470f0a16e 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -26,7 +26,7 @@ CompositorContext::CompositorContext() { - this->scene = NULL; + this->rd = NULL; this->quality = COM_QUALITY_HIGH; this->hasActiveOpenCLDevices = false; this->activegNode = NULL; @@ -34,8 +34,8 @@ CompositorContext::CompositorContext() const int CompositorContext::getFramenumber() const { - if (this->scene) { - return this->scene->r.cfra; + if (this->rd) { + return this->rd->cfra; } else { return -1; /* this should never happen */ @@ -44,8 +44,8 @@ const int CompositorContext::getFramenumber() const const int CompositorContext::isColorManaged() const { - if (this->scene) { - return this->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + if (this->rd) { + return this->rd->color_mgt_flag & R_COLOR_MANAGEMENT; } else { return 0; /* this should never happen */ diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 93872f4839f..81fd81b4117 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -51,11 +51,11 @@ private: CompositorQuality quality; /** - * @brief Reference to the scene that is being composited. + * @brief Reference to the render data that is being composited. * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - Scene *scene; + RenderData *rd; /** * @brief reference to the bNodeTree @@ -93,7 +93,7 @@ public: /** * @brief set the scene of the context */ - void setScene(Scene *scene) { this->scene = scene; } + void setRenderData(RenderData *rd) { this->rd = rd; } /** * @brief set the bnodetree of the context @@ -118,7 +118,7 @@ public: /** * @brief get the scene of the context */ - const Scene *getScene() const { return this->scene; } + const RenderData *getRenderData() const { return this->rd; } /** * @brief set the quality diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index fa30d965938..0a8862e4017 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -20,100 +20,102 @@ * Monique Dewanchand */ -#include "COM_Converter.h" +#include <string.h> + #include "BKE_node.h" -#include "COM_CompositorNode.h" -#include "COM_RenderLayersNode.h" + +#include "COM_AlphaOverNode.h" +#include "COM_BilateralBlurNode.h" +#include "COM_BlurNode.h" +#include "COM_BokehBlurNode.h" +#include "COM_BokehImageNode.h" +#include "COM_BoxMaskNode.h" +#include "COM_BrightnessNode.h" +#include "COM_ChannelMatteNode.h" +#include "COM_ChromaMatteNode.h" +#include "COM_ColorBalanceNode.h" +#include "COM_ColorCorrectionNode.h" +#include "COM_ColorCurveNode.h" +#include "COM_ColorMatteNode.h" +#include "COM_ColorNode.h" +#include "COM_ColorRampNode.h" +#include "COM_ColorSpillNode.h" #include "COM_ColorToBWNode.h" -#include "string.h" -#include "COM_SocketConnection.h" +#include "COM_CombineHSVANode.h" +#include "COM_CombineRGBANode.h" +#include "COM_CombineYCCANode.h" +#include "COM_CombineYUVANode.h" +#include "COM_CompositorNode.h" +#include "COM_ConvertAlphaNode.h" +#include "COM_ConvertColorToVectorOperation.h" #include "COM_ConvertColourToValueProg.h" #include "COM_ConvertValueToColourProg.h" -#include "COM_ConvertColorToVectorOperation.h" #include "COM_ConvertValueToVectorOperation.h" #include "COM_ConvertVectorToColorOperation.h" #include "COM_ConvertVectorToValueOperation.h" +#include "COM_Converter.h" +#include "COM_CropNode.h" +#include "COM_DefocusNode.h" +#include "COM_DifferenceMatteNode.h" +#include "COM_DilateErodeNode.h" +#include "COM_DirectionalBlurNode.h" +#include "COM_DisplaceNode.h" +#include "COM_DistanceMatteNode.h" +#include "COM_DoubleEdgeMaskNode.h" +#include "COM_EllipseMaskNode.h" #include "COM_ExecutionSystem.h" +#include "COM_ExecutionSystemHelper.h" +#include "COM_FilterNode.h" +#include "COM_FlipNode.h" +#include "COM_GammaNode.h" +#include "COM_GlareNode.h" +#include "COM_GroupNode.h" +#include "COM_HueSaturationValueCorrectNode.h" +#include "COM_HueSaturationValueNode.h" +#include "COM_IDMaskNode.h" +#include "COM_ImageNode.h" +#include "COM_InvertNode.h" +#include "COM_KeyingNode.h" +#include "COM_KeyingScreenNode.h" +#include "COM_LensDistortionNode.h" +#include "COM_LuminanceMatteNode.h" +#include "COM_MapUVNode.h" +#include "COM_MapValueNode.h" +#include "COM_MaskNode.h" +#include "COM_MathNode.h" #include "COM_MixNode.h" +#include "COM_MovieClipNode.h" +#include "COM_MovieDistortionNode.h" #include "COM_MuteNode.h" -#include "COM_TranslateNode.h" +#include "COM_NormalNode.h" +#include "COM_NormalizeNode.h" +#include "COM_OutputFileNode.h" +#include "COM_RenderLayersNode.h" #include "COM_RotateNode.h" #include "COM_ScaleNode.h" -#include "COM_FlipNode.h" -#include "COM_IDMaskNode.h" -#include "COM_FilterNode.h" -#include "COM_BrightnessNode.h" -#include "COM_SeparateRGBANode.h" -#include "COM_CombineRGBANode.h" +#include "COM_ScaleOperation.h" #include "COM_SeparateHSVANode.h" -#include "COM_CombineHSVANode.h" -#include "COM_SeparateYUVANode.h" -#include "COM_CombineYUVANode.h" +#include "COM_SeparateRGBANode.h" #include "COM_SeparateYCCANode.h" -#include "COM_CombineYCCANode.h" -#include "COM_AlphaOverNode.h" -#include "COM_ColorBalanceNode.h" -#include "COM_ViewerNode.h" -#include "COM_SplitViewerNode.h" -#include "COM_InvertNode.h" -#include "COM_GroupNode.h" -#include "COM_NormalNode.h" -#include "COM_NormalizeNode.h" -#include "COM_ImageNode.h" -#include "COM_BokehImageNode.h" -#include "COM_ColorCurveNode.h" -#include "COM_VectorCurveNode.h" +#include "COM_SeparateYUVANode.h" #include "COM_SetAlphaNode.h" -#include "COM_ConvertAlphaNode.h" -#include "COM_MapUVNode.h" -#include "COM_DisplaceNode.h" -#include "COM_MathNode.h" -#include "COM_HueSaturationValueNode.h" -#include "COM_HueSaturationValueCorrectNode.h" -#include "COM_ColorCorrectionNode.h" -#include "COM_BoxMaskNode.h" -#include "COM_EllipseMaskNode.h" -#include "COM_GammaNode.h" -#include "COM_ColorRampNode.h" -#include "COM_DifferenceMatteNode.h" -#include "COM_LuminanceMatteNode.h" -#include "COM_DistanceMatteNode.h" -#include "COM_ChromaMatteNode.h" -#include "COM_ColorMatteNode.h" -#include "COM_ChannelMatteNode.h" -#include "COM_BlurNode.h" -#include "COM_BokehBlurNode.h" -#include "COM_DilateErodeNode.h" -#include "COM_TranslateOperation.h" -#include "COM_LensDistortionNode.h" +#include "COM_SetValueOperation.h" +#include "COM_SocketConnection.h" +#include "COM_SplitViewerNode.h" +#include "COM_Stabilize2dNode.h" +#include "COM_SwitchNode.h" #include "COM_TextureNode.h" -#include "COM_ColorNode.h" -#include "COM_ValueNode.h" #include "COM_TimeNode.h" -#include "COM_DirectionalBlurNode.h" -#include "COM_ZCombineNode.h" -#include "COM_SetValueOperation.h" -#include "COM_ScaleOperation.h" -#include "COM_ExecutionSystemHelper.h" #include "COM_TonemapNode.h" -#include "COM_SwitchNode.h" -#include "COM_GlareNode.h" -#include "COM_MovieClipNode.h" -#include "COM_ColorSpillNode.h" -#include "COM_OutputFileNode.h" -#include "COM_MapValueNode.h" #include "COM_TransformNode.h" -#include "COM_Stabilize2dNode.h" -#include "COM_BilateralBlurNode.h" +#include "COM_TranslateNode.h" +#include "COM_TranslateOperation.h" +#include "COM_ValueNode.h" #include "COM_VectorBlurNode.h" -#include "COM_MovieDistortionNode.h" +#include "COM_VectorCurveNode.h" #include "COM_ViewLevelsNode.h" -#include "COM_DefocusNode.h" -#include "COM_DoubleEdgeMaskNode.h" -#include "COM_CropNode.h" -#include "COM_MaskNode.h" -#include "COM_KeyingScreenNode.h" -#include "COM_KeyingNode.h" +#include "COM_ViewerNode.h" +#include "COM_ZCombineNode.h" Node *Converter::convert(bNode *bNode) { diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h index 08fdb5bb578..2a86382a191 100644 --- a/source/blender/compositor/intern/COM_Device.h +++ b/source/blender/compositor/intern/COM_Device.h @@ -23,11 +23,7 @@ #ifndef _COM_Device_h #define _COM_Device_h -#include "COM_ExecutionSystem.h" #include "COM_WorkPackage.h" -#include "COM_NodeOperation.h" -#include "BLI_rect.h" -#include "COM_MemoryBuffer.h" /** * @brief Abstract class for device implementations to be used by the Compositor. diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 2a790da0354..4dfb9c7d26c 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -20,24 +20,25 @@ * Monique Dewanchand */ +#include <algorithm> +#include <math.h> +#include <sstream> +#include <stdlib.h> + +#include "BLI_math.h" +#include "PIL_time.h" + #include "COM_ExecutionGroup.h" #include "COM_InputSocket.h" #include "COM_SocketConnection.h" #include "COM_defines.h" -#include "math.h" #include "COM_ExecutionSystem.h" -#include <sstream> #include "COM_ReadBufferOperation.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" #include "COM_WorkScheduler.h" #include "COM_ViewerOperation.h" -#include <stdlib.h> -#include "BLI_math.h" -#include "PIL_time.h" #include "COM_ChunkOrder.h" -#include <algorithm> -#include "BLI_math.h" #include "COM_ExecutionSystemHelper.h" ExecutionGroup::ExecutionGroup() diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 7250a851f7b..7e09486fd0b 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -22,16 +22,18 @@ #include "COM_ExecutionSystem.h" +#include <sstream> +#include <stdio.h> + #include "PIL_time.h" #include "BKE_node.h" + #include "COM_Converter.h" -#include <sstream> #include "COM_NodeOperation.h" #include "COM_ExecutionGroup.h" #include "COM_NodeBase.h" #include "COM_WorkScheduler.h" #include "COM_ReadBufferOperation.h" -#include "stdio.h" #include "COM_GroupNode.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" @@ -39,7 +41,7 @@ #include "BKE_global.h" -ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) +ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering) { context.setbNodeTree(editingtree); bNode *gnode; @@ -60,22 +62,18 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) context.setRendering(rendering); context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL)); - Node *mainOutputNode = NULL; + ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); - mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); - - if (mainOutputNode) { - context.setScene((Scene *)mainOutputNode->getbNode()->id); - this->convertToOperations(); - this->groupOperations(); /* group operations in ExecutionGroups */ - unsigned int index; - unsigned int resolution[2]; - for (index = 0; index < this->groups.size(); index++) { - resolution[0] = 0; - resolution[1] = 0; - ExecutionGroup *executionGroup = groups[index]; - executionGroup->determineResolution(resolution); - } + context.setRenderData(rd); + this->convertToOperations(); + this->groupOperations(); /* group operations in ExecutionGroups */ + unsigned int index; + unsigned int resolution[2]; + for (index = 0; index < this->groups.size(); index++) { + resolution[0] = 0; + resolution[1] = 0; + ExecutionGroup *executionGroup = groups[index]; + executionGroup->determineResolution(resolution); } #ifdef COM_DEBUG diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 70fd94ca57f..48ff2ef6af9 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -156,7 +156,7 @@ public: * @param editingtree [bNodeTree*] * @param rendering [true false] */ - ExecutionSystem(bNodeTree *editingtree, bool rendering); + ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering); /** * Destructor diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index bcb606316ab..e5376567077 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -22,36 +22,34 @@ #include "COM_ExecutionSystemHelper.h" +#include <sstream> +#include <stdio.h> + #include "PIL_time.h" #include "BKE_node.h" + #include "COM_Converter.h" -#include <sstream> #include "COM_NodeOperation.h" #include "COM_ExecutionGroup.h" #include "COM_NodeBase.h" #include "COM_WorkScheduler.h" #include "COM_ReadBufferOperation.h" -#include "stdio.h" #include "COM_GroupNode.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" #include "COM_ViewerBaseOperation.h" -Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode) +void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode) { vector<Node *>& nodes = system.getNodes(); vector<SocketConnection *>& links = system.getConnections(); - Node *mainnode = NULL; const bNode *activeGroupNode = system.getContext().getActivegNode(); bool isActiveGroup = activeGroupNode == groupnode; /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; while (node != NULL) { - Node *execnode = addNode(nodes, node, isActiveGroup); - if (node->type == CMP_NODE_COMPOSITE) { - mainnode = execnode; - } + addNode(nodes, node, isActiveGroup); node = (bNode *)node->next; } @@ -72,8 +70,6 @@ Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_sta groupNode->ungroup(system); } } - - return mainnode; } void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index 99a05472075..8dbd308153b 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -48,7 +48,7 @@ public: * @param tree bNodeTree to add * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added */ - static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode); + static void addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode); /** * @brief add an editor node to the system. diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 62e030b777c..06b6164be3c 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -20,11 +20,12 @@ * Monique Dewanchand */ -#include "COM_Node.h" -#include "string.h" +#include <string.h> -#include "COM_NodeOperation.h" #include "BKE_node.h" + +#include "COM_Node.h" +#include "COM_NodeOperation.h" #include "COM_SetValueOperation.h" #include "COM_SetVectorOperation.h" #include "COM_SetColorOperation.h" @@ -35,7 +36,7 @@ #include "COM_SocketProxyNode.h" -//#include "stdio.h" +//#include <stdio.h> #include "COM_defines.h" Node::Node(bNode *editorNode, bool create_sockets) @@ -86,11 +87,15 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) { if (this->isInActiveGroup()) { - PreviewOperation *operation = new PreviewOperation(); - system->addOperation(operation); - operation->setbNode(this->getbNode()); - operation->setbNodeTree(system->getContext().getbNodeTree()); - this->addLink(system, outputSocket, operation->getInputSocket(0)); + if (!(this->getbNode()->flag & NODE_HIDDEN)) { // do not calculate previews of hidden nodes. + if (this->getbNode()->flag & NODE_PREVIEW) { + PreviewOperation *operation = new PreviewOperation(); + system->addOperation(operation); + operation->setbNode(this->getbNode()); + operation->setbNodeTree(system->getContext().getbNodeTree()); + this->addLink(system, outputSocket, operation->getInputSocket(0)); + } + } } } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 12baa26cd6e..090b1455440 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -29,6 +29,7 @@ #include "COM_CompositorContext.h" #include "DNA_node_types.h" #include "BKE_text.h" +#include "COM_ExecutionSystem.h" #include <vector> #include <string> diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp index 42946d7315e..1a895cf93b1 100644 --- a/source/blender/compositor/intern/COM_NodeBase.cpp +++ b/source/blender/compositor/intern/COM_NodeBase.cpp @@ -20,10 +20,12 @@ * Monique Dewanchand */ +#include <string.h> + +#include "BKE_node.h" + #include "COM_NodeBase.h" -#include "string.h" #include "COM_NodeOperation.h" -#include "BKE_node.h" #include "COM_SetValueOperation.h" #include "COM_SetColorOperation.h" #include "COM_SocketConnection.h" @@ -81,12 +83,14 @@ const bool NodeBase::isInputNode() const return this->inputsockets.size() == 0; } -OutputSocket *NodeBase::getOutputSocket(int index) +OutputSocket *NodeBase::getOutputSocket(unsigned int index) { + BLI_assert(index < this->outputsockets.size()); return this->outputsockets[index]; } -InputSocket *NodeBase::getInputSocket(int index) +InputSocket *NodeBase::getInputSocket(unsigned int index) { + BLI_assert(index < this->inputsockets.size()); return this->inputsockets[index]; } diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index 5e3a4fa5531..54f80926b84 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -103,7 +103,7 @@ public: * @param index * the index of the needed outputsocket */ - OutputSocket *getOutputSocket(const int index); + OutputSocket *getOutputSocket(const unsigned int index); /** * get the reference to the first outputsocket @@ -117,7 +117,7 @@ public: * @param index * the index of the needed inputsocket */ - InputSocket *getInputSocket(const int index); + InputSocket *getInputSocket(const unsigned int index); virtual bool isStatic() const { return false; } diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index 114d9f44cef..33989fa5787 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -20,12 +20,13 @@ * Monique Dewanchand */ -#include "COM_NodeOperation.h" #include <typeinfo> +#include <stdio.h> + +#include "COM_NodeOperation.h" #include "COM_InputSocket.h" #include "COM_SocketConnection.h" #include "COM_defines.h" -#include "stdio.h" NodeOperation::NodeOperation() { @@ -139,116 +140,3 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper return false; } } - -cl_mem NodeOperation::COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) -{ - cl_int error; - MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); - - const cl_image_format imageFormat = { - CL_RGBA, - CL_FLOAT - }; - - cl_mem clBuffer = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), - result->getHeight(), 0, result->getBuffer(), &error); - - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - if (error == CL_SUCCESS) cleanup->push_back(clBuffer); - - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); - return clBuffer; -} - -void NodeOperation::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer) -{ - if (offsetIndex != -1) { - cl_int error; - rcti *rect = memoryBuffer->getRect(); - cl_int2 offset = {rect->xmin, rect->ymin}; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - } -} - -void NodeOperation::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex) -{ - if (offsetIndex != -1) { - cl_int error; - cl_int2 offset = {this->getWidth(), this->getHeight()}; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - } -} - -void NodeOperation::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer) -{ - cl_int error; - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } -} - -void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) { - cl_int error; - const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; - - error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } -} - -void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex) { - cl_int error; - const int width = outputMemoryBuffer->getWidth(); - const int height = outputMemoryBuffer->getHeight(); - int offsetx; - int offsety; - const int localSize = 32; - size_t size[2]; - cl_int2 offset; - - bool breaked = false; - for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { - offset[1] = offsety; - if (offsety + localSize < height) { - size[1] = localSize; - } - else { - size[1] = height - offsety; - } - for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { - if (offsetx + localSize < width) { - size[0] = localSize; - } - else { - size[0] = width - offsetx; - } - offset[0] = offsetx; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - clFlush(queue); - if (isBreaked()) { - breaked = false; - } - } - } -} - -cl_kernel NodeOperation::COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) -{ - cl_int error; - cl_kernel kernel = clCreateKernel(program, kernelname, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - else { - if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); - } - return kernel; - -} diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 30731572712..f96b994685a 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -22,9 +22,7 @@ #ifndef _COM_NodeOperation_h #define _COM_NodeOperation_h - -class NodeOperation; - +class OpenCLDevice; #include "COM_Node.h" #include <string> #include <sstream> @@ -150,7 +148,7 @@ public: * @param memoryBuffers all input MemoryBuffer's needed * @param outputBuffer the outputbuffer to write to */ - virtual void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, + virtual void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer) {} /** @@ -165,7 +163,7 @@ public: * @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution * @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution */ - virtual void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {} + virtual void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {} virtual void deinitExecution(); bool isResolutionSet() { @@ -272,15 +270,6 @@ protected: * @brief set if this NodeOperation can be scheduled on a OpenCLDevice */ void setOpenCL(bool openCL) { this->openCL = openCL; } - - static cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); - static void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); - static void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); - void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex); - static void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); - void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex); - cl_kernel COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp); - }; #endif diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index 9d005804098..c9d27b8543c 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -23,13 +23,15 @@ #include "COM_OpenCLDevice.h" #include "COM_WorkScheduler.h" +typedef enum COM_VendorID {NVIDIA=0x10DE, AMD=0x1002} COM_VendorID; -OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program) +OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId) { this->device = device; this->context = context; this->program = program; this->queue = NULL; + this->vendorID = vendorId; } bool OpenCLDevice::initialize() @@ -56,10 +58,126 @@ void OpenCLDevice::execute(WorkPackage *work) MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect); - executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this->context, this->program, this->queue, &rect, + executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this, &rect, chunkNumber, inputBuffers, outputBuffer); delete outputBuffer; executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); } + +cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) +{ + cl_int error; + MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); + + const cl_image_format imageFormat = { + CL_RGBA, + CL_FLOAT + }; + + cl_mem clBuffer = clCreateImage2D(this->context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), + result->getHeight(), 0, result->getBuffer(), &error); + + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + if (error == CL_SUCCESS) cleanup->push_back(clBuffer); + + error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + + COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); + return clBuffer; +} + +void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer) +{ + if (offsetIndex != -1) { + cl_int error; + rcti *rect = memoryBuffer->getRect(); + cl_int2 offset = {rect->xmin, rect->ymin}; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + } +} + +void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation) +{ + if (offsetIndex != -1) { + cl_int error; + cl_int2 offset = {operation->getWidth(), operation->getHeight()}; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + } +} + +void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer) +{ + cl_int error; + error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } +} + +void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) +{ + cl_int error; + const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; + + error = clEnqueueNDRangeKernel(this->queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } +} + +void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation* operation) +{ + cl_int error; + const int width = outputMemoryBuffer->getWidth(); + const int height = outputMemoryBuffer->getHeight(); + int offsetx; + int offsety; + int localSize = 1024; + size_t size[2]; + cl_int2 offset; + + if (this->vendorID == NVIDIA){localSize = 32;} + bool breaked = false; + for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { + offset[1] = offsety; + if (offsety + localSize < height) { + size[1] = localSize; + } + else { + size[1] = height - offsety; + } + for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { + if (offsetx + localSize < width) { + size[0] = localSize; + } + else { + size[0] = width - offsetx; + } + offset[0] = offsetx; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + error = clEnqueueNDRangeKernel(this->queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + clFlush(this->queue); + if (operation->isBreaked()) { + breaked = false; + } + } + } +} + +cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) +{ + cl_int error; + cl_kernel kernel = clCreateKernel(this->program, kernelname, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + else { + if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); + } + return kernel; + +} diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index 83ce8cec811..d132f330651 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -29,7 +29,6 @@ class OpenCLDevice; #include "OCL_opencl.h" #include "COM_WorkScheduler.h" - /** * @brief device representing an GPU OpenCL device. * an instance of this class represents a single cl_device @@ -55,13 +54,21 @@ private: * @brief opencl command queue */ cl_command_queue queue; + + /** + * @brief opencl vendor ID + */ + cl_int vendorID; + public: /** * @brief constructor with opencl device * @param context * @param device + * @param program + * @param vendorID */ - OpenCLDevice(cl_context context, cl_device_id device, cl_program program); + OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId); /** @@ -83,6 +90,18 @@ public: * @param work the WorkPackage to execute */ void execute(WorkPackage *work); + + cl_context getContext(){return this->context;} + + cl_command_queue getQueue(){return this->queue;} + + cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); + void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); + void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); + void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation); + void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); + void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation* operation); + cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp); }; #endif diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h index 18d83cc151c..fed87186d20 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.h +++ b/source/blender/compositor/intern/COM_WorkPackage.h @@ -24,7 +24,7 @@ class WorkPackage; #ifndef _COM_WorkPackage_h_ #define _COM_WorkPackage_h_ - +class ExecutionGroup; #include "COM_ExecutionGroup.h" /** diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index fb7a8f8a764..619c5bea71e 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -21,15 +21,18 @@ */ #include <list> +#include <stdio.h> + +#include "BKE_global.h" + #include "COM_WorkScheduler.h" -#include "PIL_time.h" -#include "BLI_threads.h" #include "COM_CPUDevice.h" #include "COM_OpenCLDevice.h" -#include "OCL_opencl.h" -#include "stdio.h" #include "COM_OpenCLKernels.cl.h" -#include "BKE_global.h" +#include "OCL_opencl.h" + +#include "PIL_time.h" +#include "BLI_threads.h" #if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD #warning COM_CURRENT_THREADING_MODEL COM_TM_NOTHREAD is activated. Use only for debugging. @@ -214,60 +217,46 @@ void WorkScheduler::initialize() cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms]; error = clGetPlatformIDs(numberOfPlatforms, platforms, 0); unsigned int indexPlatform; - cl_uint totalNumberOfDevices = 0; for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices; + cl_uint numberOfDevices = 0; clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - totalNumberOfDevices += numberOfDevices; - } + if (numberOfDevices>0) { + cl_device_id *cldevices = new cl_device_id[numberOfDevices]; + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0); - cl_device_id *cldevices = new cl_device_id[totalNumberOfDevices]; - unsigned int numberOfDevicesReceived = 0; - for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { - cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices; - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices + numberOfDevicesReceived * sizeof (cl_device_id), 0); - numberOfDevicesReceived += numberOfDevices; - } - if (totalNumberOfDevices > 0) { - context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); - error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0); - if (error != CL_SUCCESS) { - cl_int error2; - size_t ret_val_size = 0; - printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - char *build_log = new char[ret_val_size + 1]; - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - build_log[ret_val_size] = '\0'; - printf("%s", build_log); - delete build_log; - - } - else { - unsigned int indexDevices; - for (indexDevices = 0; indexDevices < totalNumberOfDevices; indexDevices++) { - cl_device_id device = cldevices[indexDevices]; - OpenCLDevice *clDevice = new OpenCLDevice(context, device, program); - clDevice->initialize(), - gpudevices.push_back(clDevice); - if (G.f & G_DEBUG) { - char resultString[32]; - error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0); - printf("OPENCL_DEVICE: %s, ", resultString); - error = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 32, resultString, 0); - printf("%s\n", resultString); + context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); + error = clBuildProgram(program, numberOfDevices, cldevices, 0, 0, 0); + if (error != CL_SUCCESS) { + cl_int error2; + size_t ret_val_size = 0; + printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); + error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + char *build_log = new char[ret_val_size + 1]; + error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + build_log[ret_val_size] = '\0'; + printf("%s", build_log); + delete build_log; + } + else { + unsigned int indexDevices; + for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) { + cl_device_id device = cldevices[indexDevices]; + cl_int vendorID = 0; + cl_int error = clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL); + if (error!= CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + OpenCLDevice *clDevice = new OpenCLDevice(context, device, program, vendorID); + clDevice->initialize(); + gpudevices.push_back(clDevice); } } + delete cldevices; } } - delete[] cldevices; delete[] platforms; } #endif diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 2bbfd18e7c5..bec9ff95eed 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -25,6 +25,8 @@ extern "C" { #include "BLI_threads.h" } +#include "BKE_main.h" +#include "BKE_global.h" #include "COM_compositor.h" #include "COM_ExecutionSystem.h" @@ -32,7 +34,7 @@ extern "C" { #include "OCL_opencl.h" static ThreadMutex *compositorMutex; -void COM_execute(bNodeTree *editingtree, int rendering) +void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) { if (compositorMutex == NULL) { /// TODO: move to blender startup phase compositorMutex = new ThreadMutex(); @@ -41,7 +43,7 @@ void COM_execute(bNodeTree *editingtree, int rendering) WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere } BLI_mutex_lock(compositorMutex); - if (editingtree->test_break && editingtree->test_break(editingtree->tbh)) { + if (editingtree->test_break(editingtree->tbh)) { // during editing multiple calls to this method can be triggered. // make sure one the last one will be doing the work. BLI_mutex_unlock(compositorMutex); @@ -49,11 +51,12 @@ void COM_execute(bNodeTree *editingtree, int rendering) } + /* set progress bar to 0% and status to init compositing*/ editingtree->progress(editingtree->prh, 0.0); /* initialize execution system */ - ExecutionSystem *system = new ExecutionSystem(editingtree, rendering); + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering); system->execute(); delete system; diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp index 296056b6c48..59ec9525fa6 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp @@ -37,24 +37,24 @@ BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode) void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - Object *camob = context->getScene()->camera; +// Object *camob = context->getScene()->camera; - if (this->getInputSocket(2)->isConnected()) { - VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); - ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); - converter->setfStop(this->getbNode()->custom3); - converter->setCameraObject(camob); - operation->setMaxBlur((int)this->getbNode()->custom4); - operation->setQuality(context->getQuality()); - this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); - this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph); - addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2)); - graph->addOperation(operation); - graph->addOperation(converter); - this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - } - else { +// if (this->getInputSocket(2)->isConnected()) { +// VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); +// ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); +// converter->setfStop(this->getbNode()->custom3); +// converter->setCameraObject(camob); +// operation->setMaxBlur((int)this->getbNode()->custom4); +// operation->setQuality(context->getQuality()); +// this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); +// this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); +// this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), 2, graph); +// addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2)); +// graph->addOperation(operation); +// graph->addOperation(converter); +// this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); +// } +// else { BokehBlurOperation *operation = new BokehBlurOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); @@ -63,5 +63,5 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex operation->setQuality(context->getQuality()); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - } +// } } diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index fccb92ddd8b..6a6f2d1b4ff 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -35,7 +35,7 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte InputSocket *alphaSocket = this->getInputSocket(1); if (imageSocket->isConnected()) { CompositorOperation *colourAlphaProg = new CompositorOperation(); - colourAlphaProg->setScene(context->getScene()); + colourAlphaProg->setRenderData(context->getRenderData()); colourAlphaProg->setbNodeTree(context->getbNodeTree()); imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0)); alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1)); diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index d1f90b490ad..461505871c6 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -91,11 +91,16 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext graph->addOperation(bokeh); VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); - operation->setQuality(context->getQuality()); + if (data->preview) { + operation->setQuality(COM_QUALITY_LOW); + } else { + operation->setQuality(context->getQuality()); + } operation->setMaxBlur(data->maxblur); operation->setThreshold(data->bthresh); addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); + addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3)); if (data->gamco) { GammaCorrectOperation *correct = new GammaCorrectOperation(); GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index 6ee5b2a2b0d..285bfa0470e 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -25,6 +25,8 @@ #include "COM_ExecutionSystem.h" #include "COM_DilateErodeOperation.h" #include "COM_AntiAliasOperation.h" +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" #include "BLI_math.h" DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode) @@ -70,6 +72,58 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont graph->addOperation(operation); } } + else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_FEATHER) { + /* this uses a modified gaussian blur function otherwise its far too slow */ + CompositorQuality quality = context->getQuality(); + + /* initialize node data */ + NodeBlurData *data = (NodeBlurData *)&this->alpha_blur; + memset(data, 0, sizeof(*data)); + data->filtertype = R_FILTER_GAUSS; + + if (editorNode->custom2 > 0) { + data->sizex = data->sizey = editorNode->custom2; + } + else { + data->sizex = data->sizey = -editorNode->custom2; + + } + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); + // this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); // no size input yet + graph->addOperation(operationx); + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); + graph->addOperation(operationy); + addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); + // addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); // no size input yet + addPreviewOperation(graph, operationy->getOutputSocket()); + + /* TODO? */ + /* see gaussian blue node for original usage */ +#if 0 + if (!connectedSizeSocket) { + operationx->setSize(size); + operationy->setSize(size); + } +#else + operationx->setSize(1.0f); + operationy->setSize(1.0f); +#endif + operationx->setSubtract(editorNode->custom2 < 0); + operationy->setSubtract(editorNode->custom2 < 0); + + if (editorNode->storage) { + NodeDilateErode *data = (NodeDilateErode *)editorNode->storage; + operationx->setFalloff(data->falloff); + operationy->setFalloff(data->falloff); + } + } else { if (editorNode->custom2 > 0) { DilateStepOperation *operation = new DilateStepOperation(); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h index fa4e368e00d..ac374d7375b 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.h +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h @@ -30,6 +30,7 @@ * @ingroup Node */ class DilateErodeNode : public Node { + NodeBlurData alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ public: DilateErodeNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp index e5255b6bb87..6ad58caf17b 100644 --- a/source/blender/compositor/nodes/COM_GroupNode.cpp +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -37,6 +37,7 @@ void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c void GroupNode::ungroup(ExecutionSystem &system) { bNode *bnode = this->getbNode(); + bNodeTree *subtree = (bNodeTree *)bnode->id; vector<InputSocket *> &inputsockets = this->getInputSockets(); vector<OutputSocket *> &outputsockets = this->getOutputSockets(); unsigned int index; @@ -44,6 +45,10 @@ void GroupNode::ungroup(ExecutionSystem &system) /* get the node list size _before_ adding proxy nodes, so they are available for linking */ int nodes_start = system.getNodes().size(); + /* missing node group datablock can happen with library linking */ + if (!subtree) + return; + for (index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; bNodeSocket *editorInput = inputSocket->getbNodeSocket(); @@ -64,6 +69,5 @@ void GroupNode::ungroup(ExecutionSystem &system) } } - bNodeTree *subtree = (bNodeTree *)bnode->id; ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, bnode); } diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp index 6057a7f0e6c..df125403f98 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp @@ -46,27 +46,25 @@ void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, bNode *editorsnode = getbNode(); CurveMapping *storage = (CurveMapping *)editorsnode->storage; - if (colourSocket->isConnected() && outputSocket->isConnected()) { - ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); - ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); - HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); - MixBlendOperation *blend = new MixBlendOperation(); - - colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); - addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); - addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); - addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); - addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); - valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph); - outputSocket->relinkConnections(blend->getOutputSocket()); - - changeHSV->setCurveMapping(storage); - - blend->setResolutionInputSocketIndex(1); - - graph->addOperation(rgbToHSV); - graph->addOperation(hsvToRGB); - graph->addOperation(changeHSV); - graph->addOperation(blend); - } + ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); + ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); + HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); + MixBlendOperation *blend = new MixBlendOperation(); + + colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); + addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); + valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph); + outputSocket->relinkConnections(blend->getOutputSocket()); + + changeHSV->setCurveMapping(storage); + + blend->setResolutionInputSocketIndex(1); + + graph->addOperation(rgbToHSV); + graph->addOperation(hsvToRGB); + graph->addOperation(changeHSV); + graph->addOperation(blend); } diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp index 4005e5d2900..31d2ccb391e 100644 --- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp +++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp @@ -38,7 +38,7 @@ void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * operation->setObjectIndex(bnode->custom1); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - if (bnode->custom2 == 0 || context->getScene()->r.scemode & R_FULL_SAMPLE) { + if (bnode->custom2 == 0 || context->getRenderData()->scemode & R_FULL_SAMPLE) { this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); } else { diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp index 03034e34eb7..0319e66ee22 100644 --- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp @@ -39,7 +39,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); operation->setData(data); @@ -50,8 +50,8 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]); - operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); operation->setData(data); diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index ed07e41a649..13037b61a56 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -36,7 +36,7 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - const RenderData *data = &context->getScene()->r; + const RenderData *data = context->getRenderData(); OutputSocket *outputMask = this->getOutputSocket(0); @@ -55,7 +55,8 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setMask(mask); operation->setFramenumber(context->getFramenumber()); - operation->setSmooth((bool)editorNode->custom1); + operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0); + operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp index ccf7721b989..f52b7216cca 100644 --- a/source/blender/compositor/nodes/COM_MuteNode.cpp +++ b/source/blender/compositor/nodes/COM_MuteNode.cpp @@ -20,9 +20,10 @@ * Monique Dewanchand */ +#include <stdio.h> + #include "COM_MuteNode.h" #include "COM_SocketConnection.h" -#include "stdio.h" #include "COM_SetValueOperation.h" #include "COM_SetVectorOperation.h" #include "COM_SetColorOperation.h" diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp index 402529b9186..e85f521def0 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -37,15 +37,17 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage; if (!context->isRendering()) { - /* XXX TODO as in previous implementation? - * add dummy operations and exit, to prevent file writing on each compo update. + /* only output files when rendering a sequence - + * otherwise, it overwrites the output files just + * scrubbing through the timeline when the compositor updates. */ + return; } if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) { /* single output operation for the multilayer file */ OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation( - context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); + context->getRenderData(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); int num_inputs = getNumberOfInputSockets(); bool hasConnections = false; @@ -78,7 +80,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path); OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation( - context->getScene(), context->getbNodeTree(), input->getDataType(), format, path); + context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path); input->relinkConnections(outputOperation->getInputSocket(0)); graph->addOperation(outputOperation); if (!previewAdded) { diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp index 17b521c589d..95b048b6cad 100644 --- a/source/blender/compositor/nodes/COM_ScaleNode.cpp +++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp @@ -52,7 +52,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; case CMP_SCALE_SCENEPERCENT: { SetValueOperation *scaleFactorOperation = new SetValueOperation(); - scaleFactorOperation->setValue(context->getScene()->r.size / 100.0f); + scaleFactorOperation->setValue(context->getRenderData()->size / 100.0f); ScaleOperation *operation = new ScaleOperation(); inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1)); @@ -64,7 +64,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; case CMP_SCALE_RENDERPERCENT: { - const RenderData *data = &context->getScene()->r; + const RenderData *data = context->getRenderData(); ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation(); /* framing options */ diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp index 22a00410384..388466cee3c 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -39,8 +39,8 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont ImageUser *imageUser = (ImageUser *) this->getbNode()->storage; if (image1Socket->isConnected() && image2Socket->isConnected()) { SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); - splitViewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); - splitViewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + splitViewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); + splitViewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); splitViewerOperation->setImage(image); splitViewerOperation->setImageUser(imageUser); splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp index a3526e3c1a1..b035e0a392c 100644 --- a/source/blender/compositor/nodes/COM_TextureNode.cpp +++ b/source/blender/compositor/nodes/COM_TextureNode.cpp @@ -38,7 +38,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system); operation->setTexture(texture); - operation->setScene(context->getScene()); + operation->setRenderData(context->getRenderData()); system->addOperation(operation); addPreviewOperation(system, operation->getOutputSocket()); @@ -48,7 +48,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0)); addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1)); alphaOperation->setTexture(texture); - alphaOperation->setScene(context->getScene()); + alphaOperation->setRenderData(context->getRenderData()); system->addOperation(alphaOperation); } } diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index 9228fdbef85..1205767cb28 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -40,8 +40,8 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * bNode *editorNode = this->getbNode(); if (imageSocket->isConnected()) { ViewerOperation *viewerOperation = new ViewerOperation(); - viewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); - viewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + viewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); + viewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); viewerOperation->setbNodeTree(context->getbNodeTree()); viewerOperation->setImage(image); viewerOperation->setImageUser(imageUser); diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index bb915fec590..df64b7c8ddc 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -27,11 +27,11 @@ extern "C" { #include "RE_pipeline.h" } -BlurBaseOperation::BlurBaseOperation() : NodeOperation() +BlurBaseOperation::BlurBaseOperation(DataType data_type=COM_DT_COLOR) : NodeOperation() { - this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(data_type); this->addInputSocket(COM_DT_VALUE); - this->addOutputSocket(COM_DT_COLOR); + this->addOutputSocket(data_type); this->setComplex(true); this->inputProgram = NULL; this->data = NULL; @@ -89,6 +89,46 @@ float *BlurBaseOperation::make_gausstab(int rad) return gausstab; } +/* normalized distance from the current (inverted so 1.0 is close and 0.0 is far) + * 'ease' is applied after, looks nicer */ +float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff) +{ + float *dist_fac_invert, val; + int i, n; + + n = 2 * rad + 1; + + dist_fac_invert = new float[n]; + + for (i = -rad; i <= rad; i++) { + val = 1.0f - fabsf(((float)i / (float)rad)); + + /* keep in sync with proportional_falloff_curve_only_items */ + switch (falloff) { + case PROP_SMOOTH: + /* ease - gives less hard lines for dilate/erode feather */ + val = (3.0f * val * val - 2.0f * val * val * val); + break; + case PROP_SPHERE: + val = sqrtf(2.0f * val - val * val); + break; + case PROP_ROOT: + val = sqrtf(val); + break; + case PROP_SHARP: + val = val * val; + break; + case PROP_LIN: + default: + /* nothing */ + break; + } + dist_fac_invert[i + rad] = val; + } + + return dist_fac_invert; +} + void BlurBaseOperation::deinitExecution() { this->inputProgram = NULL; diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h index 84fc243a5af..8f7208274db 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.h +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h @@ -35,8 +35,9 @@ protected: SocketReader *inputProgram; SocketReader *inputSize; NodeBlurData *data; - BlurBaseOperation(); + BlurBaseOperation(DataType data_type); float *make_gausstab(int rad); + float *make_dist_fac_inverse(int rad, int falloff); float size; bool deleteData; bool sizeavailable; diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index dca087bb587..9fe5abcb075 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -22,6 +22,7 @@ #include "COM_BokehBlurOperation.h" #include "BLI_math.h" +#include "COM_OpenCLDevice.h" extern "C" { #include "RE_pipeline.h" @@ -73,13 +74,13 @@ void BokehBlurOperation::initExecution() void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; + float color_accum[4]; float tempBoundingBox[4]; float bokeh[4]; inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); if (tempBoundingBox[0] > 0.0f) { - float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -96,7 +97,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - zero_v4(tempColor); + zero_v4(color_accum); int step = getStep(); int offsetadd = getOffsetAdd(); @@ -108,15 +109,15 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * float u = this->bokehMidX - (nx - x) * m; float v = this->bokehMidY - (ny - y) * m; inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(tempColor, bokeh, &buffer[bufferindex]); - add_v4_v4(overallmultiplyer, bokeh); + madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); + add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; } } - color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]); - color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]); - color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]); - color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]); + color[0] = color_accum[0] * (1.0f / multiplier_accum[0]); + color[1] = color_accum[1] * (1.0f / multiplier_accum[1]); + color[2] = color_accum[2] * (1.0f / multiplier_accum[2]); + color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); @@ -160,25 +161,25 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe } static cl_kernel kernel = 0; -void BokehBlurOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!kernel) { - kernel = COM_clCreateKernel(program, "bokehBlurKernel", NULL); + kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); } cl_int radius = this->getWidth() * this->size / 100.0f; cl_int step = this->getStep(); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBokehProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBokehProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); clSetKernelArg(kernel, 6, sizeof(cl_int), &radius); clSetKernelArg(kernel, 7, sizeof(cl_int), &step); - COM_clAttachSizeToKernelParameter(kernel, 8); + device->COM_clAttachSizeToKernelParameter(kernel, 8, this); - COM_clEnqueueRange(queue, kernel, outputMemoryBuffer, 9); + device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this); } diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h index 3ec61c5ce01..853855d5c34 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h @@ -57,6 +57,6 @@ public: void setSize(float size) { this->size = size; } - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); }; #endif diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp index 3f9003b8c48..fe6be55e237 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp @@ -88,7 +88,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; - float sum; + float sum = 0.0f; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { pixels++; @@ -97,7 +97,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) { case 1: { - sum += buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f; + sum += rgb_to_bw(&buffer[offset]); break; } case 2: diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp index b0739cd7567..811975c5e13 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp @@ -46,7 +46,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; - float sum; + float sum = 0.0f; float mean = this->result; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { @@ -56,7 +56,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory { case 1: { - float value = buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f; + float value = rgb_to_bw(&buffer[offset]); sum += (value - mean) * (value - mean); break; } diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp index dff8ccf7e73..fb4e6f03e76 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp @@ -21,7 +21,7 @@ */ #include "COM_CombineChannelsOperation.h" -#include <stdio.h> +#include "BLI_utildefines.h" CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() { @@ -36,6 +36,31 @@ CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() this->inputChannel3Operation = NULL; this->inputChannel4Operation = NULL; } + +bool CombineChannelsOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti tempOutput; + bool first = true; + for (int i = 0 ; i < 4 ; i ++) { + NodeOperation * inputOperation = this->getInputOperation(i); + if (inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { + if (first) { + output->xmin = tempOutput.xmin; + output->ymin = tempOutput.ymin; + output->xmax = tempOutput.xmax; + output->ymax = tempOutput.ymax; + first = false; + } else { + output->xmin = MIN2(output->xmin, tempOutput.xmin); + output->ymin = MIN2(output->ymin, tempOutput.ymin); + output->xmax = MAX2(output->xmax, tempOutput.xmax); + output->ymax = MAX2(output->ymax, tempOutput.ymax); + } + } + } + return !first; +} + void CombineChannelsOperation::initExecution() { this->inputChannel1Operation = this->getInputSocketReader(0); diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h index d2977155e14..cc71f44b4f5 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.h +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h @@ -37,6 +37,8 @@ public: void initExecution(); void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 2b1a804b432..936cbaadd84 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -41,7 +41,7 @@ CompositorOperation::CompositorOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); - this->setScene(NULL); + this->setRenderData(NULL); this->outputBuffer = NULL; this->imageInput = NULL; this->alphaInput = NULL; @@ -60,11 +60,11 @@ void CompositorOperation::initExecution() void CompositorOperation::deinitExecution() { if (!isBreaked()) { - const Scene *scene = this->scene; - Render *re = RE_GetRender(scene->id.name); + const RenderData *rd = this->rd; + Render *re = RE_GetRender_FromData(rd); RenderResult *rr = RE_AcquireResultWrite(re); if (rr) { - if (rr->rectf != NULL) { + if (rr->rectf != NULL) { MEM_freeN(rr->rectf); } rr->rectf = outputBuffer; @@ -127,12 +127,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - int width = this->scene->r.xsch * this->scene->r.size / 100; - int height = this->scene->r.ysch * this->scene->r.size / 100; + int width = this->rd->xsch * this->rd->size / 100; + int height = this->rd->ysch * this->rd->size / 100; // check actual render resolution with cropping it may differ with cropped border.rendering // FIX for: [31777] Border Crop gives black (easy) - Render *re = RE_GetRender(this->scene->id.name); + Render *re = RE_GetRender_FromData(this->rd); if (re) { RenderResult *rr = RE_AcquireResultRead(re); if (rr) { diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index 0129c953946..280f39b7729 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -34,7 +34,7 @@ private: /** * @brief local reference to the scene */ - const Scene *scene; + const RenderData *rd; /** * @brief reference to the output float buffer @@ -53,7 +53,7 @@ private: public: CompositorOperation(); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); - void setScene(const Scene *scene) { this->scene = scene; } + void setRenderData(const RenderData *rd) { this->rd = rd; } bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp index c66cb8df9be..0e2c1e29a1d 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp @@ -38,7 +38,7 @@ void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float { float inputColor[4]; inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); - outputValue[0] = inputColor[0] * 0.35f + inputColor[1] * 0.45f + inputColor[2] * 0.2f; + outputValue[0] = rgb_to_bw(inputColor); } void ConvertColorToBWOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 306a2d96985..80d1c6444eb 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -22,6 +22,7 @@ #include "COM_DilateErodeOperation.h" #include "BLI_math.h" +#include "COM_OpenCLDevice.h" // DilateErode Distance Threshold DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() @@ -234,24 +235,24 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, Read } static cl_kernel dilateKernel = 0; -void DilateDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void DilateDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!dilateKernel) { - dilateKernel = COM_clCreateKernel(program, "dilateKernel", NULL); + dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); } cl_int distanceSquared = this->distance * this->distance; cl_int scope = this->scope; - COM_clAttachMemoryBufferToKernelParameter(context, dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope); clSetKernelArg(dilateKernel, 5, sizeof(cl_int), &distanceSquared); - COM_clAttachSizeToKernelParameter(dilateKernel, 6); - COM_clEnqueueRange(queue, dilateKernel, outputMemoryBuffer, 7); + device->COM_clAttachSizeToKernelParameter(dilateKernel, 6, this); + device->COM_clEnqueueRange(dilateKernel, outputMemoryBuffer, 7, this); } // Erode Distance @@ -293,24 +294,24 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff } static cl_kernel erodeKernel = 0; -void ErodeDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void ErodeDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!erodeKernel) { - erodeKernel = COM_clCreateKernel(program, "erodeKernel", NULL); + erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); } cl_int distanceSquared = this->distance * this->distance; cl_int scope = this->scope; - COM_clAttachMemoryBufferToKernelParameter(context, erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope); clSetKernelArg(erodeKernel, 5, sizeof(cl_int), &distanceSquared); - COM_clAttachSizeToKernelParameter(erodeKernel, 6); - COM_clEnqueueRange(queue, erodeKernel, outputMemoryBuffer, 7); + device->COM_clAttachSizeToKernelParameter(erodeKernel, 6, this); + device->COM_clEnqueueRange(erodeKernel, outputMemoryBuffer, 7, this); } // Dilate step diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h index b11356129b4..4d0bf9de0ec 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.h +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h @@ -99,7 +99,7 @@ public: void setDistance(float distance) { this->distance = distance; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); @@ -113,7 +113,7 @@ public: */ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index ba54c8ad9d6..8344a4d248b 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1216,7 +1216,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float gsz = rsize[2]; // by the do_*EdgeDetection() function. fsz = gsz + isz + osz; // calculate size of pixel index buffer needed - gbuf = (unsigned short *)MEM_callocN(sizeof (unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer + gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); // allocate edge/gradient pixel index buffer do_createEdgeLocationBuffer(t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz); do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset); diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 7830eef829c..7491b0f30dd 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -20,11 +20,13 @@ * Monique Dewanchand */ +#include <limits.h> + #include "COM_FastGaussianBlurOperation.h" #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" -FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation() +FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->iirgaus = NULL; } @@ -74,7 +76,7 @@ void FastGaussianBlurOperation::deinitExecution() delete this->iirgaus; this->iirgaus = NULL; } - BlurBaseOperation::deinitMutex(); + BlurBaseOperation::deinitMutex(); } void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -84,7 +86,7 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **m MemoryBuffer *newBuf = (MemoryBuffer *)this->inputProgram->initializeTileData(rect, memoryBuffers); MemoryBuffer *copy = newBuf->duplicate(); updateSize(memoryBuffers); - + int c; sx = data->sizex * this->size / 2.0f; sy = data->sizey * this->size / 2.0f; @@ -109,11 +111,14 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **m return iirgaus; } -void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int chan, int xy) +void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy) { double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3]; double *X, *Y, *W; - int i, x, y, sz; + const unsigned int src_width = src->getWidth(); + const unsigned int src_height = src->getHeight(); + unsigned int x, y, sz; + unsigned int i; float *buffer = src->getBuffer(); // <0.5 not valid, though can have a possibly useful sort of sharpening effect @@ -123,8 +128,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels, // so just skiping blur along faulty direction if src's def is below that limit! - if (src->getWidth() < 3) xy &= ~(int) 1; - if (src->getHeight() < 3) xy &= ~(int) 2; + if (src_width < 3) xy &= ~(int) 1; + if (src_height < 3) xy &= ~(int) 2; if (xy < 1) return; // see "Recursive Gabor Filtering" by Young/VanVliet @@ -178,33 +183,34 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \ Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \ Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \ - for (i = L - 4; i >= 0; i--) { \ + /* 'i != UINT_MAX' is really 'i >= 0', but necessary for unsigned int wrapping */ \ + for (i = L - 4; i != UINT_MAX; i--) { \ Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \ } \ } (void)0 // intermediate buffers - sz = MAX2(src->getWidth(), src->getHeight()); + sz = MAX2(src_width, src_height); X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); if (xy & 1) { // H - for (y = 0; y < src->getHeight(); ++y) { - const int yx = y * src->getWidth(); - for (x = 0; x < src->getWidth(); ++x) + for (y = 0; y < src_height; ++y) { + const int yx = y * src_width; + for (x = 0; x < src_width; ++x) X[x] = buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan]; - YVV(src->getWidth()); - for (x = 0; x < src->getWidth(); ++x) + YVV(src_width); + for (x = 0; x < src_width; ++x) buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan] = Y[x]; } } if (xy & 2) { // V - for (x = 0; x < src->getWidth(); ++x) { - for (y = 0; y < src->getHeight(); ++y) - X[y] = buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan]; - YVV(src->getHeight()); - for (y = 0; y < src->getHeight(); ++y) - buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan] = Y[y]; + for (x = 0; x < src_width; ++x) { + for (y = 0; y < src_height; ++y) + X[y] = buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan]; + YVV(src_height); + for (y = 0; y < src_height; ++y) + buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan] = Y[y]; } } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index f92e3dc68a5..0f3929f052c 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -36,7 +36,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); - static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy); + static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); void deinitExecution(); void initExecution(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp new file mode 100644 index 00000000000..954aef7b916 --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -0,0 +1,190 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#include "COM_GaussianAlphaXBlurOperation.h" +#include "BLI_math.h" + +extern "C" { + #include "RE_pipeline.h" +} + +GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE) +{ + this->gausstab = NULL; + this->rad = 0; +} + +void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + if (!this->sizeavailable) { + updateGauss(memoryBuffers); + } + void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + return buffer; +} + +void GaussianAlphaXBlurOperation::initExecution() +{ + /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ + + if (this->sizeavailable) { + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +{ + if (this->gausstab == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + } + + if (this->distbuf_inv == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +BLI_INLINE float finv_test(const float f, const bool test) +{ + return (LIKELY(test == false)) ? f : 1.0f - f; +} + +void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + const bool do_invert = this->do_subtract; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; + float *buffer = inputBuffer->getBuffer(); + int bufferwidth = inputBuffer->getWidth(); + int bufferstartx = inputBuffer->getRect()->xmin; + int bufferstarty = inputBuffer->getRect()->ymin; + + int miny = y; + int maxy = y; + int minx = x - this->rad; + int maxx = x + this->rad; + miny = max(miny, inputBuffer->getRect()->ymin); + minx = max(minx, inputBuffer->getRect()->xmin); + maxy = min(maxy, inputBuffer->getRect()->ymax); + maxx = min(maxx, inputBuffer->getRect()->xmax); + + /* *** this is the main part which is different to 'GaussianXBlurOperation' *** */ + int step = getStep(); + int offsetadd = getOffsetAdd(); + int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); + + /* gauss */ + float alpha_accum = 0.0f; + float multiplier_accum = 0.0f; + + /* dilate */ + float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ + float distfacinv_max = 1.0f; /* 0 to 1 */ + + for (int nx = minx; nx < maxx; nx += step) { + const int index = (nx - x) + this->rad; + float value = finv_test(buffer[bufferindex], do_invert); + float multiplier; + + /* gauss */ + { + multiplier = gausstab[index]; + alpha_accum += value * multiplier; + multiplier_accum += multiplier; + } + + /* dilate - find most extreme color */ + if (value > value_max) { + multiplier = distbuf_inv[index]; + value *= multiplier; + if (value > value_max) { + value_max = value; + distfacinv_max = multiplier; + } + } + bufferindex += offsetadd; + } + + /* blend between the max value and gauss blue - gives nice feather */ + const float value_blur = alpha_accum / multiplier_accum; + const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max)); + color[0] = finv_test(value_final, do_invert); +} + +void GaussianAlphaXBlurOperation::deinitExecution() +{ + BlurBaseOperation::deinitExecution(); + delete [] this->gausstab; + this->gausstab = NULL; + delete [] this->distbuf_inv; + this->distbuf_inv = NULL; +} + +bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; +#if 0 /* until we add size input */ + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } + else +#endif + { + if (this->sizeavailable && this->gausstab != NULL) { + newInput.xmax = input->xmax + rad; + newInput.xmin = input->xmin - rad; + newInput.ymax = input->ymax; + newInput.ymin = input->ymin; + } + else { + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + } + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + } +} diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h new file mode 100644 index 00000000000..38817ebef1d --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h @@ -0,0 +1,64 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#ifndef _COM_GaussianAlphaXBlurOperation_h +#define _COM_GaussianAlphaXBlurOperation_h +#include "COM_NodeOperation.h" +#include "COM_BlurBaseOperation.h" + +class GaussianAlphaXBlurOperation : public BlurBaseOperation { +private: + float *gausstab; + float *distbuf_inv; + int falloff; /* falloff for distbuf_inv */ + bool do_subtract; + int rad; + void updateGauss(MemoryBuffer **memoryBuffers); +public: + GaussianAlphaXBlurOperation(); + + /** + * @brief the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * @brief initialize the execution + */ + void initExecution(); + + /** + * @brief Deinitialize the execution + */ + void deinitExecution(); + + void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + + /** + * Set subtract for Dilate/Erode functionality + */ + void setSubtract(bool subtract) { this->do_subtract = subtract; } + void setFalloff(int falloff) { this->falloff = falloff; } +}; +#endif diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp new file mode 100644 index 00000000000..e1105cf94b1 --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -0,0 +1,190 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#include "COM_GaussianAlphaYBlurOperation.h" +#include "BLI_math.h" + +extern "C" { + #include "RE_pipeline.h" +} + +GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE) +{ + this->gausstab = NULL; + this->rad = 0; +} + +void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + if (!this->sizeavailable) { + updateGauss(memoryBuffers); + } + void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + return buffer; +} + +void GaussianAlphaYBlurOperation::initExecution() +{ + /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ + + if (this->sizeavailable) { + float rad = size * this->data->sizey; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) +{ + if (this->gausstab == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizey; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->gausstab = BlurBaseOperation::make_gausstab(rad); + } + + if (this->distbuf_inv == NULL) { + updateSize(memoryBuffers); + float rad = size * this->data->sizex; + if (rad < 1) + rad = 1; + + this->rad = rad; + this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff); + } +} + +BLI_INLINE float finv_test(const float f, const bool test) +{ + return (LIKELY(test == false)) ? f : 1.0f - f; +} + +void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + const bool do_invert = this->do_subtract; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; + float *buffer = inputBuffer->getBuffer(); + int bufferwidth = inputBuffer->getWidth(); + int bufferstartx = inputBuffer->getRect()->xmin; + int bufferstarty = inputBuffer->getRect()->ymin; + + int miny = y - this->rad; + int maxy = y + this->rad; + int minx = x; + int maxx = x; + miny = max(miny, inputBuffer->getRect()->ymin); + minx = max(minx, inputBuffer->getRect()->xmin); + maxy = min(maxy, inputBuffer->getRect()->ymax); + maxx = min(maxx, inputBuffer->getRect()->xmax); + + /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */ + int step = getStep(); + + /* gauss */ + float alpha_accum = 0.0f; + float multiplier_accum = 0.0f; + + /* dilate */ + float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */ + float distfacinv_max = 1.0f; /* 0 to 1 */ + + for (int ny = miny; ny < maxy; ny += step) { + int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); + + const int index = (ny - y) + this->rad; + float value = finv_test(buffer[bufferindex], do_invert); + float multiplier; + + /* gauss */ + { + multiplier = gausstab[index]; + alpha_accum += value * multiplier; + multiplier_accum += multiplier; + } + + /* dilate - find most extreme color */ + if (value > value_max) { + multiplier = distbuf_inv[index]; + value *= multiplier; + if (value > value_max) { + value_max = value; + distfacinv_max = multiplier; + } + } + + } + + /* blend between the max value and gauss blue - gives nice feather */ + const float value_blur = alpha_accum / multiplier_accum; + const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max)); + color[0] = finv_test(value_final, do_invert); +} + +void GaussianAlphaYBlurOperation::deinitExecution() +{ + BlurBaseOperation::deinitExecution(); + delete [] this->gausstab; + this->gausstab = NULL; + delete [] this->distbuf_inv; + this->distbuf_inv = NULL; +} + +bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newInput; +#if 0 /* until we add size input */ + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } + else +#endif + { + if (this->sizeavailable && this->gausstab != NULL) { + newInput.xmax = input->xmax; + newInput.xmin = input->xmin; + newInput.ymax = input->ymax + rad; + newInput.ymin = input->ymin - rad; + } + else { + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + } + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + } +} diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h new file mode 100644 index 00000000000..67166be8241 --- /dev/null +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h @@ -0,0 +1,64 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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: + * Jeroen Bakker + * Monique Dewanchand + * Campbell Barton + */ + +#ifndef _COM_GaussianAlphaYBlurOperation_h +#define _COM_GaussianAlphaYBlurOperation_h +#include "COM_NodeOperation.h" +#include "COM_BlurBaseOperation.h" + +class GaussianAlphaYBlurOperation : public BlurBaseOperation { +private: + float *gausstab; + float *distbuf_inv; + bool do_subtract; + int falloff; + int rad; + void updateGauss(MemoryBuffer **memoryBuffers); +public: + GaussianAlphaYBlurOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * @brief initialize the execution + */ + void initExecution(); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + + /** + * Set subtract for Dilate/Erode functionality + */ + void setSubtract(bool subtract) { this->do_subtract = subtract; } + void setFalloff(int falloff) { this->falloff = falloff; } +}; +#endif diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index b38ed28cd6a..dc9e354b124 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "RE_pipeline.h" } -GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation() +GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->gausstab = NULL; } @@ -115,7 +115,7 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory tempColor[1] = 0; tempColor[2] = 0; tempColor[3] = 0; - float overallmultiplyer = 0; + float multiplier_accum = 0; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -138,15 +138,15 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx); int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - const float multiplyer = gausstab[index]; - madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer); - overallmultiplyer += multiplyer; + const float multiplier = gausstab[index]; + madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; index += step; bufferindex += offsetadd; } } - mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); + mul_v4_v4fl(color, tempColor, 1.0f / multiplier_accum); } void GaussianBokehBlurOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 09a2a70ead3..7a1964a4a63 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "RE_pipeline.h" } -GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation() +GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->gausstab = NULL; this->rad = 0; @@ -72,12 +72,8 @@ void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; - tempColor[0] = 0; - tempColor[1] = 0; - tempColor[2] = 0; - tempColor[3] = 0; - float overallmultiplyer = 0.0f; + float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float multiplier_accum = 0.0f; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -99,12 +95,12 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { index = (nx - x) + this->rad; - const float multiplyer = gausstab[index]; - madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer); - overallmultiplyer += multiplyer; + const float multiplier = gausstab[index]; + madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; bufferindex += offsetadd; } - mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); + mul_v4_v4fl(color, color_accum, 1.0f / multiplier_accum); } void GaussianXBlurOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index ace817194f3..06c1c78d85a 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -27,7 +27,7 @@ extern "C" { #include "RE_pipeline.h" } -GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation() +GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->gausstab = NULL; this->rad = 0; @@ -69,12 +69,8 @@ void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; - tempColor[0] = 0; - tempColor[1] = 0; - tempColor[2] = 0; - tempColor[3] = 0; - float overallmultiplyer = 0; + float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float multiplier_accum = 0.0f; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -95,11 +91,11 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff for (int ny = miny; ny < maxy; ny += step) { index = (ny - y) + this->rad; int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); - const float multiplyer = gausstab[index]; - madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer); - overallmultiplyer += multiplyer; + const float multiplier = gausstab[index]; + madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); + multiplier_accum += multiplier; } - mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); + mul_v4_v4fl(color, color_accum, 1.0f / multiplier_accum); } void GaussianYBlurOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index 0a450cc3bf8..ae2913350f9 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -98,23 +98,42 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler int primary_channel = get_pixel_primary_channel(screenColor); - float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel); - - if (saturation < 0) { + if (pixelColor[primary_channel] > 1.0f) { + /* overexposure doesn't happen on screen itself and usually happens + * on light sources in the shot, this need to be checked separately + * because saturation and falloff calculation is based on the fact + * that pixels are not overexposured + */ color[0] = 1.0f; } - else if (saturation >= screen_saturation) { - color[0] = 0.0f; - } else { - float distance = 1.0f - saturation / screen_saturation; - - color[0] = distance; + float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel); + + if (saturation < 0) { + /* means main channel of pixel is different from screen, + * assume this is completely a foreground + */ + color[0] = 1.0f; + } + else if (saturation >= screen_saturation) { + /* matched main channels and higher saturation on pixel + * is treated as completely background + */ + color[0] = 0.0f; + } + else { + /* nice alpha falloff on edges */ + float distance = 1.0f - saturation / screen_saturation; + + color[0] = distance; + } } - color[0] *= (1.0f - garbageValue[0]); + /* apply garbage matte */ + color[0] = MIN2(color[0], 1.0f - garbageValue[0]); + /* apply core matte */ color[0] = MAX2(color[0], coreValue[0]); } diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index b728f6c5cca..9f7b69636ab 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -85,6 +85,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri int i; int width = this->getWidth(); int height = this->getHeight(); + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); if (this->trackingObject[0]) { MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject); @@ -102,7 +103,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri if (!sites_total) return NULL; - BKE_movieclip_user_set_frame(&user, framenumber); + BKE_movieclip_user_set_frame(&user, clip_frame); ibuf = BKE_movieclip_get_ibuf(movieClip, &user); if (!ibuf) @@ -115,7 +116,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri i = 0; while (track) { VoronoiSite *site = &sites[i]; - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenumber); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); int j; @@ -182,8 +183,9 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsig if (this->movieClip) { MovieClipUser user = {0}; int width, height; + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); - BKE_movieclip_user_set_frame(&user, framenumber); + BKE_movieclip_user_set_frame(&user, clip_frame); BKE_movieclip_get_size(this->movieClip, &user, &width, &height); resolution[0] = width; diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 0493bdee12c..3b7e98433e4 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -75,8 +75,8 @@ void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers float *buffer; buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->smooth); - if (this->smooth) { + BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->do_smooth, this->do_feather); + if (this->do_smooth) { PLX_antialias_buffer(buffer, width, height); } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 8507cb994c0..6b6d9aa9eeb 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -40,7 +40,8 @@ protected: int maskWidth; int maskHeight; int framenumber; - bool smooth; + bool do_smooth; + bool do_feather; float *rasterizedMask; /** @@ -60,7 +61,8 @@ public: void setMaskWidth(int width) { this->maskWidth = width; } void setMaskHeight(int height) { this->maskHeight = height; } void setFramenumber(int framenumber) { this->framenumber = framenumber; } - void setSmooth(bool smooth) { this->smooth = smooth; } + void setSmooth(bool smooth) { this->do_smooth = smooth; } + void setFeather(bool feather) { this->do_feather = feather; } void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); }; diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h index ef8668f6f21..e064b7511cb 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl.h +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.h @@ -16,7 +16,7 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " coords += offset;\n" \ " float tempBoundingBox;\n" \ " float4 color = {0.0f,0.0f,0.0f,0.0f};\n" \ -" float4 multiplyer = {0.0f,0.0f,0.0f,0.0f};\n" \ +" float4 multiplier = {0.0f,0.0f,0.0f,0.0f};\n" \ " float4 bokeh;\n" \ " const float radius2 = radius*2.0f;\n" \ " const int2 realCoordinate = coords + offsetOutput;\n" \ @@ -40,10 +40,10 @@ const char * clkernelstoh_COM_OpenCLKernels_cl = "/// This file contains all ope " uv.x = ((realCoordinate.x-nx)/radius2)*bokehImageDim.x+bokehImageCenter.x;\n" \ " bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv);\n" \ " color += bokeh * read_imagef(inputImage, SAMPLER_NEAREST, inputXy);\n" \ -" multiplyer += bokeh;\n" \ +" multiplier += bokeh;\n" \ " }\n" \ " }\n" \ -" color /= multiplyer;\n" \ +" color /= multiplier;\n" \ "\n" \ " } else {\n" \ " int2 imageCoordinates = realCoordinate - offsetInput;\n" \ diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index e71178a811d..c0aa139b032 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -92,9 +92,9 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN OutputSingleLayerOperation::OutputSingleLayerOperation( - const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) + const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) { - this->scene = scene; + this->rd = rd; this->tree = tree; this->addInputSocket(datatype); @@ -130,13 +130,13 @@ void OutputSingleLayerOperation::deinitExecution() ibuf->channels = size; ibuf->rect_float = this->outputBuffer; ibuf->mall |= IB_rectfloat; - ibuf->dither = scene->r.dither_intensity; + ibuf->dither = this->rd->dither_intensity; - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + if (this->rd->color_mgt_flag & R_COLOR_MANAGEMENT) ibuf->profile = IB_PROFILE_LINEAR_RGB; - BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, this->format->imtype, - (this->scene->r.scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, this->format->imtype, + (this->rd->scemode & R_EXTENSION), true); if (0 == BKE_imbuf_write(ibuf, filename, this->format)) printf("Cannot save Node File Output to %s\n", filename); @@ -160,9 +160,9 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype) } OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation( - const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec) + const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec) { - this->scene = scene; + this->rd = rd; this->tree = tree; BLI_strncpy(this->path, path, sizeof(this->path)); @@ -199,8 +199,8 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() char filename[FILE_MAX]; void *exrhandle = IMB_exr_get_handle(); - BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, R_IMF_IMTYPE_MULTILAYER, - (this->scene->r.scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, R_IMF_IMTYPE_MULTILAYER, + (this->rd->scemode & R_EXTENSION), true); BLI_make_existing_file(filename); for (unsigned int i = 0; i < layers.size(); ++i) { diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index cfc5f7e41f2..25ee5b31ec0 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -32,7 +32,7 @@ /* Writes the image to a single-layer file. */ class OutputSingleLayerOperation : public NodeOperation { private: - const Scene *scene; + const RenderData *rd; const bNodeTree *tree; ImageFormatData *format; @@ -43,7 +43,7 @@ private: SocketReader *imageInput; public: - OutputSingleLayerOperation(const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); + OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); bool isOutputOperation(bool rendering) const { return true; } @@ -67,7 +67,7 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation { private: typedef std::vector<OutputOpenExrLayer> LayerList; - const Scene *scene; + const RenderData *rd; const bNodeTree *tree; char path[FILE_MAX]; @@ -75,7 +75,7 @@ private: LayerList layers; public: - OutputOpenExrMultiLayerOperation(const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec); + OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec); void add_layer(const char *name, DataType datatype); diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index 77f2a06b29b..b337e435df4 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -27,19 +27,21 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->inputProgram = NULL; + this->dispersionAvailable = false; + this->dispersion = 0.0f; } void ProjectorLensDistortionOperation::initExecution() { this->inputProgram = this->getInputSocketReader(0); - kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr2 = kr * 20; } void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { + updateDispersion(memoryBuffers); void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } @@ -69,9 +71,28 @@ void ProjectorLensDistortionOperation::deinitExecution() bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.ymax = input->ymax; - newInput.ymin = input->ymin; - newInput.xmin = input->xmin - kr2 - 2; - newInput.xmax = input->xmax + kr2 + 2; + if (dispersionAvailable) { + newInput.ymax = input->ymax; + newInput.ymin = input->ymin; + newInput.xmin = input->xmin - kr2 - 2; + newInput.xmax = input->xmax + kr2 + 2; + } else { + newInput.xmin = 0; + newInput.ymin = input->ymin; + newInput.ymax = input->ymax; + newInput.xmax = inputProgram->getWidth(); + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } + +void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers) +{ + if (!dispersionAvailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + dispersion = result[0]; + kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); + kr2 = kr * 20; + dispersionAvailable = true; + } +} diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h index 2e188617ab5..5023a5df507 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -35,6 +35,8 @@ private: NodeLensDist *data; float dispersion; + bool dispersionAvailable; + float kr, kr2; public: ProjectorLensDistortionOperation(); @@ -56,9 +58,10 @@ public: void deinitExecution(); void setData(NodeLensDist *data) { this->data = data; } - void setDispertion(float dispersion) { this->dispersion = dispersion; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void updateDispersion(MemoryBuffer** inputBuffers); + }; #endif diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index fa1f0280207..857131950dd 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -48,14 +48,21 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigne } void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - MemoryBuffer *inputBuffer = inputBuffers[this->offset]; - if (inputBuffer) { - if (sampler == COM_PS_NEAREST) { - inputBuffer->read(color, x, y); - } - else { - inputBuffer->readCubic(color, x, y); + if (inputBuffers) { + MemoryBuffer *inputBuffer = inputBuffers[this->offset]; + if (inputBuffer) { + if (sampler == COM_PS_NEAREST) { + inputBuffer->read(color, x, y); + } + else { + inputBuffer->readCubic(color, x, y); + } } + } else { + color[0] = 0.0f; + color[1] = 0.0f; + color[2] = 0.0f; + color[3] = 0.0f; } } @@ -76,7 +83,8 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff return false; } -void ReadBufferOperation::readResolutionFromWriteBuffer() { +void ReadBufferOperation::readResolutionFromWriteBuffer() +{ if (this->memoryProxy != NULL) { WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation(); this->setWidth(operation->getWidth()); diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index ac06048faf3..456dc5d1d0f 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -48,7 +48,8 @@ void RotateOperation::deinitExecution() this->degreeSocket = NULL; } -inline void RotateOperation::ensureDegree() { +inline void RotateOperation::ensureDegree() +{ if (!isDegreeSet) { float degree[4]; this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index 3299434a02e..da3504de971 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -30,34 +30,24 @@ extern "C" { ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->inputProgram = NULL; + this->valuesAvailable = false; + this->dispersion = 0.0f; + this->distortion = 0.0f; } void ScreenLensDistortionOperation::initExecution() { this->inputProgram = this->getInputSocketReader(0); - kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); - // smaller dispersion range for somewhat more control - const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr = MAX2(MIN2((kg + d), 1.f), -0.999f); - kb = MAX2(MIN2((kg - d), 1.f), -0.999f); - maxk = MAX3(kr, kg, kb); - sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); - drg = 4.f * (kg - kr); - dgb = 4.f * (kb - kg); - - kr4 = kr * 4; - kg4 = kg * 4.f; - kb4 *= kb * 4.f; - cx = 0.5f * (float)getWidth(); - cy = 0.5f * (float)getHeight(); - } void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + updateDispersionAndDistortion(memoryBuffers); return buffer; } @@ -72,19 +62,20 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int float tc[4] = {0, 0, 0, 0}; const float v = sc * ((y + 0.5f) - cy) / cy; const float u = sc * ((x + 0.5f) - cx) / cx; + const float uv_dot = u * u + v * v; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - kr4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; sta = 1; } - if ((t = 1.f - kg4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - kg4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; mid = 1; } - if ((t = 1.f - kb4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - kb4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; end = 1; @@ -103,10 +94,10 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kr4 + tz * drg) * (u * u + v * v); + t = 1.f - (kr4 + tz * drg) * uv_dot; d = 1.f / (1.f + sqrtf(t)); - const float nx = (u * d + 0.5f) * getWidth() - 0.5f; - const float ny = (v * d + 0.5f) * getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; buffer->readCubic(color, nx, ny); tc[0] += (1.f - tz) * color[0], tc[1] += tz * color[1]; dr++, dg++; @@ -121,10 +112,10 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kg4 + tz * dgb) * (u * u + v * v); + t = 1.f - (kg4 + tz * dgb) * uv_dot; d = 1.f / (1.f + sqrtf(t)); - const float nx = (u * d + 0.5f) * getWidth() - 0.5f; - const float ny = (v * d + 0.5f) * getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; buffer->readCubic(color, nx, ny); tc[1] += (1.f - tz) * color[1], tc[2] += tz * color[2]; dg++, db++; @@ -170,3 +161,30 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input newInput.xmax = inputProgram->getWidth(); return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } + +void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) +{ + if (!valuesAvailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->distortion = result[0]; + this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->dispersion = result[0]; + kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); + // smaller dispersion range for somewhat more control + const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); + kr = MAX2(MIN2((kg + d), 1.f), -0.999f); + kb = MAX2(MIN2((kg - d), 1.f), -0.999f); + maxk = MAX3(kr, kg, kb); + sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); + drg = 4.f * (kg - kr); + dgb = 4.f * (kb - kg); + + kr4 = kr * 4.f; + kg4 = kg * 4.f; + kb4 = kb * 4.f; + cx = 0.5f * (float)getWidth(); + cy = 0.5f * (float)getHeight(); + valuesAvailable = true; + } +} diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index 34656f38a09..21babd11295 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -36,6 +36,7 @@ private: float dispersion; float distortion; + bool valuesAvailable; float kr, kg, kb; float kr4, kg4, kb4; float maxk; @@ -62,13 +63,12 @@ public: void deinitExecution(); void setData(NodeLensDist *data) { this->data = data; } - void setDispertion(float dispersion) { this->dispersion = dispersion; } - void setDistortion(float distortion) { this->distortion = distortion; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); private: void determineUV(float *result, float x, float y) const; + void updateDispersionAndDistortion(MemoryBuffer** inputBuffers); }; #endif diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index 072528f3fc6..dbdd17adbe4 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -32,7 +32,7 @@ TextureBaseOperation::TextureBaseOperation() : NodeOperation() this->texture = NULL; this->inputSize = NULL; this->inputOffset = NULL; - this->scene = NULL; + this->rd = NULL; } TextureOperation::TextureOperation() : TextureBaseOperation() { @@ -57,8 +57,8 @@ void TextureBaseOperation::deinitExecution() void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { if (preferredResolution[0] == 0 || preferredResolution[1] == 0) { - int width = this->scene->r.xsch * this->scene->r.size / 100; - int height = this->scene->r.ysch * this->scene->r.size / 100; + int width = this->rd->xsch * this->rd->size / 100; + int height = this->rd->ysch * this->rd->size / 100; resolution[0] = width; resolution[1] = height; } diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h index e862a1f1910..14714242511 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.h +++ b/source/blender/compositor/operations/COM_TextureOperation.h @@ -43,7 +43,7 @@ extern "C" { class TextureBaseOperation : public NodeOperation { private: Tex *texture; - const Scene *scene; + const RenderData *rd; SocketReader *inputSize; SocketReader *inputOffset; @@ -65,7 +65,7 @@ public: void setTexture(Tex *texture) { this->texture = texture; } void initExecution(); void deinitExecution(); - void setScene(const Scene *scene) { this->scene = scene; } + void setRenderData(const RenderData *rd) { this->rd = rd; } }; class TextureOperation : public TextureBaseOperation { diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 7c9b0c75518..c17e51e6391 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -31,15 +31,17 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image. - this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); // radius + this->addInputSocket(COM_DT_VALUE); // depth this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); this->inputProgram = NULL; this->inputBokehProgram = NULL; this->inputSizeProgram = NULL; + this->inputDepthProgram = NULL; this->maxBlur = 32.0f; - this->threshold = 0.0f; + this->threshold = 1.0f; } @@ -48,61 +50,62 @@ void VariableSizeBokehBlurOperation::initExecution() this->inputProgram = getInputSocketReader(0); this->inputBokehProgram = getInputSocketReader(1); this->inputSizeProgram = getInputSocketReader(2); + this->inputDepthProgram = getInputSocketReader(3); QualityStepHelper::initExecution(COM_QH_INCREASE); } void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - float tempColor[4]; float readColor[4]; float bokeh[4]; - tempColor[0] = 0; - tempColor[1] = 0; - tempColor[2] = 0; - tempColor[3] = 0; float tempSize[4]; - float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float tempDepth[4]; + float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; int miny = y - maxBlur; int maxy = y + maxBlur; int minx = x - maxBlur; int maxx = x + maxBlur; { + inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); + inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); - tempColor[0] += readColor[0]; - tempColor[1] += readColor[1]; - tempColor[2] += readColor[2]; - tempColor[3] += readColor[3]; - add_v4_v4(tempColor, readColor); - add_v3_fl(overallmultiplyer, 1.0f); + add_v4_v4(color_accum, readColor); + add_v4_fl(multiplier_accum, 1.0f); + float sizeCenter = tempSize[0]; + float centerDepth = tempDepth[0]+threshold; for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { + inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); float size = tempSize[0]; -// size += this->threshold; - float dx = nx - x; - float dy = ny - y; - if (nx == x && ny == y) { - /* pass */ - } - else if (size >= fabsf(dx) && size >= fabsf(dy)) { - float u = 256 + dx * 256 / size; - float v = 256 + dy * 256 / size; - inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); - madd_v4_v4v4(tempColor, bokeh, readColor); - add_v4_v4(overallmultiplyer, bokeh); + if (tempDepth[0] < centerDepth) { + if ((sizeCenter > threshold && size > threshold) || size <= threshold) { + float dx = nx - x; + float dy = ny - y; + if (nx == x && ny == y) { + } + else if (size >= fabsf(dx) && size >= fabsf(dy)) { + float u = 256 + dx * 256 / size; + float v = 256 + dy * 256 / size; + inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); + madd_v4_v4v4(color_accum, bokeh, readColor); + add_v4_v4(multiplier_accum, bokeh); + } + } } } } } - color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]); - color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]); - color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]); - color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]); + color[0] = color_accum[0] * (1.0f / multiplier_accum[0]); + color[1] = color_accum[1] * (1.0f / multiplier_accum[1]); + color[2] = color_accum[2] * (1.0f / multiplier_accum[2]); + color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } } @@ -136,6 +139,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) { return true; } + operation = getInputOperation(3); + if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { + return true; + } operation = getInputOperation(0); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index ede8f0333b4..d04bf08405f 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -32,6 +32,7 @@ private: SocketReader *inputProgram; SocketReader *inputBokehProgram; SocketReader *inputSizeProgram; + SocketReader *inputDepthProgram; public: VariableSizeBokehBlurOperation(); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index e1018e0d037..356ba452185 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -23,6 +23,7 @@ #include "COM_WriteBufferOperation.h" #include "COM_defines.h" #include <stdio.h> +#include "COM_OpenCLDevice.h" WriteBufferOperation::WriteBufferOperation() : NodeOperation() { @@ -110,7 +111,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me memoryBuffer->setCreatedState(); } -void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer) +void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer) { float *outputFloatBuffer = outputBuffer->getBuffer(); cl_int error; @@ -131,7 +132,7 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr CL_FLOAT }; - cl_mem clOutputBuffer = clCreateImage2D(context, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error); + cl_mem clOutputBuffer = clCreateImage2D(device->getContext(), CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } // STEP 2 @@ -139,7 +140,7 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr clMemToCleanUp->push_back(clOutputBuffer); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); - this->input->executeOpenCL(context, program, queue, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); + this->input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); // STEP 3 @@ -149,9 +150,9 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr // clFlush(queue); // clFinish(queue); - error = clEnqueueBarrier(queue); + error = clEnqueueBarrier(device->getQueue()); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueReadImage(queue, clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL); + error = clEnqueueReadImage(device->getQueue(), clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); @@ -175,7 +176,8 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr delete clKernelsToCleanUp; } -void WriteBufferOperation::readResolutionFromInputSocket() { +void WriteBufferOperation::readResolutionFromInputSocket() +{ NodeOperation *inputOperation = this->getInputOperation(0); this->setWidth(inputOperation->getWidth()); this->setHeight(inputOperation->getHeight()); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index 321eed7240a..ccc20584186 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -44,7 +44,7 @@ public: void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void initExecution(); void deinitExecution(); - void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); + void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); void readResolutionFromInputSocket(); }; diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 67ed77bcc4b..084006ce277 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -24,6 +24,7 @@ if(WITH_BLENDER) add_subdirectory(curve) add_subdirectory(gpencil) add_subdirectory(interface) + add_subdirectory(io) add_subdirectory(mask) add_subdirectory(mesh) add_subdirectory(metaball) diff --git a/source/blender/editors/SConscript b/source/blender/editors/SConscript index d08b496f0ef..6233ea0dc39 100644 --- a/source/blender/editors/SConscript +++ b/source/blender/editors/SConscript @@ -6,6 +6,7 @@ SConscript(['datafiles/SConscript', 'space_api/SConscript', 'util/SConscript', 'interface/SConscript', + 'io/SConscript', 'animation/SConscript', 'armature/SConscript', 'mask/SConscript', diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 103b23be466..c9b0f55740a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -184,7 +184,7 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction) //MovieClip *clip = ac->scene->clip; // struct Mask *mask = seq ? seq->mask : NULL; - saction->ads.source = (ID *)ac->scene;; + saction->ads.source = (ID *)ac->scene; ac->datatype = ANIMCONT_MASK; ac->data = &saction->ads; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index ea875567705..8c1e2bedd86 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -123,7 +123,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* basic settings (backdrop + mode selector + some padding) */ - /* col= uiLayoutColumn(layout, 1); */ /* UNUSED */ + /* col = uiLayoutColumn(layout, TRUE); */ /* UNUSED */ block = uiLayoutGetBlock(layout); uiBlockBeginAlign(block); but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); @@ -141,7 +141,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width - 30, 19, &data->poly_order, 1, 100, 0, 0, @@ -150,7 +150,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* draw controls for each coefficient and a + sign at end of row */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); cp = data->coefficients; @@ -177,7 +177,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, "+", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* next coefficient on a new row */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else { @@ -194,7 +194,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width - 30, 19, &data->poly_order, 1, 100, 0, 0, @@ -203,7 +203,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* draw controls for each pair of coefficients */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); cp = data->coefficients; @@ -230,7 +230,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* set up new row for the next pair of coefficients*/ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else @@ -253,11 +253,11 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* add the settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); // no grouping for now + col = uiLayoutColumn(layout, FALSE); // no grouping for now uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); @@ -278,16 +278,16 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* before range */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemL(col, IFACE_("Before:"), ICON_NONE); uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); /* after range */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemL(col, IFACE_("After:"), ICON_NONE); uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); @@ -308,15 +308,15 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE); /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* col 1 */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); /* col 2 */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); } @@ -499,18 +499,18 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); /* general settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Envelope:"), ICON_NONE); uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists // the current way is far too cramped - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -522,7 +522,7 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh /* control points list */ for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* get a new row to operate on */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); uiBlockBeginAlign(block); @@ -555,36 +555,36 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row 1: minimum */ { - /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ + /* row = uiLayoutRow(layout, FALSE); */ /* UNUSED */ /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* x-minimum */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); } /* row 2: maximum */ { - /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ + /* row = uiLayoutRow(layout, FALSE); */ /* UNUSED */ /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* x-minimum */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); } @@ -602,23 +602,23 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr); /* block 1: "stepping" settings */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); /* block 2: start range settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); /* block 3: end range settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); } @@ -642,11 +642,11 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* get layout-row + UI-block for this */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -664,7 +664,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier uiItemL(sub, "<Unknown Modifier>", ICON_NONE); /* right-align ------------------------------------------- */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); @@ -726,28 +726,28 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier box = uiLayoutBox(layout); /* restricted range ----------------------------------------------------- */ - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); /* top row: use restricted range */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { /* second row: settings */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); /* third row: blending influence */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE); uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE); } /* influence -------------------------------------------------------------- */ - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); /* top row: use influence */ uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index a8f8d2974e5..3883dce7671 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -156,7 +156,7 @@ void duplicate_fcurve_keys(FCurve *fcu) memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); - memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof (BezTriple) * (fcu->totvert - (i + 1))); + memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; /* reassign pointers... (free old, and add new) */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index b8601419d51..6250424d655 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -559,7 +559,6 @@ static short visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) const char *identifier = NULL; /* validate data */ - // TODO: this check is probably not needed, but it won't hurt if (ELEM3(NULL, ptr, ptr->data, prop)) return 0; @@ -635,6 +634,9 @@ static short visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) case CONSTRAINT_TYPE_TRACKTO: if (searchtype == VISUALKEY_ROT) return 1; break; + case CONSTRAINT_TYPE_DAMPTRACK: + if (searchtype == VISUALKEY_ROT) return 1; + break; case CONSTRAINT_TYPE_ROTLIMIT: if (searchtype == VISUALKEY_ROT) return 1; break; diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 4c125ebe013..dabc0ad1081 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -113,14 +113,14 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* get layout-row + UI-block for header */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* err... */ uiBlockSetEmboss(block, UI_EMBOSSN); /* left-align ............................... */ - sub = uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); /* active */ block = uiLayoutGetBlock(sub); @@ -151,7 +151,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* delete button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) { /* right-align ............................... */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ @@ -179,7 +179,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* delete 'button' */ uiBlockSetEmboss(block, UI_EMBOSSN); /* right-align ............................... */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ @@ -190,14 +190,14 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* new backdrop ----------------------------------- */ box = uiLayoutBox(layout); - split = uiLayoutSplit(box, 0.5f, 0); + split = uiLayoutSplit(box, 0.5f, FALSE); /* draw settings ---------------------------------- */ /* left column ..................... */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* color */ - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -210,10 +210,10 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons } /* right column ................... */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* onion-skinning */ - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "use_onion_skinning", 0, NULL, ICON_NONE); uiItemR(sub, &ptr, "ghost_range_max", 0, IFACE_("Frames"), ICON_NONE); @@ -236,14 +236,14 @@ static void draw_gpencil_space_specials(const bContext *C, uiLayout *layout) uiLayout *col, *row; SpaceClip *sc = CTX_wm_space_clip(C); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (sc) { bScreen *screen = CTX_wm_screen(C); PointerRNA sc_ptr; RNA_pointer_create(&screen->id, &RNA_SpaceClipEditor, sc, &sc_ptr); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &sc_ptr, "grease_pencil_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } @@ -262,7 +262,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin RNA_id_pointer_create((ID *)gpd, &gpd_ptr); /* draw gpd settings first ------------------------------------- */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); /* current Grease Pencil block */ /* TODO: show some info about who owns this? */ @@ -270,7 +270,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add"); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); @@ -280,12 +280,12 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* draw each layer --------------------------------------------- */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); gp_drawui_layer(col, gpd, gpl, is_v3d); } /* draw gpd drawing settings first ------------------------------------- */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* label */ uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); @@ -298,17 +298,17 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin } /* drawing space options */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); if (sc == NULL) { - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiLayoutSetActive(row, v3d_stroke_opts); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON); uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index ed530bea4bd..3f53f0403d7 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -146,7 +146,7 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) case SPACE_CLIP: /* Nodes Editor */ { SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 6d90824668e..12b002ef612 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -56,6 +56,7 @@ #include "ED_gpencil.h" #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_clip.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -1032,8 +1033,9 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) p->custom_color[3] = 0.9f; if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { - int framenr = sc->user.framenr; - MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); + MovieClip *clip = ED_space_clip_get_clip(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); + MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); p->imat[3][0] -= marker->pos[0]; diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 649266beec7..2670fb5b042 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -41,7 +41,9 @@ struct MovieClip; struct SpaceClip; struct wmEvent; -/* clip_editor.c */ +/* ** clip_editor.c ** */ + +/* common poll functions */ int ED_space_clip_poll(struct bContext *C); int ED_space_clip_view_clip_poll(struct bContext *C); @@ -50,40 +52,40 @@ int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_maskedit_poll(struct bContext *C); int ED_space_clip_maskedit_mask_poll(bContext *C); -void ED_space_clip_set(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); -struct MovieClip *ED_space_clip(struct SpaceClip *sc); -struct Mask *ED_space_clip_mask(struct SpaceClip *sc); -void ED_space_clip_size(struct SpaceClip *sc, int *width, int *height); -void ED_space_clip_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy); -void ED_space_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy); -void ED_space_clip_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); - -int ED_space_clip_clip_framenr(struct SpaceClip *sc); +void ED_space_clip_get_size(const struct bContext *C, int *width, int *height); +void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy); +void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy); +void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); -void ED_space_clip_mask_size(struct SpaceClip *sc, int *width, int *height); -void ED_space_clip_mask_aspect(struct SpaceClip *sc, float *aspx, float *aspy); +int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle); void ED_clip_update_frame(const struct Main *mainp, int cfra); -int ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit); +int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); + +void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]); +void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]); +void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); + +int ED_space_clip_check_show_trackedit(struct SpaceClip *sc); +int ED_space_clip_check_show_maskedit(struct SpaceClip *sc); -void ED_clip_point_undistorted_pos(SpaceClip * sc, const float co[2], float r_co[2]); -void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr); -void ED_clip_point_stable_pos__reverse(SpaceClip * sc, ARegion *ar, const float co[2], float r_co[2]); -void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]); +struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc); +void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); +struct Mask *ED_space_clip_get_mask(struct SpaceClip *sc); +void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask); + +/* textures buffer */ int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc); int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf); void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc); void ED_space_clip_free_texture_buffer(struct SpaceClip *sc); -int ED_space_clip_show_trackedit(struct SpaceClip *sc); -int ED_space_clip_show_maskedit(struct SpaceClip *sc); -void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask); - -/* clip_ops.c */ +/* ** clip_ops.c ** */ void ED_operatormacros_clip(void); -#endif /* ED_TEXT_H */ +#endif /* ED_CLIP_H */ diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 66e65d114cb..0979e3ec92b 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -61,6 +61,9 @@ void ED_node_link_insert(struct ScrArea *sa); void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree); void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node); + +void ED_node_sample_set(const float col[4]); + /* node ops.c */ void ED_operatormacros_node(void); diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index cea567254de..7ba26f30c39 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -33,4 +33,6 @@ struct Sequence; void ED_sequencer_select_sequence_single(struct Scene *scene, struct Sequence *seq, int deselect_all); void ED_sequencer_deselect_all(struct Scene *scene); +void ED_operatormacros_sequencer(void); + #endif /* __ED_SEQUENCER_H__ */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 3c802020747..c14e27562b4 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -878,7 +878,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), glPopMatrix(); /* min max */ - glColor3f(.5f, .5f, .5f); + glColor3f(0.5f, 0.5f, 0.5f); min = yofs + scopes->minmax[0][0] * h; max = yofs + scopes->minmax[0][1] * h; CLAMP(min, rect.ymin, rect.ymax); @@ -1012,7 +1012,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco int i, j; float w, h, centerx, centery, diam; float alpha; - const float colors[6][3] = {{.75, 0, 0}, {.75, .75, 0}, {0, .75, 0}, {0, .75, .75}, {0, 0, .75}, {.75, 0, .75}}; + const float colors[6][3] = { + {0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0}, + {0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}}; GLint scissor[4]; rect.xmin = (float)recti->xmin + 1; @@ -1308,7 +1310,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o fx = rect->xmin + zoomx * (-offsx); if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin)); while (fx < rect->xmax) { - glVertex2f(fx, rect->ymin); + glVertex2f(fx, rect->ymin); glVertex2f(fx, rect->ymax); fx += dx; } @@ -1317,7 +1319,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o fy = rect->ymin + zoomy * (-offsy); if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin)); while (fy < rect->ymax) { - glVertex2f(rect->xmin, fy); + glVertex2f(rect->xmin, fy); glVertex2f(rect->xmax, fy); fy += dy; } @@ -1344,7 +1346,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin); cuma = cumap->cm + cumap->cur; - + /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); scissor_new.xmin = ar->winrct.xmin + rect->xmin; @@ -1361,53 +1363,54 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect offsy = cumap->curr.ymin - but->aspect / zoomy; /* backdrop */ - if (cumap->flag & CUMA_DO_CLIP) { - gl_shaded_color((unsigned char *)wcol->inner, -20); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), - rect->ymin + zoomy * (cumap->clipr.ymin - offsy), - rect->xmin + zoomx * (cumap->clipr.xmax - offsx), - rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + if (but->a1 == UI_GRAD_H) { + /* magic trigger for curve backgrounds */ + rcti grid; + float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ + + grid.xmin = rect->xmin + zoomx * (-offsx); + grid.xmax = rect->xmax + zoomx * (-offsx); + grid.ymin = rect->ymin + zoomy * (-offsy); + grid.ymax = rect->ymax + zoomy * (-offsy); + + ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); + + /* grid, hsv uses different grid */ + gl_shaded_color((unsigned char *)wcol->inner, -16); + /* TODO, grid lines does not line up with colors, need to look into this */ + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.1666666f); } else { - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - } - - /* grid, every .25 step */ - gl_shaded_color((unsigned char *)wcol->inner, -16); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); - /* grid, every 1.0 step */ - gl_shaded_color((unsigned char *)wcol->inner, -24); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); - /* axes */ - gl_shaded_color((unsigned char *)wcol->inner, -50); - glBegin(GL_LINES); - glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); - glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); - glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin); - glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax); - glEnd(); - - /* magic trigger for curve backgrounds */ - if (but->a1 != -1) { - if (but->a1 == UI_GRAD_H) { - rcti grid; - float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ - - grid.xmin = rect->xmin + zoomx * (-offsx); - grid.xmax = rect->xmax + zoomx * (-offsx); - grid.ymin = rect->ymin + zoomy * (-offsy); - grid.ymax = rect->ymax + zoomy * (-offsy); - - glEnable(GL_BLEND); - ui_draw_gradient(&grid, col, UI_GRAD_H, 0.5f); - glDisable(GL_BLEND); + if (cumap->flag & CUMA_DO_CLIP) { + gl_shaded_color((unsigned char *)wcol->inner, -20); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + glColor3ubv((unsigned char *)wcol->inner); + glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), + rect->ymin + zoomy * (cumap->clipr.ymin - offsy), + rect->xmin + zoomx * (cumap->clipr.xmax - offsx), + rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + } + else { + glColor3ubv((unsigned char *)wcol->inner); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } + + /* grid, every 0.25 step */ + gl_shaded_color((unsigned char *)wcol->inner, -16); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); + /* grid, every 1.0 step */ + gl_shaded_color((unsigned char *)wcol->inner, -24); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); + /* axes */ + gl_shaded_color((unsigned char *)wcol->inner, -50); + glBegin(GL_LINES); + glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); + glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); + glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax); + glEnd(); } - - + /* cfra option */ /* XXX 2.48 */ #if 0 @@ -1421,11 +1424,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect #endif /* sample option */ - /* XXX 2.48 */ -#if 0 if (cumap->flag & CUMA_DRAW_SAMPLE) { - if (cumap->cur == 3) { - float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f; + if (but->a1 == UI_GRAD_H) { + float tsample[3]; + float hsv[3]; + linearrgb_to_srgb_v3_v3(tsample, cumap->sample); + rgb_to_hsv_v(tsample, hsv); + glColor3ub(240, 240, 240); + + glBegin(GL_LINES); + glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax); + glEnd(); + } + else if (cumap->cur == 3) { + float lum = rgb_to_bw(cumap->sample); glColor3ub(240, 240, 240); glBegin(GL_LINES); @@ -1447,7 +1460,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glEnd(); } } -#endif /* the curve */ glColor3ubv((unsigned char *)wcol->item); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a8a7a55c653..b82e7c3a1e2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6244,9 +6244,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case YKEY: case ZKEY: { - if ((event->val == KM_PRESS) && + if ((event->val == KM_PRESS) && (event->shift == FALSE) && - (event->ctrl == FALSE) && + (event->ctrl == FALSE) && (event->oskey == FALSE)) { for (but = block->buttons.first; but; but = but->next) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 385f74acbd2..737c0377f27 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -347,7 +347,7 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a glColor4f(0.0f, 0.0f, 0.0f, 1); viconutil_draw_lineloop_smooth(pts, 3); - glColor3f(.9f, .9f, .9f); + glColor3f(0.9f, 0.9f, 0.9f); viconutil_draw_points(pts, 3, 1); } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9af3ff3bdd8..1f88db033a4 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -447,7 +447,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *r /* interface_draw.c */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); -void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha); +void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha); void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 4c2d86de502..3270015271a 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -370,7 +370,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int colbuts = len / (2 * cols); int layer_used = 0; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE)); unit = UI_UNIT_X * 0.75; butw = unit; @@ -409,7 +409,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */ int row, col; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 1)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, TRUE)); totdim = RNA_property_array_dimension(ptr, prop, dim_size); if (totdim != 2) return; /* only 2D matrices supported in UI so far */ @@ -532,7 +532,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n PropertySubType subtype; int labelw; - sub = uiLayoutRow(layout, 0); + sub = uiLayoutRow(layout, FALSE); uiBlockSetCurLayout(block, sub); if (name[0]) { @@ -550,7 +550,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n subtype = RNA_property_subtype(prop); if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { - uiBlockSetCurLayout(block, uiLayoutRow(sub, 1)); + uiBlockSetCurLayout(block, uiLayoutRow(sub, TRUE)); uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ @@ -798,8 +798,8 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname if (prop && RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; - uiLayout *split = uiLayoutSplit(layout, 0, 0); - uiLayout *column = uiLayoutColumn(split, 0); + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = uiLayoutColumn(split, FALSE); RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item, &totitem, &free); @@ -825,7 +825,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname else { if (item[i].name) { if (i != 0) { - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= UI_BLOCK_NO_FLIP; } @@ -843,6 +843,14 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname MEM_freeN(item); } } + else if (prop && RNA_property_type(prop) != PROP_ENUM) { + RNA_warning("%s.%s, not an enum type", RNA_struct_identifier(ptr.type), propname); + return; + } + else { + RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); + return; + } } void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) @@ -1203,8 +1211,8 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname else { EnumPropertyItem *item; int totitem, i, free; - uiLayout *split = uiLayoutSplit(layout, 0, 0); - uiLayout *column = uiLayoutColumn(split, 0); + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = uiLayoutColumn(split, FALSE); RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); @@ -1215,7 +1223,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname else { if (item[i].name) { if (i != 0) { - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= UI_BLOCK_NO_FLIP; } @@ -2301,7 +2309,7 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout) uiBlock *block; block = uiLayoutGetBlock(layout); - uiLayoutAbsolute(layout, 0); + uiLayoutAbsolute(layout, FALSE); return block; } @@ -2893,7 +2901,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, i uiBut *but; uiLayout *col; /* needed to avoid alignment errors with previous buttons */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults")); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index dd6be9141ca..40f28de50fa 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1729,7 +1729,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a } /* create items */ - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); for (a = 0; a < md->nitems; a++) { if (a == column_end) { @@ -1748,7 +1748,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a } } - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); } if (block->flag & UI_BLOCK_NO_FLIP) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index eae721ef484..40d530a13d4 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -371,7 +371,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); template->preview = 1; } else if (flag & UI_ID_BROWSE) { @@ -529,7 +529,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const * - template_ID makes a copy of the template data and assigns it to the relevant buttons */ if (template->idlb) { - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop); } @@ -577,7 +577,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); /* Label - either use the provided text, or will become "ID-Block:" */ if (text) { @@ -618,7 +618,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); /* Path (existing string) Widget */ uiItemR(row, ptr, propname, 0, text, ICON_RNA); @@ -731,14 +731,14 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, /* create RNA pointer */ RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr); - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetContextPointer(column, "modifier", &ptr); /* rounded header ------------------------------------------------------------------- */ box = uiLayoutBox(column); if (isVirtual) { - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* VIRTUAL MODIFIER */ @@ -752,7 +752,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } else { /* REAL MODIFIER */ - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -837,7 +837,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (!isVirtual && (md->mode & eModifierMode_Expanded)) { /* apply/convert/copy */ box = uiLayoutBox(column); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { /* only here obdata, the rest of modifiers is ob level */ @@ -869,14 +869,14 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } /* result is the layout block inside the box, that we return so that modifier settings can be drawn */ - result = uiLayoutColumn(box, 0); + result = uiLayoutColumn(box, FALSE); block = uiLayoutAbsoluteBlock(box); } /* error messages */ if (md->error) { box = uiLayoutBox(column); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, md->error, ICON_ERROR); } @@ -1006,11 +1006,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetContextPointer(col, "constraint", &ptr); box = uiLayoutBox(col); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(box); /* Draw constraint header */ @@ -1198,8 +1198,8 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* layout */ block = uiLayoutGetBlock(layout); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiLayoutSetKeepAspect(col, 1); /* add preview */ @@ -1216,7 +1216,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Material, ma, &material_ptr); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiLayoutSetScaleX(col, 1.5); uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE); } @@ -1225,7 +1225,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); if (GS(parent->name) == ID_MA) uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); @@ -1237,7 +1237,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Alpha button for texture preview */ if (*pr_texture != TEX_PR_OTHER) { - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); } } @@ -1365,7 +1365,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand /* better to use rna so we can animate them */ PointerRNA ptr; RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE); bt = block->buttons.last; @@ -1776,11 +1776,11 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe block = uiLayoutGetBlock(layout); /* curve chooser */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if (labeltype == 'v') { /* vector */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[0].curve) { @@ -1798,7 +1798,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } else if (labeltype == 'c') { /* color */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[3].curve) { @@ -1820,7 +1820,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } else if (labeltype == 'h') { /* HSV */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[0].curve) { @@ -1843,7 +1843,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe bg = UI_GRAD_H; /* operation buttons */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1873,16 +1873,16 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe /* curve itself */ size = uiLayoutGetWidth(layout); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, ""); /* black/white levels */ if (levels) { - split = uiLayoutSplit(layout, 0, 0); - uiItemR(uiLayoutColumn(split, 0), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiItemR(uiLayoutColumn(split, 0), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + split = uiLayoutSplit(layout, 0.0f, FALSE); + uiItemR(uiLayoutColumn(split, FALSE), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(uiLayoutColumn(split, FALSE), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiLayoutRow(layout, 0); + uiLayoutRow(layout, FALSE); bt = uiDefBut(block, BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Reset Black/White point and curves")); uiButSetNFunc(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); @@ -1941,8 +1941,8 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 1); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, TRUE); but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, ""); @@ -2033,13 +2033,13 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, /* layers are laid out going across rows, with the columns being divided into groups */ for (group = 0; group < groups; group++) { - uCol = uiLayoutColumn(layout, 1); + uCol = uiLayoutColumn(layout, TRUE); for (row = 0; row < 2; row++) { uiBlock *block; uiBut *but; - uRow = uiLayoutRow(uCol, 1); + uRow = uiLayoutRow(uCol, TRUE); block = uiLayoutGetBlock(uRow); layer = groups * cols_per_group * row + cols_per_group * group; @@ -2113,12 +2113,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe overlap = uiLayoutOverlap(layout); /* list item behind label & other buttons */ - sub = uiLayoutRow(overlap, 0); + sub = uiLayoutRow(overlap, FALSE); but = uiDefButR_prop(block, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); - sub = uiLayoutRow(overlap, 0); + sub = uiLayoutRow(overlap, FALSE); /* retrieve icon and name */ icon = list_item_icon_get(C, itemptr, rnaicon, 0); @@ -2173,12 +2173,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe Key *key = (Key *)itemptr->id.data; KeyBlock *kb = (KeyBlock *)itemptr->data; - split = uiLayoutSplit(sub, 0.66f, 0); + split = uiLayoutSplit(sub, 0.66f, FALSE); uiItemL(split, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); if (i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE); else uiItemR(row, itemptr, "value", 0, "", ICON_NONE); uiItemR(row, itemptr, "mute", 0, "", 0); @@ -2186,7 +2186,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe if ((kb->flag & KEYBLOCK_MUTE) || (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH))) { - uiLayoutSetActive(row, 0); + uiLayoutSetActive(row, FALSE); } uiBlockSetEmboss(block, UI_EMBOSS); } @@ -2234,7 +2234,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe else if (itemptr->type == &RNA_MovieTrackingObject) { MovieTrackingObject *tracking_object = (MovieTrackingObject *)itemptr->data; - split = uiLayoutSplit(sub, 0.75f, 0); + split = uiLayoutSplit(sub, 0.75f, FALSE); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { uiItemL(split, name, ICON_CAMERA_DATA); } @@ -2243,12 +2243,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe } } else if (itemptr->type == &RNA_MaskLayer) { - split = uiLayoutSplit(sub, 0.5f, 0); + split = uiLayoutSplit(sub, 0.5f, FALSE); uiItemL(split, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); // uiItemR(row, itemptr, "alpha", 0, "", ICON_NONE); // enable when used uiItemR(row, itemptr, "hide", 0, "", 0); uiItemR(row, itemptr, "hide_select", 0, "", 0); @@ -2278,7 +2278,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe * for the string prop, after the name of each item of the collection. */ else if (prop_list_id) { - row = uiLayoutRow(sub, 1); + row = uiLayoutRow(sub, TRUE); uiItemL(row, name, icon); /* XXX: Check, as sometimes we get an itemptr looking like @@ -2379,8 +2379,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if (listtype == 'i') { box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); - col = uiLayoutColumn(box, 1); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(box, TRUE); + row = uiLayoutRow(col, FALSE); if (ptr->data && prop) { /* create list items */ @@ -2388,7 +2388,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * { /* create button */ if (!(i % 9)) - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); icon = list_item_icon_get(C, &itemptr, rnaicon, 1); but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); @@ -2403,7 +2403,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * else if (listtype == 'c') { /* compact layout */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (ptr->data && prop) { /* create list items */ @@ -2448,8 +2448,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* layout */ box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 1); + row = uiLayoutRow(box, FALSE); + col = uiLayoutColumn(row, TRUE); /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); @@ -2489,7 +2489,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* add scrollbar */ if (len > items) { - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &pa->list_scroll, 0, len - items, items, 0, ""); } } @@ -2625,7 +2625,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if (owner) { uiLayout *ui_abs; - ui_abs = uiLayoutAbsolute(layout, 0); + ui_abs = uiLayoutAbsolute(layout, FALSE); (void)ui_abs; // UNUSED uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, @@ -2633,7 +2633,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner), UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); - uiLayoutRow(layout, 0); + uiLayoutRow(layout, FALSE); } if (WM_jobs_test(wm, screen)) uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, @@ -2665,7 +2665,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) if (!rti || rti->widthfac == 0.0f || !report) return; - ui_abs = uiLayoutAbsolute(layout, 0); + ui_abs = uiLayoutAbsolute(layout, FALSE); block = uiLayoutGetBlock(ui_abs); width = BLF_width(style->widget.uifont_id, report->message); @@ -2726,7 +2726,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, if (title) uiItemL(layout, title, ICON_NONE); - flow = uiLayoutColumnFlow(layout, 2, 0); + flow = uiLayoutColumnFlow(layout, 2, FALSE); RNA_STRUCT_BEGIN (ptr, prop) { diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 9773918e508..8ff8e0824d6 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -158,17 +158,17 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, name = RNA_property_ui_name(prop); if (label_align == 'V') { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); if (!is_boolean) uiItemL(col, name, ICON_NONE); } else if (label_align == 'H') { - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemL(col, (is_boolean) ? "" : name, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); } else { col = NULL; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 004c5306d65..07b1217b1bd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1946,8 +1946,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* ************ custom buttons, old stuff ************** */ /* draws in resolution of 20x4 colors */ -void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) +void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha) { + const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f; int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; @@ -2004,7 +2005,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) /* old below */ - for (dx = 0.0f; dx < 1.0f; dx += 0.05f) { + for (dx = 0.0f; dx < 1.0f; dx += color_step) { // previous color copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); @@ -2032,11 +2033,15 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]); break; case UI_GRAD_H: - hsv_to_rgb(dx, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); + { + /* annoying but without this the color shifts - could be solved some other way + * - campbell */ + hsv_to_rgb(dx + color_step, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); copy_v3_v3(col1[1], col1[0]); copy_v3_v3(col1[2], col1[0]); copy_v3_v3(col1[3], col1[0]); break; + } case UI_GRAD_S: hsv_to_rgb(h, dx, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]); copy_v3_v3(col1[0], col1[1]); @@ -2053,7 +2058,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) // rect sx1 = rect->xmin + dx * (rect->xmax - rect->xmin); - sx2 = rect->xmin + (dx + 0.05f) * (rect->xmax - rect->xmin); + sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin); sy = rect->ymin; dy = (rect->ymax - rect->ymin) / 3.0; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index f39510666ec..e5a10dc9201 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -743,7 +743,8 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255); - rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw + /* alpha 80 is not meant editable, used for wire+action draw */ + rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255); rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index b2227405d8b..51e1b30f0bf 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2078,18 +2078,21 @@ void UI_view2d_text_cache_draw(ARegion *ar) { View2DString *v2s; int col_pack_prev = 0; + + /* investigate using BLF_ascender() */ + const float default_height = strings.first ? BLF_height_default("28") : 0.0f; // glMatrixMode(GL_PROJECTION); // glPushMatrix(); // glMatrixMode(GL_MODELVIEW); // glPushMatrix(); ED_region_pixelspace(ar); - + for (v2s = strings.first; v2s; v2s = v2s->next) { const char *str = (const char *)(v2s + 1); int xofs = 0, yofs; - yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28"))); + yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height)); if (yofs < 1) yofs = 1; if (col_pack_prev != v2s->col.pack) { diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt new file mode 100644 index 00000000000..0c417c5dfb9 --- /dev/null +++ b/source/blender/editors/io/CMakeLists.txt @@ -0,0 +1,46 @@ +# ***** 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): Blender Foundation +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenfont + ../../blenkernel + ../../blenlib + ../../blenloader + ../../bmesh + ../../makesdna + ../../makesrna + ../../windowmanager + ../../collada +) + +set(SRC + io_collada.c + io_ops.c + + io_collada.h + io_ops.h +) + +if(WITH_OPENCOLLADA) + add_definitions(-DWITH_COLLADA) +endif() + +blender_add_lib(bf_editor_io "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/io/SConscript b/source/blender/editors/io/SConscript new file mode 100644 index 00000000000..d012576637c --- /dev/null +++ b/source/blender/editors/io/SConscript @@ -0,0 +1,14 @@ +#!/usr/bin/python + +Import ('env') + +sources = env.Glob('*.c') +defs = [] + +incs = '../include ../../blenfont ../../blenkernel ../../blenlib ../../blenloader ../../bmesh' +incs += '../../makesdna ../../makesrna ../../windowmanager ../../collada' + +if env['WITH_BF_COLLADA']: + defs += ['WITH_COLLADA'] + +env.BlenderLib ( 'bf_editor_io', sources, Split(incs), defines=defs, libtype=['core','player'], priority=[330,210] ) diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c new file mode 100644 index 00000000000..dca38e53934 --- /dev/null +++ b/source/blender/editors/io/io_collada.c @@ -0,0 +1,324 @@ +/* + * ***** 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) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/io/collada.c + * \ingroup collada + */ +#ifdef WITH_COLLADA +#include "DNA_scene_types.h" + +#include "BLF_translation.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_report.h" + +#include "ED_screen.h" +#include "ED_object.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "../../collada/collada.h" + +static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + char filepath[FILE_MAX]; + + if (G.main->name[0] == 0) + BLI_strncpy(filepath, "untitled", sizeof(filepath)); + else + BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + + BLI_replace_extension(filepath, sizeof(filepath), ".dae"); + RNA_string_set(op->ptr, "filepath", filepath); + } + + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +/* function used for WM_OT_save_mainfile too */ +static int wm_collada_export_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + int apply_modifiers; + int export_mesh_type; + int selected; + int include_children; + int include_armatures; + int deform_bones_only; + + int include_uv_textures; + int include_material_textures; + int use_texture_copies; + int active_uv_only; + + int use_object_instantiation; + int sort_by_name; + int second_life; + + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + RNA_string_get(op->ptr, "filepath", filepath); + BLI_ensure_extension(filepath, sizeof(filepath), ".dae"); + + /* Options panel */ + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); + export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); + selected = RNA_boolean_get(op->ptr, "selected"); + include_children = RNA_boolean_get(op->ptr, "include_children"); + include_armatures = RNA_boolean_get(op->ptr, "include_armatures"); + deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only"); + + include_uv_textures = RNA_boolean_get(op->ptr, "include_uv_textures"); + include_material_textures= RNA_boolean_get(op->ptr, "include_material_textures"); + use_texture_copies = RNA_boolean_get(op->ptr, "use_texture_copies"); + active_uv_only = RNA_boolean_get(op->ptr, "active_uv_only"); + + use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); + sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); + second_life = RNA_boolean_get(op->ptr, "second_life"); + + /* get editmode results */ + ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + + if (collada_export( + CTX_data_scene(C), + filepath, + apply_modifiers, + export_mesh_type, + selected, + include_children, + include_armatures, + deform_bones_only, + + active_uv_only, + include_uv_textures, + include_material_textures, + use_texture_copies, + + use_object_instantiation, + sort_by_name, + second_life)) { + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) +{ + uiLayout *box, *row, *col, *split; + + /* Export Options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); + + row = uiLayoutRow(box, 0); + split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); + col = uiLayoutColumn(split,0); + uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split,0); + uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE); + uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers")); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + + // Texture options + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); + + + // Armature options + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); + + /* Collada options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); + +} + +static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) +{ + PointerRNA ptr; + + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + uiCollada_exportSettings(op->layout, &ptr); +} + +void WM_OT_collada_export(wmOperatorType *ot) +{ + static EnumPropertyItem prop_bc_export_mesh_type[] = { + {BC_MESH_TYPE_VIEW, "view", 0, "View", "Apply modifier's view settings"}, + {BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"}, + {0, NULL, 0, NULL, NULL} + }; + + ot->name = "Export COLLADA"; + ot->description = "Save a Collada file"; + ot->idname = "WM_OT_collada_export"; + + ot->invoke = wm_collada_export_invoke; + ot->exec = wm_collada_export_exec; + ot->poll = WM_operator_winactive; + + ot->flag |= OPTYPE_PRESET; + + ot->ui = wm_collada_export_draw; + + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + + RNA_def_boolean(ot->srna, + "apply_modifiers", 0, "Apply Modifiers", + "Apply modifiers to exported mesh (non destructive))"); + + RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX, + "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); + + RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type, 0, + "Resolution", "Modifier resolution for export"); + + RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", + "Export only selected elements"); + + RNA_def_boolean(ot->srna, "include_children", 0, "Include Children", + "Export all children of selected objects (even if not selected)"); + + RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures", + "Export related armatures (even if not selected)"); + + RNA_def_boolean(ot->srna, "deform_bones_only", 0, "Deform Bones only", + "Only export deforming bones with armatures"); + + + RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer", + "Export textures assigned to the object UV maps"); + + RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures", + "Export textures assigned to the object UV maps"); + + RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures", + "Export textures assigned to the object Materials"); + + RNA_def_boolean(ot->srna, "use_texture_copies", 1, "copy", + "Copy textures to same folder where the .dae file is exported"); + + + RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances", + "Instantiate multiple Objects from same Data"); + + RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name", + "Sort exported data by Object name"); + + RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", + "Compatibility mode for Second Life"); +} + + +/* function used for WM_OT_save_mainfile too */ +static int wm_collada_import_exec(bContext *C, wmOperator *op) +{ + char filename[FILE_MAX]; + + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + RNA_string_get(op->ptr, "filepath", filename); + if (collada_import(C, filename)) return OPERATOR_FINISHED; + + BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); + + return OPERATOR_FINISHED; +} + +void WM_OT_collada_import(wmOperatorType *ot) +{ + ot->name = "Import COLLADA"; + ot->description = "Load a Collada file"; + ot->idname = "WM_OT_collada_import"; + + ot->invoke = WM_operator_filesel; + ot->exec = wm_collada_import_exec; + ot->poll = WM_operator_winactive; + + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} +#endif diff --git a/source/blender/editors/io/io_collada.h b/source/blender/editors/io/io_collada.h new file mode 100644 index 00000000000..5cb255e1b7c --- /dev/null +++ b/source/blender/editors/io/io_collada.h @@ -0,0 +1,39 @@ +/* + * ***** 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) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editor/io/io_collada.h + * \ingroup editor/io + */ + +#ifndef __IO_COLLADA_H__ +#define __IO_COLLADA_H__ + +struct wmOperatorType; + +void WM_OT_collada_export(struct wmOperatorType *ot); +void WM_OT_collada_import(struct wmOperatorType *ot); + +#endif diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c new file mode 100644 index 00000000000..b724db6e737 --- /dev/null +++ b/source/blender/editors/io/io_ops.c @@ -0,0 +1,44 @@ +/* + * ***** 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) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/io/io_ops.c + * \ingroup collada + */ + + +#include "io_collada.h" + +#include "WM_types.h" +#include "WM_api.h" + +void ED_operatortypes_io(void) +{ +#ifdef WITH_COLLADA + // Collada operators: + WM_operatortype_append(WM_OT_collada_export); + WM_operatortype_append(WM_OT_collada_import); +#endif +} diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h new file mode 100644 index 00000000000..1e2c4443e43 --- /dev/null +++ b/source/blender/editors/io/io_ops.h @@ -0,0 +1,36 @@ +/* + * ***** 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) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editor/io/io_collada.h + * \ingroup editor/io + */ + +#ifndef __IO_OPS_H__ +#define __IO_OPS_H__ + +void ED_operatortypes_io(void); + +#endif diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 0bc9adb6577..c9f6dc0c5fb 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -52,7 +52,7 @@ #include "mask_intern.h" /* own include */ -static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_co[2], int threshold, int feather, +static int find_nearest_diff_point(const bContext *C, Mask *mask, const float normal_co[2], int threshold, int feather, MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, float *u_r, float tangent[2], const short use_deform) @@ -176,7 +176,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_c /******************** add vertex *********************/ -static void setup_vertex_point(bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, +static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point, const float point_co[2], const float tangent[2], const float u, MaskSplinePoint *reference_point, const short reference_adjacent) { @@ -365,7 +365,7 @@ static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index) spline->tot_point++; } -static int add_vertex_subdivide(bContext *C, Mask *mask, const float co[2]) +static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2]) { MaskLayer *masklay; MaskSpline *spline; @@ -399,7 +399,7 @@ static int add_vertex_subdivide(bContext *C, Mask *mask, const float co[2]) return FALSE; } -static int add_vertex_extrude(bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) +static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) { MaskSpline *spline; MaskSplinePoint *point; @@ -500,7 +500,7 @@ static int add_vertex_extrude(bContext *C, Mask *mask, MaskLayer *masklay, const return TRUE; } -static int add_vertex_new(bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) +static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2]) { MaskSpline *spline; MaskSplinePoint *point; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 678186f0e8c..83337a18223 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -116,7 +116,8 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline) #endif /* return non-zero if spline is selected */ -static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline) +static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline, + const char UNUSED(draw_flag), const char draw_type) { const int is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; unsigned char rgb_spline[4]; @@ -188,8 +189,20 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline) /* draw handle segment */ if (has_handle) { - glColor3ubv(rgb_spline); + /* this could be split into its own loop */ + if (draw_type == MASK_DT_OUTLINE) { + const unsigned char rgb_grey[4] = {0x60, 0x60, 0x60, 0xff}; + glLineWidth(3); + glColor4ubv(rgb_grey); + glBegin(GL_LINES); + glVertex3fv(vert); + glVertex3fv(handle); + glEnd(); + glLineWidth(1); + } + + glColor3ubv(rgb_spline); glBegin(GL_LINES); glVertex3fv(vert); glVertex3fv(handle); @@ -415,7 +428,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type if (!(masklay->restrictflag & MASK_RESTRICT_SELECT)) { /* ...and then handles over the curve so they're nicely visible */ - draw_spline_points(masklay, spline); + draw_spline_points(masklay, spline, draw_flag, draw_type); } /* show undeform for testing */ @@ -425,7 +438,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type spline->points_deform = NULL; draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height); // draw_spline_parents(masklay, spline); - draw_spline_points(masklay, spline); + draw_spline_points(masklay, spline, draw_flag, draw_type); spline->points_deform = back; } } @@ -441,10 +454,7 @@ void ED_mask_draw(const bContext *C, if (!mask) return; - /* TODO: for now, in the future better to make sure all utility functions - * are using const specifier for non-changing pointers - */ - ED_mask_size((bContext *)C, &width, &height); + ED_mask_size(C, &width, &height); draw_masklays(mask, draw_flag, draw_type, width, height); } diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 52711c8da55..6e0da5fd756 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -76,7 +76,7 @@ int ED_maskedit_mask_poll(bContext *C) /********************** registration *********************/ -void ED_mask_mouse_pos(bContext *C, wmEvent *event, float co[2]) +void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -92,7 +92,7 @@ void ED_mask_mouse_pos(bContext *C, wmEvent *event, float co[2]) /* input: x/y - mval space * output: xr/yr - mask point space */ -void ED_mask_point_pos(bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr) { SpaceClip *sc = CTX_wm_space_clip(C); float co[2]; @@ -110,7 +110,7 @@ void ED_mask_point_pos(bContext *C, float x, float y, float *xr, float *yr) *yr = co[1]; } -void ED_mask_point_pos__reverse(bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); @@ -121,7 +121,7 @@ void ED_mask_point_pos__reverse(bContext *C, float x, float y, float *xr, float co[0] = x; co[1] = y; BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co); - ED_clip_point_stable_pos__reverse(sc, ar, co, co); + ED_clip_point_stable_pos__reverse(C, co, co); } else { /* possible other spaces from which mask editing is available */ @@ -132,13 +132,12 @@ void ED_mask_point_pos__reverse(bContext *C, float x, float y, float *xr, float *yr = co[1]; } -void ED_mask_size(bContext *C, int *width, int *height) +void ED_mask_size(const bContext *C, int *width, int *height) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { if (sa->spacetype == SPACE_CLIP) { - SpaceClip *sc = sa->spacedata.first; - ED_space_clip_mask_size(sc, width, height); + ED_space_clip_get_size(C, width, height); return; } else if (sa->spacetype == SPACE_SEQ) { @@ -154,12 +153,12 @@ void ED_mask_size(bContext *C, int *width, int *height) *height = 0; } -void ED_mask_aspect(bContext *C, float *aspx, float *aspy) +void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - ED_space_clip_mask_aspect(sc, aspx, aspy); + ED_space_clip_get_aspect(sc, aspx, aspy); } else { /* possible other spaces from which mask editing is available */ @@ -168,18 +167,17 @@ void ED_mask_aspect(bContext *C, float *aspx, float *aspy) } } -void ED_mask_pixelspace_factor(bContext *C, float *scalex, float *scaley) +void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - ARegion *ar = CTX_wm_region(C); int width, height; float zoomx, zoomy, aspx, aspy; - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); *scalex = ((float)width * aspx) * zoomx; *scaley = ((float)height * aspy) * zoomy; @@ -239,6 +237,7 @@ void ED_operatortypes_mask(void) WM_operatortype_append(MASK_OT_shape_key_insert); WM_operatortype_append(MASK_OT_shape_key_clear); WM_operatortype_append(MASK_OT_shape_key_feather_reset); + WM_operatortype_append(MASK_OT_shape_key_rekey); } void ED_keymap_mask(wmKeyConfig *keyconf) diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index c34558d2a01..f1d72f59078 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -61,12 +61,12 @@ void MASK_OT_normals_make_consistent(struct wmOperatorType *ot); void MASK_OT_handle_type_set(struct wmOperatorType *ot); int ED_mask_feather_find_nearest( - struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, + const struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, struct MaskLayer **masklay_r, struct MaskSpline **spline_r, struct MaskSplinePoint **point_r, struct MaskSplinePointUW **uw_r, float *score); struct MaskSplinePoint *ED_mask_point_find_nearest( - struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, + const struct bContext *C, struct Mask *mask, float normal_co[2], int threshold, struct MaskLayer **masklay_r, struct MaskSpline **spline_r, int *is_handle_r, float *score); @@ -97,18 +97,19 @@ void ED_mask_select_flush_all(struct Mask *mask); int ED_maskedit_poll(struct bContext *C); int ED_maskedit_mask_poll(struct bContext *C); -void ED_mask_size(struct bContext *C, int *width, int *height); -void ED_mask_aspect(struct bContext *C, float *aspx, float *aspy); +void ED_mask_size(const struct bContext *C, int *width, int *height); +void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy); -void ED_mask_pixelspace_factor(struct bContext *C, float *scalex, float *scaley); -void ED_mask_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]); +void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley); +void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); -void ED_mask_point_pos(struct bContext *C, float x, float y, float *xr, float *yr); -void ED_mask_point_pos__reverse(struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); /* mask_shapekey.c */ void MASK_OT_shape_key_insert(struct wmOperatorType *ot); void MASK_OT_shape_key_clear(struct wmOperatorType *ot); void MASK_OT_shape_key_feather_reset(struct wmOperatorType *ot); +void MASK_OT_shape_key_rekey(struct wmOperatorType *ot); #endif /* __MASK_INTERN_H__ */ diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index b770e5e9dba..91ba05c1ab2 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -57,7 +57,7 @@ /******************** utility functions *********************/ -MaskSplinePoint *ED_mask_point_find_nearest(bContext *C, Mask *mask, float normal_co[2], int threshold, +MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float normal_co[2], int threshold, MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r, float *score) { @@ -153,7 +153,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(bContext *C, Mask *mask, float norma return NULL; } -int ED_mask_feather_find_nearest(bContext *C, Mask *mask, float normal_co[2], int threshold, +int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[2], int threshold, MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, MaskSplinePointUW **uw_r, float *score) { diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index 7ba3c27e18d..a1f2539ce7c 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -44,6 +44,7 @@ #include "WM_types.h" #include "ED_screen.h" +#include "ED_clip.h" /* frame remapping functions */ #include "ED_mask.h" /* own include */ #include "mask_intern.h" /* own include */ @@ -104,21 +105,25 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) MovieClip *clip; MovieTrackingTrack *track; MovieTrackingMarker *marker; - MovieTrackingObject *tracking; + MovieTrackingObject *tracking_object; /* done */ + int framenr; + float marker_pos_ofs[2]; float parmask_pos[2]; if ((NULL == (sc = CTX_wm_space_clip(C))) || (NULL == (clip = sc->clip)) || (NULL == (track = clip->tracking.act_track)) || - (NULL == (marker = BKE_tracking_marker_get(track, sc->user.framenr))) || - (NULL == (tracking = BKE_tracking_object_get_active(&clip->tracking)))) + (NULL == (tracking_object = BKE_tracking_object_get_active(&clip->tracking)))) { return OPERATOR_CANCELLED; } + framenr = ED_space_clip_get_clip_frame_number(sc); + marker = BKE_tracking_marker_get(track, framenr); + add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); BKE_mask_coord_from_movieclip(clip, &sc->user, parmask_pos, marker_pos_ofs); @@ -138,7 +143,7 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (MASKPOINT_ISSEL_ANY(point)) { point->parent.id_type = ID_MC; point->parent.id = &clip->id; - strcpy(point->parent.parent, tracking->name); + strcpy(point->parent.parent, tracking_object->name); strcpy(point->parent.sub_parent, track->name); copy_v2_v2(point->parent.parent_orig, parmask_pos); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 55e09529320..e619277456e 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -581,8 +581,6 @@ static int circle_select_exec(bContext *C, wmOperator *op) MaskLayer *masklay; int i; - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; @@ -595,8 +593,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) /* TODO - make generic! - this is SpaceClip only! */ /* compute ellipse and position in unified coordinates */ - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); width = height = MAX2(width, height); ellipse[0] = width * zoomx / radius; diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 8da083ab400..a619ac7e3cd 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -29,7 +29,11 @@ * \ingroup edmask */ +#include <stdlib.h> + #include "BLI_utildefines.h" +#include "BLI_listbase.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -39,6 +43,9 @@ #include "DNA_mask_types.h" #include "DNA_scene_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -233,6 +240,175 @@ void MASK_OT_shape_key_feather_reset(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/* + * - loop over selected shapekeys. + * - find firstsel/lastsel pairs. + * - move these into a temp list. + * - re-key all the original shapes. + * - copy unselected values back from the original. + * - free the original. + */ +static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + const int frame = CFRA; + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *masklay; + int change = FALSE; + + const short do_feather = RNA_boolean_get(op->ptr, "feather"); + const short do_location = RNA_boolean_get(op->ptr, "location"); + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + + if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { + continue; + } + + /* we need at least one point selected here to bother re-interpolating */ + if (!ED_mask_layer_select_check(masklay)) { + continue; + } + + if (masklay->splines_shapes.first) { + MaskLayerShape *masklay_shape; + MaskLayerShape *masklay_shape_lastsel = NULL; + + for (masklay_shape = masklay->splines_shapes.first; + masklay_shape; + masklay_shape = masklay_shape->next) + { + MaskLayerShape *masklay_shape_a = NULL; + MaskLayerShape *masklay_shape_b = NULL; + + /* find contiguous selections */ + if (masklay_shape->flag & MASK_SHAPE_SELECT) { + if (masklay_shape_lastsel == NULL) { + masklay_shape_lastsel = masklay_shape; + } + if ((masklay_shape->next == NULL) || + (((MaskLayerShape *)masklay_shape->next)->flag & MASK_SHAPE_SELECT) == 0) + { + masklay_shape_a = masklay_shape_lastsel; + masklay_shape_b = masklay_shape; + masklay_shape_lastsel = NULL; + } + } + + /* we have a from<>to? - re-interpolate! */ + if (masklay_shape_a && masklay_shape_b) { + ListBase shapes_tmp = {NULL, NULL}; + MaskLayerShape *masklay_shape_tmp; + MaskLayerShape *masklay_shape_tmp_next; + MaskLayerShape *masklay_shape_tmp_last = masklay_shape_b->next; + MaskLayerShape *masklay_shape_tmp_rekey; + + /* move keys */ + for (masklay_shape_tmp = masklay_shape_a; + masklay_shape_tmp && (masklay_shape_tmp != masklay_shape_tmp_last); + masklay_shape_tmp = masklay_shape_tmp_next) + { + masklay_shape_tmp_next = masklay_shape_tmp->next; + BLI_remlink(&masklay->splines_shapes, masklay_shape_tmp); + BLI_addtail(&shapes_tmp, masklay_shape_tmp); + } + + /* re-key, note: cant modify the keys here since it messes uop */ + for (masklay_shape_tmp = shapes_tmp.first; + masklay_shape_tmp; + masklay_shape_tmp = masklay_shape_tmp->next) + { + BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, TRUE); + masklay_shape_tmp_rekey = BKE_mask_layer_shape_varify_frame(masklay, masklay_shape_tmp->frame); + BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey); + masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT; + } + + /* restore unselected points and free copies */ + for (masklay_shape_tmp = shapes_tmp.first; + masklay_shape_tmp; + masklay_shape_tmp = masklay_shape_tmp_next) + { + /* restore */ + int i_abs = 0; + int i; + MaskSpline *spline; + MaskLayerShapeElem *shape_ele_src; + MaskLayerShapeElem *shape_ele_dst; + + masklay_shape_tmp_next = masklay_shape_tmp->next; + + /* we know this exists, added above */ + masklay_shape_tmp_rekey = BKE_mask_layer_shape_find_frame(masklay, masklay_shape_tmp->frame); + + shape_ele_src = (MaskLayerShapeElem *)masklay_shape_tmp->data; + shape_ele_dst = (MaskLayerShapeElem *)masklay_shape_tmp_rekey->data; + + for (spline = masklay->splines.first; spline; spline = spline->next) { + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + + /* not especially efficient but makes this easier to follow */ + SWAP(MaskLayerShapeElem, *shape_ele_src, *shape_ele_dst); + + if (MASKPOINT_ISSEL_ANY(point)) { + if (do_location) { + memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float) * 6); + } + if (do_feather) { + shape_ele_dst->value[6] = shape_ele_src->value[6]; + } + } + + shape_ele_src++; + shape_ele_dst++; + + i_abs++; + } + } + + BKE_mask_layer_shape_free(masklay_shape_tmp); + } + + change = TRUE; + } + } + + /* re-evaluate */ + BKE_mask_layer_evaluate(masklay, frame, TRUE); + } + } + + if (change) { + WM_event_add_notifier(C, NC_MASK | ND_DATA, mask); + DAG_id_tag_update(&mask->id, 0); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void MASK_OT_shape_key_rekey(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Re-Key Points of Selected Shapes"; + ot->description = "Recalculates animation data on selected points for frames selected in the dopesheet"; + ot->idname = "MASK_OT_shape_key_rekey"; + + /* api callbacks */ + ot->exec = mask_shape_key_rekey_exec; + ot->poll = ED_maskedit_mask_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "location", TRUE, "Location", ""); + RNA_def_boolean(ot->srna, "feather", TRUE, "Feather", ""); +} + /* *** Shape Key Utils *** */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index f154aec2eb4..898399f723d 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1468,6 +1468,8 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo if (cure && p) { if (!kcd->ignore_edge_snapping || !(cure->e)) { + KnifeVert *edgesnap = NULL; + if (kcd->snap_midpoints) { mid_v3_v3v3(p, cure->v1->co, cure->v2->co); mid_v3_v3v3(cagep, cure->v1->cageco, cure->v2->cageco); @@ -1479,6 +1481,13 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo d = len_v3v3(cagep, cure->v1->cageco) / len_v3v3(cure->v1->cageco, cure->v2->cageco); interp_v3_v3v3(p, cure->v1->co, cure->v2->co, d); } + + /* update mouse coordinates to the snapped-to edge's screen coordinates + * this is important for angle snap, which uses the previous mouse position */ + edgesnap = new_knife_vert(kcd, p, cagep); + kcd->cur.mval[0] = (int)edgesnap->sco[0]; + kcd->cur.mval[1] = (int)edgesnap->sco[1]; + } else { return NULL; @@ -1557,6 +1566,11 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo if (curv && p) { copy_v3_v3(p, curv->co); copy_v3_v3(cagep, curv->cageco); + + /* update mouse coordinates to the snapped-to vertex's screen coordinates + * this is important for angle snap, which uses the previous mouse position */ + kcd->cur.mval[0] = (int)curv->sco[0]; + kcd->cur.mval[1] = (int)curv->sco[1]; } return curv; @@ -1617,7 +1631,11 @@ static int knife_update_active(KnifeTool_OpData *kcd) kcd->cur.mval[0] = kcd->vc.mval[0]; kcd->cur.mval[1] = kcd->vc.mval[1]; + /* XXX knife_snap_angle updates the view coordinate mouse values to constrained angles, + * which current mouse values are set to current mouse values are then used + * for vertex and edge snap detection, without regard to the exact angle constraint */ kcd->cur.vert = knife_find_closest_vert(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); + if (!kcd->cur.vert) { kcd->cur.edge = knife_find_closest_edge(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index bf299ffaa61..6940b05e86c 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1046,6 +1046,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) // if (EM_texFaceCheck()) /* sets as active, useful for other tools */ +#if 0 if (select) { if (em->selectmode & SCE_SELECT_VERTEX) { /* TODO: would be nice if the edge vertex chosen here @@ -1060,6 +1061,8 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) * belongs to the selected edge could be set to * active here in face select mode */ } +#endif + mouse_mesh(C, mval, select, TRUE, FALSE); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 5ad663b92d3..908c0a6f4f2 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1752,6 +1752,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", ""); prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_enum_funcs(prop, gameprops_itemf); ot->prop = prop; } diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index b47591dddee..48104c9274d 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -160,7 +160,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) +static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -180,21 +180,114 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void GROUP_OT_objects_remove(wmOperatorType *ot) +void GROUP_OT_objects_remove_all(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove From Groups"; - ot->description = "Remove selected objects from all groups"; - ot->idname = "GROUP_OT_objects_remove"; + ot->name = "Remove From All Groups"; + ot->description = "Remove selected objects from all groups or a selected group"; + ot->idname = "GROUP_OT_objects_remove_all"; /* api callbacks */ - ot->exec = group_objects_remove_exec; + ot->exec = group_objects_remove_all_exec; ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +static int group_objects_remove_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int group_object_index = RNA_enum_get(op->ptr, "group"); + + /* first get the group back from the enum index, quite awkward and UI spesific */ + if (ob) { + Group *group = NULL; + int i = 0; + + while ((group = find_group(ob, group))) { + if (i == group_object_index) { + break; + } + i++; + } + + /* now remove all selected objects from the group */ + if (group) { + + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + { + rem_from_group(group, base->object, scene, base); + } + CTX_DATA_END; + + DAG_scene_sort(bmain, scene); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + + return OPERATOR_FINISHED; + } + } + + return OPERATOR_CANCELLED; +} + + +/* can be called with C == NULL */ +static EnumPropertyItem *group_objects_remove_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +{ + Object *ob = ED_object_context(C); + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + + if (C == NULL) { + return DummyRNA_NULL_items; + } + + /* check that the action exists */ + if (ob) { + Group *group = NULL; + int i = 0; + + while ((group = find_group(ob, group))) { + item_tmp.identifier = item_tmp.name = group->id.name + 2; + /* item_tmp.icon = ICON_ARMATURE_DATA; */ + item_tmp.value = i; + RNA_enum_item_add(&item, &totitem, &item_tmp); + i++; + } + } + + RNA_enum_item_end(&item, &totitem); + *free = 1; + + return item; +} + +void GROUP_OT_objects_remove(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Remove From Group"; + ot->description = "Remove selected objects from all groups or a selected group"; + ot->idname = "GROUP_OT_objects_remove"; + + /* api callbacks */ + ot->exec = group_objects_remove_exec; + ot->invoke = WM_menu_invoke; + ot->poll = ED_operator_objectmode; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove this object from"); + RNA_def_enum_funcs(prop, group_objects_remove_itemf); + ot->prop = prop; +} + static int group_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 4b33c5663ba..f7e7c87d956 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -139,6 +139,7 @@ void LATTICE_OT_make_regular(struct wmOperatorType *ot); /* object_group.c */ void GROUP_OT_create(struct wmOperatorType *ot); +void GROUP_OT_objects_remove_all(struct wmOperatorType *ot); void GROUP_OT_objects_remove(struct wmOperatorType *ot); void GROUP_OT_objects_add_active(struct wmOperatorType *ot); void GROUP_OT_objects_remove_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 0a9944debe1..e85f47837ef 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -102,7 +102,7 @@ void make_editLatt(Object *obedit) if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->editlatt->latt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); } @@ -162,7 +162,7 @@ void load_editLatt(Object *obedit) if (editlt->dvert) { tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); + lt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->dvert, editlt->dvert, tot); } } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index d0a93302b7f..cec849efca7 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -105,6 +105,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_select_mirror); WM_operatortype_append(GROUP_OT_create); + WM_operatortype_append(GROUP_OT_objects_remove_all); WM_operatortype_append(GROUP_OT_objects_remove); WM_operatortype_append(GROUP_OT_objects_add_active); WM_operatortype_append(GROUP_OT_objects_remove_active); @@ -394,6 +395,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 37ab87780b5..3533a337aa1 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1241,6 +1241,8 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) else WM_cursor_set(win, CURSOR_X_MOVE); } + else + WM_cursor_set(win, CURSOR_STD); } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4e98d2ae967..cacd6d01291 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -460,7 +460,7 @@ int ED_operator_mask(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); - return ED_space_clip_show_maskedit(sc); + return ED_space_clip_check_show_maskedit(sc); } /* *************************** action zone operator ************************** */ @@ -1175,7 +1175,7 @@ static int area_split_menu_init(bContext *C, wmOperator *op) sAreaSplitData *sd; /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = CTX_wm_area(C); @@ -1210,7 +1210,7 @@ static int area_split_init(bContext *C, wmOperator *op) if (dir == 'h' && sa->winy < 2 * areaminy) return 0; /* custom data */ - sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; sd->sarea = sa; @@ -2180,7 +2180,7 @@ static int area_join_init(bContext *C, wmOperator *op) return 0; } - jd = (sAreaJoinData *)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); + jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join"); jd->sa1 = sa1; jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4dee83dbb82..a1ade77d068 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -2344,8 +2344,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* Use tf_uv_pxoffset instead of tf->uv so we can offset the UV half a pixel * this is done so we can avoid offsetting all the pixels by 0.5 which causes * problems when wrapping negative coords */ - xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f) ) / ibuf_xf; - yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f) ) / ibuf_yf; + xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f)) / ibuf_xf; + yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f)) / ibuf_yf; /* Note about (PROJ_GEOM_TOLERANCE/x) above... * Needed to add this offset since UV coords are often quads aligned to pixels. @@ -5096,8 +5096,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* This can be removed once fixed properly in * BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) - * at zero pressure we should do nothing 1/2^12 is .0002 which is the sensitivity of the most sensitive pen tablet available */ - if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) + * at zero pressure we should do nothing 1/2^12 is 0.0002 which is the sensitivity of the most sensitive pen tablet available */ + if (tablet && (pressure < 0.0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) return; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 89dbe14f62a..e6c061a06ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -592,7 +592,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, distsq = len_squared_v3v3(mirror, cache->true_location); if (distsq <= 4.0f * (cache->radius_squared)) - return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius)); + return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius)); else return 0; } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index d233c45a230..f327f67be33 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -269,7 +269,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) SculptSession *ss = ob->sculpt; SculptUndoNode *unode; MultiresModifierData *mmd; - int update = 0, rebuild = 1; + int update = FALSE, rebuild = FALSE; sculpt_update_mesh_elements(scene, sd, ob, 0); @@ -297,15 +297,15 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) switch (unode->type) { case SCULPT_UNDO_COORDS: if (sculpt_undo_restore_coords(C, dm, unode)) - update = 1; + update = TRUE; break; case SCULPT_UNDO_HIDDEN: if (sculpt_undo_restore_hidden(C, dm, unode)) - rebuild = 1; + rebuild = TRUE; break; case SCULPT_UNDO_MASK: if (sculpt_undo_restore_mask(C, dm, unode)) - update = 1; + update = TRUE; break; } } diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index 137cda9c285..0abdd134046 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../include + ../io ../../blenkernel ../../blenlib ../../blenloader diff --git a/source/blender/editors/space_api/SConscript b/source/blender/editors/space_api/SConscript index 6bf901cf8ad..9b818b074ba 100644 --- a/source/blender/editors/space_api/SConscript +++ b/source/blender/editors/space_api/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../blenloader ../../makesdna' +incs = '../include ../io ../../blenlib ../../blenkernel ../../blenloader ../../makesdna' incs += ' ../../windowmanager ../../python ../../makesrna ../../bmesh' incs += ' #/intern/guardedalloc #/extern/glew/include' diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index fa77249a7a1..2cbcbcdbc9a 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -63,6 +63,9 @@ #include "ED_logic.h" #include "ED_clip.h" #include "ED_mask.h" +#include "ED_sequencer.h" + +#include "io_ops.h" /* only call once on startup, storage is global in BKE kernel listbase */ void ED_spacetypes_init(void) @@ -113,6 +116,7 @@ void ED_spacetypes_init(void) ED_operatortypes_render(); ED_operatortypes_logic(); ED_operatortypes_mask(); + ED_operatortypes_io(); UI_view2d_operatortypes(); UI_buttons_operatortypes(); @@ -136,7 +140,8 @@ void ED_spacetypes_init(void) ED_operatormacros_clip(); ED_operatormacros_curve(); ED_operatormacros_mask(); - + ED_operatormacros_sequencer(); + /* register dropboxes (can use macros) */ spacetypes = BKE_spacetypes_list(); for (type = spacetypes->first; type; type = type->next) { diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index d1c2c1e092f..6154a1cc5ce 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -991,7 +991,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (!path) return; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index d1737fcd065..c894c1a980b 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -333,6 +333,9 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) buttons_area_redraw(sa, BCONTEXT_DATA); sbuts->preview = 1; break; + case NC_GROUP: + buttons_area_redraw(sa, BCONTEXT_OBJECT); + break; case NC_BRUSH: buttons_area_redraw(sa, BCONTEXT_TEXTURE); break; diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 9b3d713d040..e561b2a9e79 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -118,13 +118,13 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); if (clip) { - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); - row = uiLayoutRow(layout, 0); - split = uiLayoutSplit(row, 0.0, 0); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(layout, FALSE); + split = uiLayoutSplit(row, 0.0f, FALSE); + row = uiLayoutRow(split, TRUE); uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload"); @@ -396,7 +396,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P BKE_movieclip_get_size(clip, user, &width, &height); if (track->flag & TRACK_LOCKED) { - uiLayoutSetActive(layout, 0); + uiLayoutSetActive(layout, FALSE); block = uiLayoutAbsoluteBlock(layout); uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, ""); @@ -434,7 +434,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag, 0, 0, 0, 0, tip); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0); block = uiLayoutAbsoluteBlock(col); diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 361a3a7d906..83d895067cc 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -146,7 +146,7 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; /* frame range */ @@ -256,7 +256,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); View2D *v2d = &ar->v2d; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking; MovieTrackingDopesheet *dopesheet; MovieTrackingDopesheetChannel *channel; diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 716994f7487..6d1610f3f91 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -91,7 +91,7 @@ static int dopesheet_select_channel_poll(bContext *C) static int dopesheet_select_channel_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 8deb83b6f0d..37da40e11b3 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -226,7 +226,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; char str[256] = {0}; int block = FALSE; @@ -255,7 +255,7 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { int x, y; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); /* find window pixel coordinates of origin */ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); @@ -344,7 +344,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if (count == 0) return; - start_frame = framenr = ED_space_clip_clip_framenr(sc); + start_frame = framenr = ED_space_clip_get_clip_frame_number(sc); marker = BKE_tracking_marker_get(track, framenr); if (marker->framenr != framenr || marker->flag & MARKER_DISABLED) @@ -813,7 +813,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) { int i; float pat_min[2], pat_max[2]; - float dx = 12.0f / width, dy = 12.0f / height; +/* float dx = 12.0f / width, dy = 12.0f / height;*/ /* XXX UNUSED */ float tilt_ctrl[2]; if (!outline) { @@ -837,25 +837,30 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glEnable(GL_LINE_STIPPLE); glLineStipple(3, 0xaaaa); - glBegin(GL_LINE_LOOP); - glVertex2f(pat_min[0] - dx, pat_min[1] - dy); - glVertex2f(pat_max[0] + dx, pat_min[1] - dy); - glVertex2f(pat_max[0] + dx, pat_max[1] + dy); - glVertex2f(pat_min[0] - dx, pat_max[1] + dy); - glEnd(); +#if 0 + /* TODO: disable for now, needs better approach visualizing this */ - glBegin(GL_LINES); - glVertex2f(0.0f, 0.0f); - glVertex2fv(tilt_ctrl); + glBegin(GL_LINE_LOOP); + glVertex2f(pat_min[0] - dx, pat_min[1] - dy); + glVertex2f(pat_max[0] + dx, pat_min[1] - dy); + glVertex2f(pat_max[0] + dx, pat_max[1] + dy); + glVertex2f(pat_min[0] - dx, pat_max[1] + dy); glEnd(); - glDisable(GL_LINE_STIPPLE); - /* marker's offset slider */ draw_marker_slide_square(pat_min[0] - dx, pat_max[1] + dy, patdx, patdy, outline, px); /* pattern re-sizing triangle */ draw_marker_slide_triangle(pat_max[0] + dx, pat_min[1] - dy, patdx, patdy, outline, px); +#endif + + glBegin(GL_LINES); + glVertex2f(0.0f, 0.0f); + glVertex2fv(tilt_ctrl); + glEnd(); + + glDisable(GL_LINE_STIPPLE); + /* slider to control pattern tilt */ draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px); @@ -919,7 +924,7 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra if (marker->flag & MARKER_DISABLED) strcpy(state, "disabled"); - else if (marker->framenr != ED_space_clip_clip_framenr(sc)) + else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) strcpy(state, "estimated"); else if (marker->flag & MARKER_TRACKED) strcpy(state, "tracked"); @@ -967,7 +972,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track, *act_track; MovieTrackingMarker *marker; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int undistort = sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT; float *marker_pos = NULL, *fp, *active_pos = NULL, cur_pos[2]; @@ -1313,7 +1318,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); if (track) { - int framenr = sc->user.framenr; + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); offsx = marker->pos[0]; @@ -1403,19 +1408,23 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); } -void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) +void clip_draw_main(const bContext *C, ARegion *ar) { - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + Scene *scene = CTX_data_scene(C); ImBuf *ibuf; int width, height; float zoomx, zoomy; + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + /* if no clip, nothing to do */ - if (!clip) + if (!clip) { + ED_region_grid_draw(ar, zoomx, zoomy); return; - - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + } if (sc->flag & SC_SHOW_STABLE) { float smat[4][4], ismat[4][4]; @@ -1471,7 +1480,7 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) void clip_draw_grease_pencil(bContext *C, int onlyv2d) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!clip) return; @@ -1487,12 +1496,10 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); if (track) { - int framenr = sc->user.framenr; - /* don't get the exact marker since it may not exist for the frame */ + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); - if (marker) { - glTranslatef(marker->pos[0], marker->pos[1], 0.0f); - } + + glTranslatef(marker->pos[0], marker->pos[1], 0.0f); } } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 0bad9f86ea1..b57b16707d4 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -91,7 +91,7 @@ int ED_space_clip_tracking_poll(bContext *C) SpaceClip *sc = CTX_wm_space_clip(C); if (sc && sc->clip) - return ED_space_clip_show_trackedit(sc); + return ED_space_clip_check_show_trackedit(sc); return FALSE; } @@ -101,7 +101,7 @@ int ED_space_clip_maskedit_poll(bContext *C) SpaceClip *sc = CTX_wm_space_clip(C); if (sc && sc->clip) { - return ED_space_clip_show_maskedit(sc); + return ED_space_clip_check_show_maskedit(sc); } return FALSE; @@ -122,90 +122,12 @@ int ED_space_clip_maskedit_mask_poll(bContext *C) return FALSE; } -/* ******** editing functions ******** */ +/* ******** common editing functions ******** */ -void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip) +void ED_space_clip_get_size(const bContext *C, int *width, int *height) { - MovieClip *old_clip; - - if (!screen && C) - screen = CTX_wm_screen(C); - - old_clip = sc->clip; - sc->clip = clip; - - if (sc->clip && sc->clip->id.us == 0) - sc->clip->id.us = 1; - - if (screen && sc->view == SC_VIEW_CLIP) { - ScrArea *area; - SpaceLink *sl; - - for (area = screen->areabase.first; area; area = area->next) { - for (sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_CLIP) { - SpaceClip *cur_sc = (SpaceClip *) sl; - - if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) { - if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { - cur_sc->clip = clip; - } - } - } - } - } - } - - if (C) - WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); -} - -MovieClip *ED_space_clip(SpaceClip *sc) -{ - return sc->clip; -} - -Mask *ED_space_clip_mask(SpaceClip *sc) -{ - return sc->mask; -} - -ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) -{ - if (sc->clip) { - ImBuf *ibuf; - - ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); - - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; - - if (ibuf) - IMB_freeImBuf(ibuf); - } - - return NULL; -} - -ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) -{ - if (sc->clip) { - ImBuf *ibuf; - - ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); - - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; - - if (ibuf) - IMB_freeImBuf(ibuf); - } - - return NULL; -} + SpaceClip *sc = CTX_wm_space_clip(C); -void ED_space_clip_size(SpaceClip *sc, int *width, int *height) -{ if (!sc->clip) { *width = *height = 0; } @@ -214,40 +136,25 @@ void ED_space_clip_size(SpaceClip *sc, int *width, int *height) } } -void ED_space_clip_mask_size(SpaceClip *sc, int *width, int *height) +void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy) { - /* quite the same as ED_space_clip_size, but it also runs aspect correction on output resolution - * this is needed because mask should be rasterized with exactly the same resolution as - * currently displaying frame and it doesn't have access to aspect correction currently - * used for display. (sergey) - */ - - if (!sc->mask) { - *width = 0; - *height = 0; - } else { - float aspx, aspy; + ARegion *ar = CTX_wm_region(C); + int width, height; - ED_space_clip_size(sc, width, height); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); - *width *= aspx; - *height *= aspy; - } + *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); + *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); } -void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) +void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) { - int w, h; - - ED_space_clip_aspect(sc, aspx, aspy); - ED_space_clip_size(sc, &w, &h); + MovieClip *clip = ED_space_clip_get_clip(sc); - /* now this is not accounted for! */ -#if 0 - *aspx *= (float)w; - *aspy *= (float)h; -#endif + if (clip) + BKE_movieclip_aspect(clip, aspx, aspy); + else + *aspx = *aspy = 1.0f; if (*aspx < *aspy) { *aspy = *aspy / *aspx; @@ -259,27 +166,7 @@ void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) } } -void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) -{ - int width, height; - - ED_space_clip_size(sc, &width, &height); - - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); -} - -void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) -{ - MovieClip *clip = ED_space_clip(sc); - - if (clip) - BKE_movieclip_aspect(clip, aspx, aspy); - else - *aspx = *aspy = 1.0f; -} - -void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy) +void ED_space_clip_get_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy) { int w, h; @@ -290,11 +177,11 @@ void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *asp * mainly this is sued for transformation stuff */ - ED_space_clip_aspect(sc, aspx, aspy); - ED_space_clip_size(sc, &w, &h); + ED_space_clip_get_aspect(sc, aspx, aspy); + BKE_movieclip_get_size(sc->clip, &sc->user, &w, &h); - *aspx *= (float)w; - *aspy *= (float)h; + *aspx *= (float) w; + *aspy *= (float) h; if (*aspx < *aspy) { *aspy = *aspy / *aspx; @@ -306,6 +193,48 @@ void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *asp } } +/* return current frame number in clip space */ +int ED_space_clip_get_clip_frame_number(SpaceClip *sc) +{ + MovieClip *clip = ED_space_clip_get_clip(sc); + + return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); +} + +ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) +{ + if (sc->clip) { + ImBuf *ibuf; + + ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; +} + +ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) +{ + if (sc->clip) { + ImBuf *ibuf; + + ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; +} + void ED_clip_update_frame(const Main *mainp, int cfra) { wmWindowManager *wm; @@ -329,29 +258,23 @@ void ED_clip_update_frame(const Main *mainp, int cfra) } } -/* return current frame number in clip space */ -int ED_space_clip_clip_framenr(SpaceClip *sc) +static int selected_boundbox(const bContext *C, float min[2], float max[2]) { - MovieClip *clip = ED_space_clip(sc); - - return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); -} - -static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) -{ - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height, ok = FALSE; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); + int framenr = ED_space_clip_get_clip_frame_number(sc); INIT_MINMAX2(min, max); - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (marker) { float pos[3]; @@ -383,22 +306,23 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) return ok; } -int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) +int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) { + SpaceClip *sc = CTX_wm_space_clip(C); int w, h, frame_width, frame_height; float min[2], max[2]; - ED_space_clip_size(sc, &frame_width, &frame_height); + ED_space_clip_get_size(C, &frame_width, &frame_height); if (frame_width == 0 || frame_height == 0) return FALSE; - if (!selected_boundbox(sc, min, max)) + if (!selected_boundbox(C, min, max)) return FALSE; /* center view */ - clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), - (max[1] + min[1]) / (2 * frame_height)); + clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -408,7 +332,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) int width, height; float zoomx, zoomy, newzoom, aspx, aspy; - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); width = ar->winrct.xmax - ar->winrct.xmin + 1; height = ar->winrct.ymax - ar->winrct.ymin + 1; @@ -430,11 +354,11 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ copy_v2_v2(r_co, co); if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); float aspy = 1.0f / clip->tracking.camera.pixel_aspect; int width, height; - ED_space_clip_size(sc, &width, &height); + BKE_movieclip_get_size(sc->clip, &sc->user, &width, &height); r_co[0] *= width; r_co[1] *= height * aspy; @@ -446,15 +370,15 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ } } -void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *yr) +void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, float *yr) { ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); int sx, sy, width, height; float zoomx, zoomy, pos[3], imat[4][4]; - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); @@ -469,7 +393,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y *yr = pos[1] / height; if (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; float aspy = 1.0f / tracking->camera.pixel_aspect; float tmp[2] = {*xr * width, *yr * height * aspy}; @@ -485,16 +409,18 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y * \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords. * better name here? view_to_track / track_to_view or so? */ -void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2]) +void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float zoomx, zoomy; float pos[3]; int width, height; int sx, sy; UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); ED_clip_point_undistorted_pos(sc, co, pos); pos[2] = 0.0f; @@ -506,11 +432,92 @@ void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float c r_co[1] = (pos[1] * height * zoomy) + (float)sy; } -void ED_clip_mouse_pos(bContext *C, wmEvent *event, float co[2]) +void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2]) { ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]); } +int ED_space_clip_check_show_trackedit(SpaceClip *sc) +{ + if (sc) { + return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); + } + + return FALSE; +} + +int ED_space_clip_check_show_maskedit(SpaceClip *sc) +{ + if (sc) { + return sc->mode == SC_MODE_MASKEDIT; + } + + return FALSE; +} + +/* ******** clip editing functions ******** */ + +MovieClip *ED_space_clip_get_clip(SpaceClip *sc) +{ + return sc->clip; +} + +void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip) +{ + MovieClip *old_clip; + + if (!screen && C) + screen = CTX_wm_screen(C); + + old_clip = sc->clip; + sc->clip = clip; + + if (sc->clip && sc->clip->id.us == 0) + sc->clip->id.us = 1; + + if (screen && sc->view == SC_VIEW_CLIP) { + ScrArea *area; + SpaceLink *sl; + + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_CLIP) { + SpaceClip *cur_sc = (SpaceClip *) sl; + + if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) { + if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { + cur_sc->clip = clip; + } + } + } + } + } + } + + if (C) + WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); +} + +/* ******** masking editing functions ******** */ + +Mask *ED_space_clip_get_mask(SpaceClip *sc) +{ + return sc->mask; +} + +void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) +{ + sc->mask = mask; + + if (sc->mask && sc->mask->id.us == 0) { + sc->clip->id.us = 1; + } + + if (C) { + WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); + } +} + /* OpenGL draw context */ typedef struct SpaceClipDrawContext { @@ -552,7 +559,7 @@ int ED_space_clip_texture_buffer_supported(SpaceClip *sc) int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) { SpaceClipDrawContext *context = sc->draw_context; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int need_rebind = 0; context->last_texture = glaGetOneInteger(GL_TEXTURE_2D); @@ -654,36 +661,3 @@ void ED_space_clip_free_texture_buffer(SpaceClip *sc) MEM_freeN(context); } } - -/* ******** masking editing related functions ******** */ - -int ED_space_clip_show_trackedit(SpaceClip *sc) -{ - if (sc) { - return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); - } - - return FALSE; -} - -int ED_space_clip_show_maskedit(SpaceClip *sc) -{ - if (sc) { - return sc->mode == SC_MODE_MASKEDIT; - } - - return FALSE; -} - -void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) -{ - sc->mask = mask; - - if (sc->mask && sc->mask->id.us == 0) { - sc->clip->id.us = 1; - } - - if (C) { - WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); - } -} diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 323594ea469..91501971d9d 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -147,7 +147,7 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); int width, height; @@ -181,7 +181,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) static void draw_frame_curves(SpaceClip *sc) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); int i, lines = 0, prevfra = 0; @@ -214,7 +214,7 @@ static void draw_frame_curves(SpaceClip *sc) void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DGrid *grid; short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index b7687eba717..abf7f416b9c 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -166,7 +166,7 @@ static void mouse_select_init_data(MouseSelectUserData *userdata, float *co) static int mouse_select_knot(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; MovieTracking *tracking = &clip->tracking; @@ -211,7 +211,7 @@ static int mouse_select_knot(bContext *C, float co[2], int extend) static int mouse_select_curve(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MouseSelectUserData userdata; @@ -345,7 +345,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); BorderSelectuserData userdata; @@ -400,7 +400,7 @@ void CLIP_OT_graph_select_border(wmOperatorType *ot) static int graph_select_all_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MovieTrackingMarker *marker; @@ -466,7 +466,7 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -498,7 +498,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -648,7 +648,7 @@ void CLIP_OT_graph_center_current_frame(wmOperatorType *ot) static int graph_disable_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); MovieTrackingMarker *marker; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 5bc195a1ae2..c61a0baa82e 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -69,7 +69,7 @@ void clip_draw_dopesheet_channels(const struct bContext *C, struct ARegion *ar); void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot); /* clip_draw.c */ -void clip_draw_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); +void clip_draw_main(const struct bContext *C, struct ARegion *ar); void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); @@ -125,7 +125,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int in void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); -void clip_view_center_to_point(struct SpaceClip *sc, float x, float y); +void clip_view_center_to_point(const struct bContext *C, float x, float y); void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index d5ec65e68c7..e76edcf0290 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -69,8 +69,10 @@ /******************** view navigation utilities *********************/ -static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float location[2]) +static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float oldzoom = sc->zoom; int width, height; @@ -78,7 +80,7 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); width *= sc->zoom; height *= sc->zoom; @@ -92,22 +94,22 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; } } -static void sclip_zoom_set_factor(SpaceClip *sc, ARegion *ar, float zoomfac, float location[2]) +static void sclip_zoom_set_factor(const bContext *C, float zoomfac, float location[2]) { - sclip_zoom_set(sc, ar, sc->zoom*zoomfac, location); + SpaceClip *sc = CTX_wm_space_clip(C); + + sclip_zoom_set(C, sc->zoom * zoomfac, location); } static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2], *mpos = NULL; if (event) { @@ -115,7 +117,7 @@ static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor mpos = location; } - sclip_zoom_set_factor(sc, ar, factor, mpos); + sclip_zoom_set_factor(C, factor, mpos); ED_region_tag_redraw(CTX_wm_region(C)); } @@ -208,7 +210,7 @@ static int open_exec(bContext *C, wmOperator *op) RNA_property_update(C, &pprop->ptr, pprop->prop); } else if (sc) { - ED_space_clip_set(C, screen, sc, clip); + ED_space_clip_set_clip(C, screen, sc, clip); } WM_event_add_notifier(C, NC_MOVIECLIP | NA_ADDED, clip); @@ -225,7 +227,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) MovieClip *clip = NULL; if (sc) - clip = ED_space_clip(sc); + clip = ED_space_clip_get_clip(sc); if (clip) { strncpy(path, clip->name, sizeof(path)); @@ -494,10 +496,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) static int view_zoom_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); - - sclip_zoom_set_factor(sc, ar, RNA_float_get(op->ptr, "factor"), NULL); + sclip_zoom_set_factor(C, RNA_float_get(op->ptr, "factor"), NULL); ED_region_tag_redraw(CTX_wm_region(C)); @@ -525,8 +524,6 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); ViewZoomData *vpd = op->customdata; float factor; @@ -534,7 +531,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); - sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); + sclip_zoom_set(C, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); break; default: @@ -582,13 +579,11 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) static int view_zoom_in_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); - sclip_zoom_set_factor(sc, ar, 1.25f, location); + sclip_zoom_set_factor(C, 1.25f, location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -624,13 +619,11 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) static int view_zoom_out_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); - sclip_zoom_set_factor(sc, ar, 0.8f, location); + sclip_zoom_set_factor(C, 0.8f, location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -669,9 +662,8 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) static int view_zoom_ratio_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); - sclip_zoom_set(sc, ar, RNA_float_get(op->ptr, "ratio"), NULL); + sclip_zoom_set(C, RNA_float_get(op->ptr, "ratio"), NULL); /* ensure pixel exact locations for draw */ sc->xof = (int) sc->xof; @@ -713,8 +705,8 @@ static int view_all_exec(bContext *C, wmOperator *op) sc = CTX_wm_space_clip(C); ar = CTX_wm_region(C); - ED_space_clip_size(sc, &w, &h); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &w, &h); + ED_space_clip_get_aspect(sc, &aspx, &aspy); w = w * aspx; h = h * aspy; @@ -729,7 +721,7 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomx = (float) width / (w + 2 * margin); zoomy = (float) height / (h + 2 * margin); - sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); + sclip_zoom_set(C, MIN2(zoomx, zoomy), NULL); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { @@ -737,10 +729,10 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomy = (float) height / h; /* find the zoom value that will fit the image in the image space */ - sclip_zoom_set(sc, ar, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); + sclip_zoom_set(C, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); } else - sclip_zoom_set(sc, ar, 1.0f, NULL); + sclip_zoom_set(C, 1.0f, NULL); } sc->xof = sc->yof = 0.0f; @@ -775,7 +767,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) sc->xlockof = 0.0f; sc->ylockof = 0.0f; - ED_clip_view_selection(sc, ar, 1); + ED_clip_view_selection(C, ar, 1); ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; @@ -1031,7 +1023,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if ((clip->flag & MCLIP_USE_PROXY) == 0) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 3f8fd5966ec..d9c9f63e4a3 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -69,7 +69,7 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), void (*segment_end)(void *userdata)) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int width, height, coord; BKE_movieclip_get_size(clip, &sc->user, &width, &height); @@ -128,7 +128,7 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int in void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), void (*segment_end)(void *userdata)) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -147,7 +147,7 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int in void clip_graph_tracking_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata, void (*func)(void *userdata, MovieTrackingMarker *marker)) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -223,13 +223,14 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, } } -void clip_view_center_to_point(SpaceClip *sc, float x, float y) +void clip_view_center_to_point(const bContext *C, float x, float y) { + SpaceClip *sc = CTX_wm_space_clip(C); int width, height; float aspx, aspy; - ED_space_clip_size(sc, &width, &height); - ED_space_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_aspect(sc, &aspx, &aspy); sc->xof = (x - 0.5f) * width * aspx; sc->yof = (y - 0.5f) * height * aspy; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 174b7fcb373..0a6a4af6960 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -227,7 +227,7 @@ static void clip_scopes_check_gpencil_change(ScrArea *sa) static void clip_stabilization_tag_refresh(ScrArea *sa) { SpaceClip *sc = (SpaceClip *) sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { MovieTrackingStabilization *stab = &clip->tracking.stabilization; @@ -1008,13 +1008,14 @@ static void clip_refresh(const bContext *C, ScrArea *sa) /********************* main region ********************/ /* sets up the fields of the View2D from zoom and offset */ -static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) +static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) { - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); float x1, y1, w, h; int width, height, winx, winy; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); w = width; h = height; @@ -1074,12 +1075,55 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } +static void clip_main_area_draw_mask(const bContext *C, ARegion *ar) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + int x, y; + int width, height; + float zoomx, zoomy; + + /* frame image */ + float maxdim; + float xofs, yofs; + + /* find window pixel coordinates of origin */ + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + + /* frame the image */ + maxdim = maxf(width, height); + if (width == height) { + xofs = yofs = 0; + } + else if (width < height) { + xofs = ((height - width) / -2.0f) * zoomx; + yofs = 0.0f; + } + else { /* (width > height) */ + xofs = 0.0f; + yofs = ((width - height) / -2.0f) * zoomy; + } + + /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ + glPushMatrix(); + glTranslatef(x + xofs, y + yofs, 0); + glScalef(maxdim * zoomx, maxdim * zoomy, 0); + glMultMatrixf(sc->stabmat); + + ED_mask_draw(C, sc->mask_draw_flag, sc->mask_draw_type); + + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + + glPopMatrix(); +} + static void clip_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceClip *sc = CTX_wm_space_clip(C); - Scene *scene = CTX_data_scene(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); /* if tracking is in progress, we should synchronize framenr from clipuser * so latest tracked frame would be shown */ @@ -1093,7 +1137,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) tmpibuf = ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); } - if (ED_clip_view_selection(sc, ar, 0)) { + if (ED_clip_view_selection(C, ar, 0)) { sc->xof += sc->xlockof; sc->yof += sc->ylockof; } @@ -1107,51 +1151,12 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* data... */ - movieclip_main_area_set_view2d(sc, ar); + movieclip_main_area_set_view2d(C, ar); - clip_draw_main(sc, ar, scene); + clip_draw_main(C, ar); if (sc->mode == SC_MODE_MASKEDIT) { - int x, y; - int width, height; - float zoomx, zoomy, aspx, aspy; - - /* frame image */ - float maxdim; - float xofs, yofs; - - /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_aspect(sc, &aspx, &aspy); - - /* frame the image */ - maxdim = maxf(width, height); - if (width == height) { - xofs = yofs = 0; - } - else if (width < height) { - xofs = ((height - width) / -2.0f) * zoomx; - yofs = 0.0f; - } - else { /* (width > height) */ - xofs = 0.0f; - yofs = ((width - height) / -2.0f) * zoomy; - } - - /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ - glPushMatrix(); - glTranslatef(x + xofs, y + yofs, 0); - glScalef(maxdim * zoomx, maxdim * zoomy, 0); - glMultMatrixf(sc->stabmat); - - ED_mask_draw((bContext *)C, sc->mask_draw_flag, sc->mask_draw_type); - - ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - - glPopMatrix(); + clip_main_area_draw_mask(C, ar); } /* Grease Pencil */ @@ -1226,7 +1231,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; @@ -1289,7 +1294,7 @@ static void clip_channels_area_init(wmWindowManager *wm, ARegion *ar) static void clip_channels_area_draw(const bContext *C, ARegion *ar) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DScrollers *scrollers; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 8ca483c94d3..af2847492ad 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -81,16 +81,17 @@ /********************** add marker operator *********************/ -static void add_marker(SpaceClip *sc, float x, float y) +static void add_marker(const bContext *C, float x, float y) { - MovieClip *clip = ED_space_clip(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; int width, height; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height); @@ -102,18 +103,18 @@ static void add_marker(SpaceClip *sc, float x, float y) static int add_marker_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); float pos[2]; int width, height; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (!width || !height) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", pos); - add_marker(sc, pos[0], pos[1]); + add_marker(C, pos[0], pos[1]); /* reset offset from locked position, so frame jumping wouldn't be so confusing */ sc->xlockof = 0; @@ -160,7 +161,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track = tracksbase->first, *next; @@ -201,10 +202,10 @@ void CLIP_OT_delete_track(wmOperatorType *ot) static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track = tracksbase->first, *next; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int has_selection = 0; while (track) { @@ -283,7 +284,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra int area, int corner, int action, int width, int height) { SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); marker = BKE_tracking_marker_ensure(track, framenr); @@ -524,15 +525,15 @@ static void show_cursor(bContext *C) MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int *area_r, int *action_r, int *corner_r) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height; float co[2]; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int action = -1, area = 0, corner = -1; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (width == 0 || height == 0) return NULL; @@ -575,6 +576,9 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int ok = TRUE; } else { +#if 0 + /* TODO: disable for now, needs better approaches for visualization */ + if (mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 1, 12.0f, width, height)) { area = TRACK_AREA_PAT; action = SLIDE_ACTION_OFFSET; @@ -585,6 +589,7 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int action = SLIDE_ACTION_SIZE; ok = TRUE; } +#endif if (!ok && mouse_on_tilt(sc, marker, co, width, height)) { area = TRACK_AREA_PAT; action = SLIDE_ACTION_TILT_SIZE; @@ -621,10 +626,10 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) int width, height; float co[2]; void *customdata = NULL; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int area, action, corner; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (width == 0 || height == 0) return NULL; @@ -647,7 +652,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) if (slidedata) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; tracking->act_track = slidedata->track; @@ -946,7 +951,7 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) int tot = 0; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); track = tracksbase->first; while (track) { @@ -990,7 +995,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit { ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int frames_limit = 0; clear_invisible_track_selection(sc, clip); @@ -1033,14 +1038,14 @@ static int track_markers_check_direction(int backwards, int curfra, int efra) static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwards) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTrackingSettings *settings = &clip->tracking.settings; int frames_limit; track_init_markers(sc, clip, &frames_limit); - tmj->sfra = ED_space_clip_clip_framenr(sc); + tmj->sfra = ED_space_clip_get_clip_frame_number(sc); tmj->clip = clip; tmj->backwards = backwards; @@ -1157,10 +1162,10 @@ static void track_markers_freejob(void *tmv) static int track_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); struct MovieTrackingContext *context; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int sfra = framenr, efra; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); @@ -1220,7 +1225,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve TrackMarkersJob *tmj; ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); wmJob *steve; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); @@ -1326,7 +1331,7 @@ typedef struct { static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op, char *error_msg, int max_error) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTracking *tracking = &clip->tracking; MovieTrackingSettings *settings = &clip->tracking.settings; @@ -1450,7 +1455,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even SolveCameraJob *scj; ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); wmJob *steve; @@ -1532,7 +1537,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); @@ -1580,12 +1585,12 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) static int clear_track_path_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); int action = RNA_enum_get(op->ptr, "action"); int clear_active = RNA_boolean_get(op->ptr, "clear_active"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); if (clear_active) { track = BKE_tracking_track_get_active(&clip->tracking); @@ -1637,12 +1642,12 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) static int disable_markers_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track = tracksbase->first; int action = RNA_enum_get(op->ptr, "action"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); while (track) { if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { @@ -1719,7 +1724,7 @@ static Object *get_orientation_object(bContext *C) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); Object *object = NULL; @@ -1743,7 +1748,7 @@ static int set_orientation_poll(bContext *C) if (sc) { Scene *scene = CTX_data_scene(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { MovieTracking *tracking = &clip->tracking; @@ -1764,7 +1769,7 @@ static int set_orientation_poll(bContext *C) static int count_selected_bundles(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; int tot = 0; @@ -1835,7 +1840,7 @@ static Object *object_solver_camera(Scene *scene, Object *ob) static int set_origin_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; MovieTrackingObject *tracking_object; @@ -2031,7 +2036,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb static int set_plane_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; @@ -2169,7 +2174,7 @@ void CLIP_OT_set_plane(wmOperatorType *ot) static int set_axis_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); MovieTrackingTrack *track; @@ -2241,7 +2246,7 @@ void CLIP_OT_set_axis(wmOperatorType *ot) static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); MovieTrackingTrack *track; @@ -2322,7 +2327,7 @@ static int set_scale_exec(bContext *C, wmOperator *op) static int set_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist); @@ -2357,7 +2362,7 @@ static int set_solution_scale_poll(bContext *C) SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (clip) { MovieTracking *tracking = &clip->tracking; @@ -2378,7 +2383,7 @@ static int set_solution_scale_exec(bContext *C, wmOperator *op) static int set_solution_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.object_distance); @@ -2411,7 +2416,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int width, height; BKE_movieclip_get_size(clip, &sc->user, &width, &height); @@ -2447,7 +2452,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) static int hide_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -2506,7 +2511,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -2563,7 +2568,7 @@ static bGPDlayer *detect_get_layer(MovieClip *clip) static int detect_features_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS; ImBuf *ibuf = BKE_movieclip_get_ibuf_flag(clip, &sc->user, clip_flag, MOVIECLIP_CACHE_SKIP); MovieTracking *tracking = &clip->tracking; @@ -2574,7 +2579,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) int min_trackability = RNA_int_get(op->ptr, "min_trackability"); int min_distance = RNA_int_get(op->ptr, "min_distance"); int place_outside_layer = 0; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); bGPDlayer *layer = NULL; if (!ibuf) { @@ -2640,7 +2645,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int pos = RNA_enum_get(op->ptr, "position"); int delta; @@ -2665,7 +2670,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) } else { /* to to failed frame */ if (clip->tracking.reconstruction.flag & TRACKING_RECONSTRUCTED) { - int a = ED_space_clip_clip_framenr(sc); + int a = ED_space_clip_get_clip_frame_number(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); @@ -2732,7 +2737,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) static int join_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track, *track, *next; @@ -2786,7 +2791,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) static int lock_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track = tracksbase->first; @@ -2839,7 +2844,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track, *act_track = BKE_tracking_track_get_active(tracking); @@ -2886,7 +2891,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -2935,7 +2940,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingStabilization *stab = &tracking->stabilization; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -2995,7 +3000,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track; @@ -3038,7 +3043,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -3168,7 +3173,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) static int clean_tracks_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *track, *next, *act_track = BKE_tracking_track_get_active(tracking); @@ -3224,7 +3229,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (!RNA_struct_property_is_set(op->ptr, "frames")) RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames); @@ -3273,7 +3278,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; BKE_tracking_object_add(tracking, "Object"); @@ -3303,7 +3308,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) static int tracking_object_remove_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object; @@ -3341,7 +3346,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) static int copy_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); @@ -3381,7 +3386,7 @@ static int paste_tracks_poll(bContext *C) static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 640af498c1f..0ebb84b3953 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -110,15 +110,16 @@ static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx return dist < MAX2(epsx, epsy); } -static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) +static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *track) { - int framenr = ED_space_clip_clip_framenr(sc); + SpaceClip *sc = CTX_wm_space_clip(C); + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); float pat_min[2], pat_max[2]; float epsx, epsy; int width, height; - ED_space_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); @@ -187,7 +188,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas { MovieTrackingTrack *track = NULL, *cur; float mindist = 0.0f; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); cur = tracksbase->first; while (cur) { @@ -226,7 +227,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas static int mouse_select(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); @@ -235,7 +236,7 @@ static int mouse_select(bContext *C, float co[2], int extend) track = find_nearest_track(sc, tracksbase, co); if (track) { - int area = track_mouse_area(sc, co, track); + int area = track_mouse_area(C, co, track); if (!extend || !TRACK_VIEW_SELECTED(sc, track)) area = TRACK_AREA_ALL; @@ -288,7 +289,7 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) if (track) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); clip->tracking.act_track = track; @@ -332,14 +333,14 @@ void CLIP_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); rcti rect; rctf rectf; int change = FALSE, mode, extend; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); /* get rectangle from operator */ rect.xmin = RNA_int_get(op->ptr, "xmin"); @@ -412,15 +413,14 @@ void CLIP_OT_select_border(wmOperatorType *ot) static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select) { - ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); rcti rect; int change = FALSE; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); /* get rectangle from operator */ BLI_lasso_boundbox(&rect, mcords, moves); @@ -435,7 +435,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho float screen_co[2]; /* marker in screen coords */ - ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); + ED_clip_point_stable_pos__reverse(C, marker->pos, screen_co); if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) @@ -519,14 +519,13 @@ static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], f static int circle_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); - ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); /* get operator properties */ x = RNA_int_get(op->ptr, "x"); @@ -536,8 +535,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_space_clip_size(sc, &width, &height); - ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; @@ -602,13 +601,13 @@ void CLIP_OT_select_circle(wmOperatorType *ot) static int select_all_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track = NULL; /* selected track */ MovieTrackingMarker *marker; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int action = RNA_enum_get(op->ptr, "action"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); int has_selection = FALSE; if (action == SEL_TOGGLE) { @@ -692,13 +691,13 @@ void CLIP_OT_select_all(wmOperatorType *ot) static int select_groped_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; MovieTrackingMarker *marker; MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int group = RNA_enum_get(op->ptr, "group"); - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); track = tracksbase->first; while (track) { diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 10db1bb1f12..55e75992b89 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -71,7 +71,7 @@ #include "fsmenu.h" #include "filelist.h" -#include "file_intern.h" // own include +#include "file_intern.h" // own include /* button events */ enum { @@ -109,8 +109,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) { /* Button layout. */ const int max_x = ar->winx - 10; - const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN); - const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN); + const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); + const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); const int input_minw = 20; const int btn_h = UI_UNIT_Y; const int btn_fn_w = UI_UNIT_X; @@ -123,16 +123,16 @@ void file_draw_buttons(const bContext *C, ARegion *ar) int loadbutton; int fnumbuttons; int min_x = 10; - int chan_offs = 0; + int chan_offs = 0; int available_w = max_x - min_x; int line1_w = available_w; int line2_w = available_w; - uiBut* but; - uiBlock* block; - SpaceFile* sfile = CTX_wm_space_file(C); - FileSelectParams* params = ED_fileselect_get_params(sfile); - ARegion* artmp; + uiBut *but; + uiBlock *block; + SpaceFile *sfile = CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + ARegion *artmp; /* Initialize UI block. */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); @@ -140,7 +140,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiBlockSetHandleFunc(block, do_file_buttons, NULL); /* exception to make space for collapsed region icon */ - for (artmp=CTX_wm_area(C)->regionbase.first; artmp; artmp=artmp->next) { + for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) { if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) { chan_offs = 16; min_x += chan_offs; @@ -152,7 +152,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin; if (loadbutton < btn_minw) { loadbutton = MAX2(btn_minw, - btn_margin + UI_GetStringWidth(params->title)); + btn_margin + UI_GetStringWidth(params->title)); } if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) { @@ -174,12 +174,12 @@ void file_draw_buttons(const bContext *C, ARegion *ar) /* Text input fields for directory and file. */ if (available_w > 0) { - int overwrite_alert= file_draw_check_exists(sfile); + int overwrite_alert = file_draw_check_exists(sfile); /* callbacks for operator check functions */ uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL); but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "", - min_x, line1_y, line1_w-chan_offs, btn_h, + min_x, line1_y, line1_w - chan_offs, btn_h, params->dir, 0.0, (float)FILE_MAX, 0, 0, TIP_("File path")); uiButSetCompleteFunc(but, autocomplete_directory, NULL); @@ -187,9 +187,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar) if ((params->flag & FILE_DIRSEL_ONLY) == 0) { but = uiDefBut(block, TEX, B_FS_FILENAME, "", - min_x, line2_y, line2_w-chan_offs, btn_h, + min_x, line2_y, line2_w - chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE, 0, 0, - TIP_(overwrite_alert ?N_("File name, overwrite existing") : N_("File name"))); + TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name"))); uiButSetCompleteFunc(but, autocomplete_file, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */ @@ -246,8 +246,8 @@ static void draw_tile(int sx, int sy, int width, int height, int colorid, int sh static int get_file_icon(struct direntry *file) { if (file->type & S_IFDIR) { - if ( strcmp(file->relname, "..") == 0) { - return ICON_FILE_PARENT; + if (strcmp(file->relname, "..") == 0) { + return ICON_FILE_PARENT; } if (file->flags & BLENDERFILE) { return ICON_FILE_BLEND; @@ -283,7 +283,7 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, /*float alpha=1.0f;*/ x = sx; - y = sy-height; + y = sy - height; /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ @@ -292,9 +292,9 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, } -static void file_draw_string(int sx, int sy, const char* string, float width, int height, short align) +static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiFontStyle fs = style->widgetlabel; rcti rect; char fname[FILE_MAXFILE]; @@ -306,7 +306,7 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */ rect.xmin = sx; - rect.xmax = (int)(sx + ceil(width+4.0f)); + rect.xmax = (int)(sx + ceil(width + 4.0f)); rect.ymin = sy - height; rect.ymax = sy; @@ -315,12 +315,12 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in void file_calc_previews(const bContext *C, ARegion *ar) { - SpaceFile *sfile= CTX_wm_space_file(C); - View2D *v2d= &ar->v2d; + SpaceFile *sfile = CTX_wm_space_file(C); + View2D *v2d = &ar->v2d; ED_fileselect_init_layout(sfile, ar); /* +SCROLL_HEIGHT is bad hack to work around issue in UI_view2d_totRect_set */ - UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT); + UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height + V2D_SCROLL_HEIGHT); } static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow) @@ -337,13 +337,13 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) { if (imb->x > imb->y) { scaledx = (float)layout->prv_w; - scaledy = ( (float)imb->y/(float)imb->x )*layout->prv_w; - scale = scaledx/imb->x; + scaledy = ( (float)imb->y / (float)imb->x) * layout->prv_w; + scale = scaledx / imb->x; } else { scaledy = (float)layout->prv_h; - scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h; - scale = scaledy/imb->y; + scaledx = ( (float)imb->x / (float)imb->y) * layout->prv_h; + scale = scaledy / imb->y; } } else { @@ -353,8 +353,8 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int } ex = (int)scaledx; ey = (int)scaledy; - fx = ((float)layout->prv_w - (float)ex)/2.0f; - fy = ((float)layout->prv_h - (float)ey)/2.0f; + fx = ((float)layout->prv_w - (float)ex) / 2.0f; + fy = ((float)layout->prv_h - (float)ey) / 2.0f; dx = (fx + 0.5f + layout->prv_border_x); dy = (fy + 0.5f - layout->prv_border_y); xco = sx + (int)dx; @@ -389,17 +389,17 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) { - char newname[FILE_MAX+12]; - char orgname[FILE_MAX+12]; - char filename[FILE_MAX+12]; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - ARegion* ar = CTX_wm_region(C); + char newname[FILE_MAX + 12]; + char orgname[FILE_MAX + 12]; + char filename[FILE_MAX + 12]; + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + ARegion *ar = CTX_wm_region(C); BLI_make_file_string(G.main->name, orgname, sfile->params->dir, oldname); BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); - if ( strcmp(orgname, newname) != 0 ) { + if (strcmp(orgname, newname) != 0) { if (!BLI_exists(newname)) { BLI_rename(orgname, newname); /* to make sure we show what is on disk */ @@ -417,11 +417,11 @@ static void draw_background(FileLayout *layout, View2D *v2d) int sy; /* alternating flat shade background */ - for (i=0; (i <= layout->rows); i+=2) { - sy = (int)v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + for (i = 0; (i <= layout->rows); i += 2) { + sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y; UI_ThemeColorShade(TH_BACK, -7); - glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy+layout->tile_h+2*layout->tile_border_y)); + glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y)); } } @@ -433,10 +433,10 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) /* vertical column dividers */ sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { - sx += (layout->tile_w+2*layout->tile_border_x); + sx += (layout->tile_w + 2 * layout->tile_border_x); UI_ThemeColorShade(TH_BACK, 30); - sdrawline(sx+1, (short)(v2d->cur.ymax - layout->tile_border_y), sx+1, (short)v2d->cur.ymin); + sdrawline(sx + 1, (short)(v2d->cur.ymax - layout->tile_border_y), sx + 1, (short)v2d->cur.ymin); UI_ThemeColorShade(TH_BACK, -30); sdrawline(sx, (short)(v2d->cur.ymax - layout->tile_border_y), sx, (short)v2d->cur.ymin); } @@ -444,11 +444,11 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) void file_draw_list(const bContext *C, ARegion *ar) { - SpaceFile *sfile= CTX_wm_space_file(C); - FileSelectParams* params = ED_fileselect_get_params(sfile); - FileLayout* layout= ED_fileselect_get_layout(sfile, ar); - View2D *v2d= &ar->v2d; - struct FileList* files = sfile->files; + SpaceFile *sfile = CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + FileLayout *layout = ED_fileselect_get_layout(sfile, ar); + View2D *v2d = &ar->v2d; + struct FileList *files = sfile->files; struct direntry *file; ImBuf *imb; uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); @@ -472,7 +472,7 @@ void file_draw_list(const bContext *C, ARegion *ar) } offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); - if (offset<0) offset=0; + if (offset < 0) offset = 0; numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); @@ -484,14 +484,14 @@ void file_draw_list(const bContext *C, ARegion *ar) numfiles_layout += layout->columns; } - textwidth =( FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; - textheight = (int)(layout->textheight*3.0/2.0 + 0.5); + textwidth = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; + textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5); - align = ( FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; + align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; - for (i = offset; (i < numfiles) && (i<offset+numfiles_layout); i++) { + for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) { ED_fileselect_layout_tilepos(layout, i, &sx, &sy); - sx += (int)(v2d->tot.xmin+2.0f); + sx += (int)(v2d->tot.xmin + 2.0f); sy = (int)(v2d->tot.ymax - sy); file = filelist_file(files, i); @@ -503,12 +503,12 @@ void file_draw_list(const bContext *C, ARegion *ar) if ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE)) { int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK; int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0; - draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid, shade); + draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); } } uiSetRoundBox(UI_CNR_NONE); - if ( FILE_IMGDISPLAY == params->display ) { + if (FILE_IMGDISPLAY == params->display) { is_icon = 0; imb = filelist_getimage(files, i); if (!imb) { @@ -519,26 +519,26 @@ void file_draw_list(const bContext *C, ARegion *ar) file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); } else { - file_draw_icon(block, file->path, sx, sy-(UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); + file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); sx += ICON_DEFAULT_WIDTH_SCALE + 4; } UI_ThemeColor4(TH_TEXT); if (file->selflag & EDITING_FILE) { - uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy-layout->tile_h-3, - textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); + uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 3, + textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); uiButSetRenameFunc(but, renamebutton_cb, file); uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ uiButClearFlag(but, UI_BUT_UNDO); - if ( 0 == uiButActiveOnly(C, block, but)) { + if (0 == uiButActiveOnly(C, block, but)) { file->selflag &= ~EDITING_FILE; } } if (!(file->selflag & EDITING_FILE)) { int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy; - file_draw_string(sx+1, tpos, file->relname, (float)textwidth, textheight, align); + file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align); } if (params->display == FILE_SHORTDISPLAY) { diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index d3598ffd4e7..3ad6614d356 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -41,12 +41,12 @@ struct SpaceFile; struct ARegion *file_buttons_region(struct ScrArea *sa); /* file_draw.c */ -#define TILE_BORDER_X (UI_UNIT_X/4) -#define TILE_BORDER_Y (UI_UNIT_Y/4) +#define TILE_BORDER_X (UI_UNIT_X / 4) +#define TILE_BORDER_Y (UI_UNIT_Y / 4) /* ui geometry */ -#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y*2) -#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y/6) +#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y * 2) +#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y / 6) void file_draw_buttons(const bContext *C, ARegion *ar); void file_calc_previews(const bContext *C, ARegion *ar); @@ -98,12 +98,12 @@ void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); /* filesel.c */ -float file_shorten_string(char* string, float w, int front); -float file_string_width(const char* str); +float file_shorten_string(char *string, float w, int front); +float file_string_width(const char *str); float file_font_pointsize(void); void file_change_dir(bContext *C, int checkdir); -int file_select_match(struct SpaceFile *sfile, const char *pattern); +int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file); void autocomplete_directory(struct bContext *C, char *str, void *arg_v); void autocomplete_file(struct bContext *C, char *str, void *arg_v); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4bb5a21cb3d..0cf3586e659 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -65,17 +65,17 @@ #include <ctype.h> /* for events */ -#define NOTACTIVEFILE 0 -#define ACTIVATE 1 -#define INACTIVATE 2 +#define NOTACTIVEFILE 0 +#define ACTIVATE 1 +#define INACTIVATE 2 /* ---------- FILE SELECTION ------------ */ -static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, const rcti* rect) +static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, const rcti *rect) { FileSelection sel; float fxmin, fymin, fxmax, fymax; - View2D* v2d = &ar->v2d; + View2D *v2d = &ar->v2d; rcti rect_view; UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin); @@ -88,11 +88,11 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, return sel; } -static void file_deselect_all(SpaceFile* sfile, unsigned int flag) +static void file_deselect_all(SpaceFile *sfile, unsigned int flag) { FileSelection sel; sel.first = 0; - sel.last = filelist_numfiles(sfile->files)-1; + sel.last = filelist_numfiles(sfile->files) - 1; filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); } @@ -103,10 +103,10 @@ typedef enum FileSelect { FILE_SELECT_FILE = 2 } FileSelect; -static void clamp_to_filelist(int numfiles, FileSelection* sel) +static void clamp_to_filelist(int numfiles, FileSelection *sel) { /* border select before the first file */ - if ( (sel->first < 0) && (sel->last >=0 ) ) { + if ( (sel->first < 0) && (sel->last >= 0) ) { sel->first = 0; } /* don't select if everything is outside filelist */ @@ -117,67 +117,67 @@ static void clamp_to_filelist(int numfiles, FileSelection* sel) /* fix if last file invalid */ if ( (sel->first > 0) && (sel->last < 0) ) - sel->last = numfiles-1; + sel->last = numfiles - 1; /* clamp */ if ( (sel->first >= numfiles) ) { - sel->first = numfiles-1; + sel->first = numfiles - 1; } if ( (sel->last >= numfiles) ) { - sel->last = numfiles-1; + sel->last = numfiles - 1; } } -static FileSelection file_selection_get(bContext* C, const rcti* rect, short fill) +static FileSelection file_selection_get(bContext *C, const rcti *rect, short fill) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); int numfiles = filelist_numfiles(sfile->files); FileSelection sel; sel = find_file_mouse_rect(sfile, ar, rect); - if ( !((sel.first == -1) && (sel.last == -1)) ) { + if (!((sel.first == -1) && (sel.last == -1)) ) { clamp_to_filelist(numfiles, &sel); } /* if desired, fill the selection up from the last selected file to the current one */ if (fill && (sel.last >= 0) && (sel.last < numfiles) ) { - int f= sel.last; + int f = sel.last; while (f >= 0) { - if ( filelist_is_selected(sfile->files, f, CHECK_ALL) ) + if (filelist_is_selected(sfile->files, f, CHECK_ALL) ) break; f--; } if (f >= 0) { - sel.first = f+1; + sel.first = f + 1; } } return sel; } -static FileSelect file_select_do(bContext* C, int selected_idx) +static FileSelect file_select_do(bContext *C, int selected_idx) { FileSelect retval = FILE_SELECT_NOTHING; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); int numfiles = filelist_numfiles(sfile->files); - struct direntry* file; + struct direntry *file; /* make the selected file active */ - if ( (selected_idx >= 0) && - (selected_idx < numfiles) && - (file= filelist_file(sfile->files, selected_idx))) + if ((selected_idx >= 0) && + (selected_idx < numfiles) && + (file = filelist_file(sfile->files, selected_idx))) { params->active_file = selected_idx; if (S_ISDIR(file->type)) { /* the path is too long and we are not going up! */ - if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) { + if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { // XXX error("Path too long, cannot enter this directory"); } else { - if (strcmp(file->relname, "..")==0) { + if (strcmp(file->relname, "..") == 0) { /* avoids /../../ */ BLI_parent_dir(params->dir); } @@ -202,12 +202,12 @@ static FileSelect file_select_do(bContext* C, int selected_idx) } -static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, short fill) +static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, short fill) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; - FileSelection sel= file_selection_get(C, rect, fill); /* get the selection */ - const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; + FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */ + const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; /* flag the files as selected in the filelist */ filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type); @@ -231,15 +231,15 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); FileSelection sel; rcti rect; int result; - result= WM_border_select_modal(C, op, event); + result = WM_border_select_modal(C, op, event); if (result == OPERATOR_RUNNING_MODAL) { @@ -254,7 +254,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) { file_deselect_all(sfile, HILITED_FILE); filelist_select(sfile->files, &sel, FILE_SEL_ADD, HILITED_FILE, CHECK_ALL); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } params->sel_first = sel.first; params->sel_last = sel.last; @@ -263,7 +263,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) params->active_file = -1; params->sel_first = params->sel_last = -1; file_deselect_all(sfile, HILITED_FILE); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } return result; @@ -271,11 +271,11 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) static int file_border_select_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); rcti rect; FileSelect ret; - int extend= RNA_boolean_get(op->ptr, "extend"); - short select= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); + int extend = RNA_boolean_get(op->ptr, "extend"); + short select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -283,7 +283,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); if (!extend) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); file_deselect_all(sfile, SELECTED_FILE); } @@ -292,10 +292,10 @@ static int file_border_select_exec(bContext *C, wmOperator *op) ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0); if (FILE_SELECT_DIR == ret) { - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } else if (FILE_SELECT_FILE == ret) { - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } return OPERATOR_FINISHED; } @@ -320,8 +320,8 @@ void FILE_OT_select_border(wmOperatorType *ot) static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelect ret; rcti rect; int extend = RNA_boolean_get(op->ptr, "extend"); @@ -341,12 +341,12 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill); if (FILE_SELECT_DIR == ret) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); else if (FILE_SELECT_FILE == ret) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); WM_event_add_mousemove(C); /* for directory changes */ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); return OPERATOR_FINISHED; } @@ -369,18 +369,18 @@ void FILE_OT_select(wmOperatorType *ot) static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelection sel; int numfiles = filelist_numfiles(sfile->files); int i; int is_selected = 0; sel.first = 0; - sel.last = numfiles-1; + sel.last = numfiles - 1; /* Is any file selected ? */ - for ( i=0; i < numfiles; ++i) { + for (i = 0; i < numfiles; ++i) { if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { is_selected = 1; break; @@ -391,7 +391,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, SELECTED_FILE, CHECK_ALL); } else { - const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; + const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, check_type); } ED_area_tag_redraw(sa); @@ -418,18 +418,18 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) static int bookmark_select_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (RNA_struct_find_property(op->ptr, "dir")) { char entry[256]; - FileSelectParams* params = sfile->params; + FileSelectParams *params = sfile->params; RNA_string_get(op->ptr, "dir", entry); BLI_strncpy(params->dir, entry, sizeof(params->dir)); BLI_cleanup_dir(G.main->name, params->dir); file_change_dir(C, 1); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -451,10 +451,10 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); - struct FSMenu* fsmenu = fsmenu_get(); - struct FileSelectParams* params= ED_fileselect_get_params(sfile); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); + struct FSMenu *fsmenu = fsmenu_get(); + struct FileSelectParams *params = ED_fileselect_get_params(sfile); if (params->dir[0] != '\0') { char name[FILE_MAX]; @@ -482,13 +482,13 @@ void FILE_OT_bookmark_add(wmOperatorType *ot) static int bookmark_delete_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - struct FSMenu* fsmenu = fsmenu_get(); + ScrArea *sa = CTX_wm_area(C); + struct FSMenu *fsmenu = fsmenu_get(); int nentries = fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS); if (RNA_struct_find_property(op->ptr, "index")) { int index = RNA_int_get(op->ptr, "index"); - if ( (index >-1) && (index < nentries)) { + if ( (index > -1) && (index < nentries)) { char name[FILE_MAX]; fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); @@ -517,16 +517,16 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { - View2D* v2d = &ar->v2d; - FileSelectParams* params; + View2D *v2d = &ar->v2d; + FileSelectParams *params; int numfiles, origfile; - if (sfile==NULL || sfile->files==NULL) return 0; + if (sfile == NULL || sfile->files == NULL) return 0; numfiles = filelist_numfiles(sfile->files); params = ED_fileselect_get_params(sfile); - origfile= params->active_file; + origfile = params->active_file; mx -= ar->winrct.xmin; my -= ar->winrct.ymin; @@ -540,20 +540,20 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) active_file = ED_fileselect_layout_offset(sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy)); if ((active_file >= 0) && (active_file < numfiles)) - params->active_file=active_file; + params->active_file = active_file; else - params->active_file= -1; + params->active_file = -1; } else - params->active_file= -1; + params->active_file = -1; return (params->active_file != origfile); } static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (!file_hilight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; @@ -577,7 +577,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; sfile->op = NULL; @@ -590,9 +590,9 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_operator_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); - if (!sfile || !sfile->op) poll= 0; + if (!sfile || !sfile->op) poll = 0; return poll; } @@ -634,30 +634,45 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) * they may be already set. */ { PointerRNA itemptr; - PropertyRNA *prop_files= RNA_struct_find_property(op->ptr, "files"); - PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); + PropertyRNA *prop_files = RNA_struct_find_property(op->ptr, "files"); + PropertyRNA *prop_dirs = RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); if (prop_files) { + int num_files = 0; RNA_property_collection_clear(op->ptr, prop_files); - for (i=0; i<numfiles; i++) { + for (i = 0; i < numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { - struct direntry *file= filelist_file(sfile->files, i); + struct direntry *file = filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_files, &itemptr); RNA_string_set(&itemptr, "name", file->relname); + num_files++; } } + /* make sure the file specified in the filename button is added even if no files selected */ + if (0 == num_files) { + RNA_property_collection_add(op->ptr, prop_files, &itemptr); + RNA_string_set(&itemptr, "name", sfile->params->file); + } } if (prop_dirs) { + int num_dirs = 0; RNA_property_collection_clear(op->ptr, prop_dirs); - for (i=0; i<numfiles; i++) { + for (i = 0; i < numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) { - struct direntry *file= filelist_file(sfile->files, i); + struct direntry *file = filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); RNA_string_set(&itemptr, "name", file->relname); + num_dirs++; } } + + /* make sure the directory specified in the button is added even if no directory selected */ + if (0 == num_dirs) { + RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); + RNA_string_set(&itemptr, "name", sfile->params->dir); + } } @@ -669,16 +684,16 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ - if ((prop= RNA_struct_find_property(op->ptr, "filepath"))) { + if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { char filepath[FILE_MAX]; RNA_property_string_get(op->ptr, prop, filepath); BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); } else { - if ((prop= RNA_struct_find_property(op->ptr, "filename"))) { + if ((prop = RNA_struct_find_property(op->ptr, "filename"))) { RNA_property_string_get(op->ptr, prop, sfile->params->file); } - if ((prop= RNA_struct_find_property(op->ptr, "directory"))) { + if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } @@ -692,8 +707,8 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; if (op) { /* fail on reload */ if (op->type->check) { char filepath[FILE_MAX]; @@ -730,20 +745,20 @@ int file_draw_check_exists(SpaceFile *sfile) /* sends events now, so things get handled on windowqueue level */ int file_exec(bContext *C, wmOperator *exec_op) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); char filepath[FILE_MAX]; if (sfile->op) { - wmOperator *op= sfile->op; + wmOperator *op = sfile->op; /* when used as a macro, for doubleclick, * to prevent closing when doubleclicking on .. item */ if (RNA_boolean_get(exec_op->ptr, "need_active")) { - int i, active=0; + int i, active = 0; - for (i=0; i<filelist_numfiles(sfile->files); i++) { + for (i = 0; i < filelist_numfiles(sfile->files); i++) { if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { - active=1; + active = 1; break; } } @@ -788,14 +803,14 @@ void FILE_OT_execute(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (BLI_has_parent(sfile->params->dir)) { BLI_parent_dir(sfile->params->dir); BLI_cleanup_dir(G.main->name, sfile->params->dir); file_change_dir(C, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } } @@ -819,15 +834,15 @@ void FILE_OT_parent(struct wmOperatorType *ot) static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); - struct FSMenu* fsmenu = fsmenu_get(); + SpaceFile *sfile = CTX_wm_space_file(C); + struct FSMenu *fsmenu = fsmenu_get(); ED_fileselect_clear(C, sfile); /* refresh system directory menu */ fsmenu_refresh_system_category(fsmenu); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; @@ -847,7 +862,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (!sfile->folders_next) @@ -859,7 +874,7 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -878,7 +893,7 @@ void FILE_OT_next(struct wmOperatorType *ot) int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -891,7 +906,7 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -901,31 +916,31 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { ScrArea *sa = CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); - ARegion *ar, *oldar= CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); + ARegion *ar, *oldar = CTX_wm_region(C); int offset; int numfiles, numfiles_layout; int edit_idx = 0; int i; /* escape if not our timer */ - if (sfile->smoothscroll_timer==NULL || sfile->smoothscroll_timer!=event->customdata) + if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) return OPERATOR_PASS_THROUGH; numfiles = filelist_numfiles(sfile->files); /* check if we are editing a name */ - for (i=0; i < numfiles; ++i) { + for (i = 0; i < numfiles; ++i) { if (filelist_is_selected(sfile->files, i, CHECK_ALL) ) { - edit_idx=i; + edit_idx = i; break; } } /* if we are not editing, we are done */ - if (0==edit_idx) { + if (0 == edit_idx) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_PASS_THROUGH; } @@ -933,21 +948,21 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (!ar || ar->regiontype != RGN_TYPE_WINDOW) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_PASS_THROUGH; } offset = ED_fileselect_layout_offset(sfile->layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); - if (offset<0) offset=0; + if (offset < 0) offset = 0; /* scroll offset is the first file in the row/column we are editing in */ if (sfile->scroll_offset == 0) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { - sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows; + sfile->scroll_offset = (edit_idx / sfile->layout->rows) * sfile->layout->rows; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows; } else { - sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns; + sfile->scroll_offset = (edit_idx / sfile->layout->columns) * sfile->layout->columns; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } } @@ -957,7 +972,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent /* check if we have reached our final scroll position */ if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_FINISHED; } @@ -1011,7 +1026,7 @@ void FILE_OT_smoothscroll(wmOperatorType *ot) /* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created. * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name. */ -static int new_folder_path(const char* parent, char *folder, char *name) +static int new_folder_path(const char *parent, char *folder, char *name) { int i = 1; int len = 0; @@ -1021,22 +1036,22 @@ static int new_folder_path(const char* parent, char *folder, char *name) /* check whether folder with the name already exists, in this case * add number to the name. Check length of generated name to avoid * crazy case of huge number of folders each named 'New Folder (x)' */ - while (BLI_exists(folder) && (len<FILE_MAXFILE)) { + while (BLI_exists(folder) && (len < FILE_MAXFILE)) { len = BLI_snprintf(name, FILE_MAXFILE, "New Folder(%d)", i); BLI_join_dirfile(folder, FILE_MAX, parent, name); /* XXX, not real length */ i++; } - return (len<FILE_MAXFILE); + return (len < FILE_MAXFILE); } int file_directory_new_exec(bContext *C, wmOperator *op) { char name[FILE_MAXFILE]; char path[FILE_MAX]; - int generate_name= 1; + int generate_name = 1; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (!sfile->params) { BKE_report(op->reports, RPT_WARNING, "No parent directory given"); @@ -1047,7 +1062,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op) if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", path); - if (path[0] != '\0') generate_name= 0; + if (path[0] != '\0') generate_name = 0; } if (generate_name) { @@ -1070,12 +1085,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op) BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); /* set timer to smoothly view newly generated file */ - sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/1000.0); /* max 30 frs/sec */ - sfile->scroll_offset=0; + sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ + sfile->scroll_offset = 0; /* reload dir to make sure we're seeing what's in the directory */ ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -1100,7 +1115,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) static void file_expand_directory(bContext *C) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { /* TODO, what about // when relbase isn't valid? */ @@ -1108,8 +1123,8 @@ static void file_expand_directory(bContext *C) BLI_path_abs(sfile->params->dir, G.main->name); } else if (sfile->params->dir[0] == '~') { - char tmpstr[sizeof(sfile->params->dir)-1]; - BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); + char tmpstr[sizeof(sfile->params->dir) - 1]; + BLI_strncpy(tmpstr, sfile->params->dir + 1, sizeof(tmpstr)); BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr); } @@ -1125,12 +1140,12 @@ static void file_expand_directory(bContext *C) } /* change "C:" --> "C:\", [#28102] */ else if ( (isalpha(sfile->params->dir[0]) && - (sfile->params->dir[1] == ':')) && + (sfile->params->dir[1] == ':')) && (sfile->params->dir[2] == '\0') - ) { - sfile->params->dir[2]= '\\'; - sfile->params->dir[3]= '\0'; + ) { + sfile->params->dir[2] = '\\'; + sfile->params->dir[3] = '\0'; } #endif } @@ -1138,14 +1153,14 @@ static void file_expand_directory(bContext *C) static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { file_expand_directory(C); if (!BLI_exists(sfile->params->dir)) { return WM_operator_confirm_message(C, op, "Create new directory?"); - } + } return file_directory_exec(C, op); } @@ -1157,7 +1172,7 @@ static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { file_expand_directory(C); @@ -1177,23 +1192,27 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) BLI_add_slash(sfile->params->dir); file_change_dir(C, 1); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); - } - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); + } return OPERATOR_FINISHED; } int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); - + SpaceFile *sfile = CTX_wm_space_file(C); + char matched_file[FILE_MAX]; if (sfile->params) { - if (file_select_match(sfile, sfile->params->file)) { + matched_file[0] = '\0'; + if (file_select_match(sfile, sfile->params->file, matched_file)) { + /* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */ sfile->params->file[0] = '\0'; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ + BLI_strncpy(sfile->params->file, matched_file, sizeof(sfile->params->file)); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } - } + } return OPERATOR_FINISHED; } @@ -1203,8 +1222,8 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_directory_poll(bContext *C) { /* sfile->files can be NULL on file load */ - SpaceFile *sfile= CTX_wm_space_file(C); - return ED_operator_file_active(C) && (sfile->files==NULL || filelist_lib(sfile->files)==NULL); + SpaceFile *sfile = CTX_wm_space_file(C); + return ED_operator_file_active(C) && (sfile->files == NULL || filelist_lib(sfile->files) == NULL); } void FILE_OT_directory(struct wmOperatorType *ot) @@ -1234,12 +1253,12 @@ void FILE_OT_refresh(struct wmOperatorType *ot) static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -1262,23 +1281,23 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) { ARegion *ar, *arnew; - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->regiontype==RGN_TYPE_CHANNELS) + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->regiontype == RGN_TYPE_CHANNELS) return ar; /* add subdiv level; after header */ - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->regiontype==RGN_TYPE_HEADER) + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->regiontype == RGN_TYPE_HEADER) break; /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for file panels"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for file panels"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_CHANNELS; - arnew->alignment= RGN_ALIGN_LEFT; + arnew->regiontype = RGN_TYPE_CHANNELS; + arnew->alignment = RGN_ALIGN_LEFT; arnew->flag = RGN_FLAG_HIDDEN; @@ -1287,8 +1306,8 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= file_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = file_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -1311,8 +1330,8 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) static int file_filenum_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= CTX_wm_space_file(C); - ScrArea *sa= CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); + ScrArea *sa = CTX_wm_area(C); int inc = RNA_int_get(op->ptr, "increment"); if (sfile->params && (inc != 0)) { @@ -1343,17 +1362,17 @@ void FILE_OT_filenum(struct wmOperatorType *ot) static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); if (sfile->params) { int idx = sfile->params->active_file; int numfiles = filelist_numfiles(sfile->files); - if ( (0<=idx) && (idx<numfiles) ) { - struct direntry *file= filelist_file(sfile->files, idx); + if ( (0 <= idx) && (idx < numfiles) ) { + struct direntry *file = filelist_file(sfile->files, idx); filelist_select_file(sfile->files, idx, FILE_SEL_ADD, EDITING_FILE, CHECK_ALL); BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE); - sfile->params->renamefile[0]= '\0'; + sfile->params->renamefile[0] = '\0'; } ED_area_tag_redraw(sa); } @@ -1365,19 +1384,19 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) static int file_rename_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile && sfile->params) { if (sfile->params->active_file < 0) { - poll= 0; + poll = 0; } else { char dir[FILE_MAX], group[FILE_MAX]; - if (filelist_islibrary(sfile->files, dir, group)) poll= 0; + if (filelist_islibrary(sfile->files, dir, group)) poll = 0; } } else - poll= 0; + poll = 0; return poll; } @@ -1397,22 +1416,22 @@ void FILE_OT_rename(struct wmOperatorType *ot) static int file_delete_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); - struct direntry* file; + SpaceFile *sfile = CTX_wm_space_file(C); + struct direntry *file; if (sfile && sfile->params) { if (sfile->params->active_file < 0) { - poll= 0; + poll = 0; } else { char dir[FILE_MAX], group[FILE_MAX]; - if (filelist_islibrary(sfile->files, dir, group)) poll= 0; + if (filelist_islibrary(sfile->files, dir, group)) poll = 0; file = filelist_file(sfile->files, sfile->params->active_file); - if (file && S_ISDIR(file->type)) poll= 0; + if (file && S_ISDIR(file->type)) poll = 0; } } else - poll= 0; + poll = 0; return poll; } @@ -1420,15 +1439,15 @@ static int file_delete_poll(bContext *C) int file_delete_exec(bContext *C, wmOperator *UNUSED(op)) { char str[FILE_MAX]; - SpaceFile *sfile= CTX_wm_space_file(C); - struct direntry* file; + SpaceFile *sfile = CTX_wm_space_file(C); + struct direntry *file; file = filelist_file(sfile->files, sfile->params->active_file); BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname); BLI_delete(str, 0, 0); ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index a17a7edbd80..51bd660e126 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -59,7 +59,7 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) { PointerRNA ptr; - char *entry= (char*)arg_entry; + char *entry = (char *)arg_entry; WM_operator_properties_create(&ptr, "FILE_OT_select_bookmark"); RNA_string_set(&ptr, "dir", entry); @@ -69,15 +69,15 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete, int reverse) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); uiBlock *block; uiBut *but; uiLayout *box, *col; - struct FSMenu* fsmenu = fsmenu_get(); + struct FSMenu *fsmenu = fsmenu_get(); int i, i_iter, nentries = fsmenu_get_nentries(fsmenu, category); /* reset each time */ - *nr= -1; + *nr = -1; /* hide if no entries */ if (nentries == 0) @@ -85,24 +85,24 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* layout */ uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT); - block= uiLayoutGetBlock(pa->layout); - box= uiLayoutBox(pa->layout); - col= uiLayoutColumn(box, 1); + block = uiLayoutGetBlock(pa->layout); + box = uiLayoutBox(pa->layout); + col = uiLayoutColumn(box, TRUE); - for (i_iter=0; i_iter< nentries;++i_iter) { + for (i_iter = 0; i_iter < nentries; ++i_iter) { char dir[FILE_MAX]; char temp[FILE_MAX]; - uiLayout* layout = uiLayoutRow(col, 0); + uiLayout *layout = uiLayoutRow(col, FALSE); char *entry; - i= reverse ? nentries-(i_iter+1) : i_iter; + i = reverse ? nentries - (i_iter + 1) : i_iter; entry = fsmenu_get_entry(fsmenu, category, i); /* set this list item as active if we have a match */ if (sfile->params) { if (BLI_path_cmp(sfile->params->dir, entry) == 0) { - *nr= i; + *nr = i; } } @@ -118,7 +118,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* create list item */ but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry); uiButSetFunc(but, file_panel_cb, entry, NULL); - uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); + uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT); /* create delete button */ if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { @@ -131,7 +131,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat static void file_panel_system(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0); @@ -139,11 +139,11 @@ static void file_panel_system(const bContext *C, Panel *pa) static void file_panel_bookmarks(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); uiLayout *row; if (sfile) { - row= uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); @@ -153,10 +153,10 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) static void file_panel_recent(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { - if ( !(U.uiflag & USER_HIDE_RECENT) ) { + if (!(U.uiflag & USER_HIDE_RECENT) ) { file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1); } } @@ -165,31 +165,31 @@ static void file_panel_recent(const bContext *C, Panel *pa) static int file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); return (sfile && sfile->op); } static void file_panel_operator_header(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; BLI_strncpy(pa->drawname, RNA_struct_ui_name(op->type->srna), sizeof(pa->drawname)); } static int file_panel_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { - const char *prop_id= RNA_property_identifier(prop); - return !( strcmp(prop_id, "filepath") == 0 || - strcmp(prop_id, "directory") == 0 || - strcmp(prop_id, "filename") == 0 - ); + const char *prop_id = RNA_property_identifier(prop); + return !(strcmp(prop_id, "filepath") == 0 || + strcmp(prop_id, "directory") == 0 || + strcmp(prop_id, "filename") == 0 + ); } static void file_panel_operator(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; // int empty= 1, flag; uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); @@ -203,30 +203,30 @@ void file_panels_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype file system directories"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file system directories"); strcpy(pt->idname, "FILE_PT_system"); strcpy(pt->label, N_("System")); - pt->draw= file_panel_system; + pt->draw = file_panel_system; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); strcpy(pt->idname, "FILE_PT_bookmarks"); strcpy(pt->label, N_("Bookmarks")); - pt->draw= file_panel_bookmarks; + pt->draw = file_panel_bookmarks; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file recent directories"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file recent directories"); strcpy(pt->idname, "FILE_PT_recent"); strcpy(pt->label, N_("Recent")); - pt->draw= file_panel_recent; + pt->draw = file_panel_recent; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); strcpy(pt->idname, "FILE_PT_operator"); strcpy(pt->label, N_("Operator")); - pt->poll= file_panel_operator_poll; - pt->draw_header= file_panel_operator_header; - pt->draw= file_panel_operator; + pt->poll = file_panel_operator_poll; + pt->draw_header = file_panel_operator_header; + pt->draw = file_panel_operator; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index afd04697e5e..6d2c8657f0b 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -98,7 +98,7 @@ typedef struct ThumbnailJob { ListBase loadimages; short *stop; short *do_update; - struct FileList* filelist; + struct FileList *filelist; ReportList reports; } ThumbnailJob; @@ -119,7 +119,7 @@ typedef struct FileList { short hide_parent; void (*readf)(struct FileList *); - int (*filterf)(struct direntry* file, const char* dir, unsigned int filter, short hide_dot); + int (*filterf)(struct direntry *file, const char *dir, unsigned int filter, short hide_dot); } FileList; @@ -145,25 +145,25 @@ typedef struct FolderList { #define SPECIAL_IMG_LOADING 10 #define SPECIAL_IMG_MAX SPECIAL_IMG_LOADING + 1 -static ImBuf* gSpecialFileImages[SPECIAL_IMG_MAX]; +static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX]; /* ******************* SORT ******************* */ static int compare_name(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -172,28 +172,28 @@ static int compare_name(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); return (BLI_natstrcmp(entry1->relname, entry2->relname)); } static int compare_date(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -202,31 +202,31 @@ static int compare_date(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); - if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1; - if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1; + if (entry1->s.st_mtime < entry2->s.st_mtime) return 1; + if (entry1->s.st_mtime > entry2->s.st_mtime) return -1; else return BLI_natstrcmp(entry1->relname, entry2->relname); } static int compare_size(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -235,39 +235,39 @@ static int compare_size(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); - if ( entry1->s.st_size < entry2->s.st_size) return 1; - if ( entry1->s.st_size > entry2->s.st_size) return -1; + if (entry1->s.st_size < entry2->s.st_size) return 1; + if (entry1->s.st_size > entry2->s.st_size) return -1; else return BLI_natstrcmp(entry1->relname, entry2->relname); } static int compare_extension(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; const char *sufix1, *sufix2; - const char *nil=""; + const char *nil = ""; - if (!(sufix1= strstr (entry1->relname, ".blend.gz"))) - sufix1= strrchr (entry1->relname, '.'); - if (!(sufix2= strstr (entry2->relname, ".blend.gz"))) - sufix2= strrchr (entry2->relname, '.'); - if (!sufix1) sufix1= nil; - if (!sufix2) sufix2= nil; + if (!(sufix1 = strstr(entry1->relname, ".blend.gz"))) + sufix1 = strrchr(entry1->relname, '.'); + if (!(sufix2 = strstr(entry2->relname, ".blend.gz"))) + sufix2 = strrchr(entry2->relname, '.'); + if (!sufix1) sufix1 = nil; + if (!sufix2) sufix2 = nil; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -276,46 +276,46 @@ static int compare_extension(const void *a1, const void *a2) if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if ( strcmp(entry1->relname, ".")==0 ) return (-1); - if ( strcmp(entry2->relname, ".")==0 ) return (1); - if ( strcmp(entry1->relname, "..")==0 ) return (-1); - if ( strcmp(entry2->relname, "..")==0 ) return (1); + if (strcmp(entry1->relname, ".") == 0) return (-1); + if (strcmp(entry2->relname, ".") == 0) return (1); + if (strcmp(entry1->relname, "..") == 0) return (-1); + if (strcmp(entry2->relname, "..") == 0) return (1); return (BLI_strcasecmp(sufix1, sufix2)); } -static int is_hidden_file(const char* filename, short hide_dot) +static int is_hidden_file(const char *filename, short hide_dot) { - int is_hidden=0; + int is_hidden = 0; if (hide_dot) { - if (filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { - is_hidden=1; /* ignore .file */ + if (filename[0] == '.' && filename[1] != '.' && filename[1] != 0) { + is_hidden = 1; /* ignore .file */ } else if (((filename[0] == '.') && (filename[1] == 0) )) { - is_hidden=1; /* ignore . */ + is_hidden = 1; /* ignore . */ } else { - int len=strlen(filename); - if ( (len>0) && (filename[len-1]=='~') ) { - is_hidden=1; /* ignore file~ */ + int len = strlen(filename); + if ( (len > 0) && (filename[len - 1] == '~') ) { + is_hidden = 1; /* ignore file~ */ } } } else { if (((filename[0] == '.') && (filename[1] == 0) )) { - is_hidden=1; /* ignore . */ + is_hidden = 1; /* ignore . */ } } return is_hidden; } -static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsigned int filter, short hide_dot) +static int is_filtered_file(struct direntry *file, const char *UNUSED(dir), unsigned int filter, short hide_dot) { - int is_filtered=0; + int is_filtered = 0; if (filter) { if (file->flags & filter) { - is_filtered=1; + is_filtered = 1; } else if (file->type & S_IFDIR) { if (filter & FOLDERFILE) { @@ -329,9 +329,9 @@ static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsi return is_filtered && !is_hidden_file(file->relname, hide_dot); } -static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int filter, short hide_dot) +static int is_filtered_lib(struct direntry *file, const char *dir, unsigned int filter, short hide_dot) { - int is_filtered=0; + int is_filtered = 0; char tdir[FILE_MAX], tgroup[GROUP_MAX]; if (BLO_is_a_library(dir, tdir, tgroup)) { is_filtered = !is_hidden_file(file->relname, hide_dot); @@ -342,12 +342,12 @@ static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int return is_filtered; } -static int is_filtered_main(struct direntry* file, const char* UNUSED(dir), unsigned int UNUSED(filter), short hide_dot) +static int is_filtered_main(struct direntry *file, const char *UNUSED(dir), unsigned int UNUSED(filter), short hide_dot) { return !is_hidden_file(file->relname, hide_dot); } -void filelist_filter(FileList* filelist) +void filelist_filter(FileList *filelist) { int num_filtered = 0; int i, j; @@ -358,7 +358,7 @@ void filelist_filter(FileList* filelist) // How many files are left after filter ? for (i = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; - if ( filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { + if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { num_filtered++; } } @@ -367,12 +367,12 @@ void filelist_filter(FileList* filelist) MEM_freeN(filelist->fidx); filelist->fidx = NULL; } - filelist->fidx = (int *)MEM_callocN(num_filtered*sizeof(int), "filteridx"); + filelist->fidx = (int *)MEM_callocN(num_filtered * sizeof(int), "filteridx"); filelist->numfiltered = num_filtered; - for (i = 0, j=0; i < filelist->numfiles; ++i) { + for (i = 0, j = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; - if ( filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { + if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { filelist->fidx[j++] = i; } } @@ -386,16 +386,16 @@ void filelist_init_icons(void) #ifdef WITH_HEADLESS bbuf = NULL; #else - bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect, "<splash>"); + bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons, datatoc_prvicons_size, IB_rect, "<splash>"); #endif if (bbuf) { - for (y=0; y<SPECIAL_IMG_ROWS; y++) { - for (x=0; x<SPECIAL_IMG_COLS; x++) { - int tile = SPECIAL_IMG_COLS*y + x; + for (y = 0; y < SPECIAL_IMG_ROWS; y++) { + for (x = 0; x < SPECIAL_IMG_COLS; x++) { + int tile = SPECIAL_IMG_COLS * y + x; if (tile < SPECIAL_IMG_MAX) { ibuf = IMB_allocImBuf(SPECIAL_IMG_SIZE, SPECIAL_IMG_SIZE, 32, IB_rect); - for (k=0; k<SPECIAL_IMG_SIZE; k++) { - memcpy(&ibuf->rect[k*SPECIAL_IMG_SIZE], &bbuf->rect[(k+y*SPECIAL_IMG_SIZE)*SPECIAL_IMG_SIZE*SPECIAL_IMG_COLS+x*SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE*sizeof(int)); + for (k = 0; k < SPECIAL_IMG_SIZE; k++) { + memcpy(&ibuf->rect[k * SPECIAL_IMG_SIZE], &bbuf->rect[(k + y * SPECIAL_IMG_SIZE) * SPECIAL_IMG_SIZE * SPECIAL_IMG_COLS + x * SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE * sizeof(int)); } gSpecialFileImages[tile] = ibuf; } @@ -408,20 +408,20 @@ void filelist_init_icons(void) void filelist_free_icons(void) { int i; - for (i=0; i < SPECIAL_IMG_MAX; ++i) { + for (i = 0; i < SPECIAL_IMG_MAX; ++i) { IMB_freeImBuf(gSpecialFileImages[i]); gSpecialFileImages[i] = NULL; } } //-----------------FOLDERLIST (previous/next) --------------// -struct ListBase* folderlist_new(void) +ListBase *folderlist_new(void) { - ListBase* p = MEM_callocN(sizeof(ListBase), "folderlist" ); + ListBase *p = MEM_callocN(sizeof(ListBase), "folderlist"); return p; } -void folderlist_popdir(struct ListBase* folderlist, char *dir) +void folderlist_popdir(struct ListBase *folderlist, char *dir) { const char *prev_dir; struct FolderList *folder; @@ -441,21 +441,21 @@ void folderlist_popdir(struct ListBase* folderlist, char *dir) // delete the folder next or use setdir directly before PREVIOUS OP } -void folderlist_pushdir(ListBase* folderlist, const char *dir) +void folderlist_pushdir(ListBase *folderlist, const char *dir) { struct FolderList *folder, *previous_folder; previous_folder = folderlist->last; // check if already exists if (previous_folder && previous_folder->foldername) { - if (BLI_path_cmp(previous_folder->foldername, dir)==0) { + if (BLI_path_cmp(previous_folder->foldername, dir) == 0) { return; } } // create next folder element - folder = (FolderList*)MEM_mallocN(sizeof(FolderList), "FolderList"); - folder->foldername = (char*)MEM_mallocN(sizeof(char)*(strlen(dir)+1), "foldername"); + folder = (FolderList *)MEM_mallocN(sizeof(FolderList), "FolderList"); + folder->foldername = (char *)MEM_mallocN(sizeof(char) * (strlen(dir) + 1), "foldername"); folder->foldername[0] = '\0'; BLI_strncpy(folder->foldername, dir, FILE_MAXDIR); @@ -474,7 +474,7 @@ int folderlist_clear_next(struct SpaceFile *sfile) // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next folder = sfile->folders_prev->last; - if ((!folder) ||(BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) + if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) return 0; // eventually clear flist->folders_next @@ -482,27 +482,27 @@ int folderlist_clear_next(struct SpaceFile *sfile) } /* not listbase itself */ -void folderlist_free(ListBase* folderlist) +void folderlist_free(ListBase *folderlist) { if (folderlist) { FolderList *folder; - for (folder= folderlist->first; folder; folder= folder->next) + for (folder = folderlist->first; folder; folder = folder->next) MEM_freeN(folder->foldername); BLI_freelistN(folderlist); } } -ListBase *folderlist_duplicate(ListBase* folderlist) +ListBase *folderlist_duplicate(ListBase *folderlist) { if (folderlist) { - ListBase *folderlistn= MEM_callocN(sizeof(ListBase), "copy folderlist"); + ListBase *folderlistn = MEM_callocN(sizeof(ListBase), "copy folderlist"); FolderList *folder; BLI_duplicatelist(folderlistn, folderlist); - for (folder= folderlistn->first; folder; folder= folder->next) { - folder->foldername= MEM_dupallocN(folder->foldername); + for (folder = folderlistn->first; folder; folder = folder->next) { + folder->foldername = MEM_dupallocN(folder->foldername); } return folderlistn; } @@ -510,14 +510,14 @@ ListBase *folderlist_duplicate(ListBase* folderlist) } -static void filelist_read_main(struct FileList* filelist); -static void filelist_read_library(struct FileList* filelist); -static void filelist_read_dir(struct FileList* filelist); +static void filelist_read_main(struct FileList *filelist); +static void filelist_read_library(struct FileList *filelist); +static void filelist_read_dir(struct FileList *filelist); //------------------FILELIST------------------------// -struct FileList* filelist_new(short type) +FileList *filelist_new(short type) { - FileList* p = MEM_callocN(sizeof(FileList), "filelist" ); + FileList *p = MEM_callocN(sizeof(FileList), "filelist"); switch (type) { case FILE_MAIN: p->readf = filelist_read_main; @@ -536,7 +536,7 @@ struct FileList* filelist_new(short type) } -void filelist_free(struct FileList* filelist) +void filelist_free(struct FileList *filelist) { int i; @@ -570,51 +570,51 @@ void filelist_free(struct FileList* filelist) filelist->filelist = NULL; filelist->filter = 0; filelist->filter_glob[0] = '\0'; - filelist->numfiltered =0; - filelist->hide_dot =0; + filelist->numfiltered = 0; + filelist->hide_dot = 0; } -void filelist_freelib(struct FileList* filelist) +void filelist_freelib(struct FileList *filelist) { if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= NULL; + filelist->libfiledata = NULL; } -struct BlendHandle *filelist_lib(struct FileList* filelist) +BlendHandle *filelist_lib(struct FileList *filelist) { return filelist->libfiledata; } -int filelist_numfiles(struct FileList* filelist) +int filelist_numfiles(struct FileList *filelist) { return filelist->numfiltered; } -const char * filelist_dir(struct FileList* filelist) +const char *filelist_dir(struct FileList *filelist) { return filelist->dir; } -void filelist_setdir(struct FileList* filelist, const char *dir) +void filelist_setdir(struct FileList *filelist, const char *dir) { BLI_strncpy(filelist->dir, dir, sizeof(filelist->dir)); } -void filelist_imgsize(struct FileList* filelist, short w, short h) +void filelist_imgsize(struct FileList *filelist, short w, short h) { filelist->prv_w = w; filelist->prv_h = h; } -short filelist_changed(struct FileList* filelist) +short filelist_changed(struct FileList *filelist) { return filelist->changed; } -struct ImBuf * filelist_getimage(struct FileList* filelist, int index) +ImBuf *filelist_getimage(struct FileList *filelist, int index) { - ImBuf* ibuf = NULL; + ImBuf *ibuf = NULL; int fidx = 0; if ( (index < 0) || (index >= filelist->numfiltered) ) { return NULL; @@ -625,10 +625,10 @@ struct ImBuf * filelist_getimage(struct FileList* filelist, int index) return ibuf; } -struct ImBuf * filelist_geticon(struct FileList* filelist, int index) +ImBuf *filelist_geticon(struct FileList *filelist, int index) { - ImBuf* ibuf= NULL; - struct direntry *file= NULL; + ImBuf *ibuf = NULL; + struct direntry *file = NULL; int fidx = 0; if ( (index < 0) || (index >= filelist->numfiltered) ) { return NULL; @@ -636,7 +636,7 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) fidx = filelist->fidx[index]; file = &filelist->filelist[fidx]; if (file->type & S_IFDIR) { - if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) { + if (strcmp(filelist->filelist[fidx].relname, "..") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT]; } else if (strcmp(filelist->filelist[fidx].relname, ".") == 0) { @@ -675,7 +675,7 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) return ibuf; } -struct direntry * filelist_file(struct FileList* filelist, int index) +struct direntry *filelist_file(struct FileList *filelist, int index) { int fidx = 0; @@ -687,7 +687,7 @@ struct direntry * filelist_file(struct FileList* filelist, int index) return &filelist->filelist[fidx]; } -int filelist_find(struct FileList* filelist, const char *filename) +int filelist_find(struct FileList *filelist, const char *filename) { int index = -1; int i; @@ -698,7 +698,7 @@ int filelist_find(struct FileList* filelist, const char *filename) for (i = 0; i < filelist->numfiles; ++i) { - if ( strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ + if (strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ index = i; break; } @@ -713,17 +713,17 @@ int filelist_find(struct FileList* filelist, const char *filename) return fidx; } -void filelist_hidedot(struct FileList* filelist, short hide) +void filelist_hidedot(struct FileList *filelist, short hide) { filelist->hide_dot = hide; } -void filelist_setfilter(struct FileList* filelist, unsigned int filter) +void filelist_setfilter(struct FileList *filelist, unsigned int filter) { filelist->filter = filter; } -void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob) +void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob) { BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob)); } @@ -731,23 +731,23 @@ void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob static int file_is_blend_backup(const char *str) { short a, b; - int retval= 0; + int retval = 0; - a= strlen(str); - b= 7; + a = strlen(str); + b = 7; - if (a==0 || b>=a); + if (a == 0 || b >= a) ; else { char *loc; - if (a > b+1) + if (a > b + 1) b++; /* allow .blend1 .blend2 .blend32 */ - loc= BLI_strcasestr(str+a-b, ".blend"); + loc = BLI_strcasestr(str + a - b, ".blend"); if (loc) - retval= 1; + retval = 1; } return (retval); @@ -801,37 +801,37 @@ static int file_extension_type(const char *relname) int ED_file_extension_icon(const char *relname) { - int type= file_extension_type(relname); + int type = file_extension_type(relname); - if (type == BLENDERFILE || type==BLENDERFILE_BACKUP) + if (type == BLENDERFILE || type == BLENDERFILE_BACKUP) return ICON_FILE_BLEND; - else if (type == IMAGEFILE) + else if (type == IMAGEFILE) return ICON_FILE_IMAGE; - else if (type == MOVIEFILE) + else if (type == MOVIEFILE) return ICON_FILE_MOVIE; - else if (type == PYSCRIPTFILE) + else if (type == PYSCRIPTFILE) return ICON_FILE_SCRIPT; - else if (type == SOUNDFILE) + else if (type == SOUNDFILE) return ICON_FILE_SOUND; - else if (type == FTFONTFILE) + else if (type == FTFONTFILE) return ICON_FILE_FONT; - else if (type == BTXFILE) + else if (type == BTXFILE) return ICON_FILE_BLANK; - else if (type == COLLADAFILE) + else if (type == COLLADAFILE) return ICON_FILE_BLANK; return ICON_FILE_BLANK; } -static void filelist_setfiletypes(struct FileList* filelist) +static void filelist_setfiletypes(struct FileList *filelist) { struct direntry *file; int num; - file= filelist->filelist; + file = filelist->filelist; - for (num=0; num<filelist->numfiles; num++, file++) { - file->type= file->s.st_mode; /* restore the mess below */ + for (num = 0; num < filelist->numfiles; num++, file++) { + file->type = file->s.st_mode; /* restore the mess below */ /* Don't check extensions for directories */ if (file->type & S_IFDIR) { @@ -842,21 +842,21 @@ static void filelist_setfiletypes(struct FileList* filelist) if (filelist->filter_glob && BLI_testextensie_glob(file->relname, filelist->filter_glob)) { - file->flags= OPERATORFILE; + file->flags = OPERATORFILE; } } } -static void filelist_read_dir(struct FileList* filelist) +static void filelist_read_dir(struct FileList *filelist) { - char wdir[FILE_MAX]= ""; + char wdir[FILE_MAX] = ""; if (!filelist) return; filelist->fidx = NULL; filelist->filelist = NULL; - BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ + BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ BLI_cleanup_dir(G.main->name, filelist->dir); filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist)); @@ -866,13 +866,13 @@ static void filelist_read_dir(struct FileList* filelist) filelist_filter(filelist); } -static void filelist_read_main(struct FileList* filelist) +static void filelist_read_main(struct FileList *filelist) { if (!filelist) return; filelist_from_main(filelist); } -static void filelist_read_library(struct FileList* filelist) +static void filelist_read_library(struct FileList *filelist) { if (!filelist) return; BLI_cleanup_dir(G.main->name, filelist->dir); @@ -884,7 +884,7 @@ static void filelist_read_library(struct FileList* filelist) BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; - for (num=0; num<filelist->numfiles; num++, file++) { + for (num = 0; num < filelist->numfiles; num++, file++) { if (BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; @@ -900,26 +900,26 @@ static void filelist_read_library(struct FileList* filelist) } } -void filelist_readdir(struct FileList* filelist) +void filelist_readdir(struct FileList *filelist) { filelist->readf(filelist); } -int filelist_empty(struct FileList* filelist) +int filelist_empty(struct FileList *filelist) { return filelist->filelist == NULL; } -void filelist_parent(struct FileList* filelist) +void filelist_parent(struct FileList *filelist) { BLI_parent_dir(filelist->dir); BLI_make_exist(filelist->dir); filelist_readdir(filelist); } -void filelist_select_file(struct FileList* filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) +void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) { - struct direntry* file = filelist_file(filelist, index); + struct direntry *file = filelist_file(filelist, index); if (file != NULL) { int check_ok = 0; switch (check) { @@ -950,7 +950,7 @@ void filelist_select_file(struct FileList* filelist, int index, FileSelType sele } } -void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag, FileCheckType check) +void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType select, unsigned int flag, FileCheckType check) { /* select all valid files between first and last indicated */ if ( (sel->first >= 0) && (sel->first < filelist->numfiltered) && (sel->last >= 0) && (sel->last < filelist->numfiltered) ) { @@ -961,9 +961,9 @@ void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType } } -int filelist_is_selected(struct FileList* filelist, int index, FileCheckType check) +int filelist_is_selected(struct FileList *filelist, int index, FileCheckType check) { - struct direntry* file = filelist_file(filelist, index); + struct direntry *file = filelist_file(filelist, index); if (!file) { return 0; } @@ -978,27 +978,27 @@ int filelist_is_selected(struct FileList* filelist, int index, FileCheckType che } } -void filelist_sort(struct FileList* filelist, short sort) +void filelist_sort(struct FileList *filelist, short sort) { switch (sort) { - case FILE_SORT_ALPHA: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name); - break; - case FILE_SORT_TIME: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date); - break; - case FILE_SORT_SIZE: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size); - break; - case FILE_SORT_EXTENSION: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension); + case FILE_SORT_ALPHA: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name); + break; + case FILE_SORT_TIME: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date); + break; + case FILE_SORT_SIZE: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size); + break; + case FILE_SORT_EXTENSION: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension); } filelist_filter(filelist); } -int filelist_islibrary(struct FileList* filelist, char* dir, char* group) +int filelist_islibrary(struct FileList *filelist, char *dir, char *group) { return BLO_is_a_library(filelist->dir, dir, group); } @@ -1009,27 +1009,27 @@ static int groupname_to_code(const char *group) char *lslash; BLI_strncpy(buf, group, sizeof(buf)); - lslash= BLI_last_slash(buf); + lslash = BLI_last_slash(buf); if (lslash) - lslash[0]= '\0'; + lslash[0] = '\0'; return BKE_idcode_from_name(buf); } -void filelist_from_library(struct FileList* filelist) +void filelist_from_library(struct FileList *filelist) { LinkNode *l, *names, *previews; - struct ImBuf* ima; + struct ImBuf *ima; int ok, i, nprevs, nnames, idcode; char filename[FILE_MAX]; char dir[FILE_MAX], group[GROUP_MAX]; /* name test */ - ok= filelist_islibrary(filelist, dir, group); + ok = filelist_islibrary(filelist, dir, group); if (!ok) { /* free */ if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= NULL; + filelist->libfiledata = NULL; return; } @@ -1038,40 +1038,40 @@ void filelist_from_library(struct FileList* filelist) /* there we go */ /* for the time being only read filedata when libfiledata==0 */ if (filelist->libfiledata == NULL) { - filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); + filelist->libfiledata = BLO_blendhandle_from_file(dir, NULL); if (filelist->libfiledata == NULL) return; } - idcode= groupname_to_code(group); + idcode = groupname_to_code(group); /* memory for strings is passed into filelist[i].relname * and freed in freefilelist */ if (idcode) { - previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); - names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); + previews = BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); + names = BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); /* ugh, no rewind, need to reopen */ BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); + filelist->libfiledata = BLO_blendhandle_from_file(dir, NULL); } else { - previews= NULL; - nprevs= 0; - names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata); - nnames= BLI_linklist_length(names); + previews = NULL; + nprevs = 0; + names = BLO_blendhandle_get_linkable_groups(filelist->libfiledata); + nnames = BLI_linklist_length(names); } - filelist->numfiles= nnames + 1; - filelist->filelist= malloc(filelist->numfiles * sizeof(*filelist->filelist)); + filelist->numfiles = nnames + 1; + filelist->filelist = malloc(filelist->numfiles * sizeof(*filelist->filelist)); memset(filelist->filelist, 0, filelist->numfiles * sizeof(*filelist->filelist)); - filelist->filelist[0].relname= BLI_strdup(".."); + filelist->filelist[0].relname = BLI_strdup(".."); filelist->filelist[0].type |= S_IFDIR; - for (i=0, l= names; i<nnames; i++, l= l->next) { - char *blockname= l->link; + for (i = 0, l = names; i < nnames; i++, l = l->next) { + char *blockname = l->link; - filelist->filelist[i + 1].relname= BLI_strdup(blockname); + filelist->filelist[i + 1].relname = BLI_strdup(blockname); if (idcode) { filelist->filelist[i + 1].type |= S_IFREG; } @@ -1084,8 +1084,8 @@ void filelist_from_library(struct FileList* filelist) printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs); } else if (previews) { - for (i=0, l= previews; i<nnames; i++, l= l->next) { - PreviewImage *img= l->link; + for (i = 0, l = previews; i < nnames; i++, l = l->next) { + PreviewImage *img = l->link; if (img) { unsigned int w = img->w[ICON_SIZE_PREVIEW]; @@ -1095,7 +1095,7 @@ void filelist_from_library(struct FileList* filelist) /* first allocate imbuf for copying preview into it */ if (w > 0 && h > 0 && rect) { ima = IMB_allocImBuf(w, h, 32, IB_rect); - memcpy(ima->rect, rect, w*h*sizeof(unsigned int)); + memcpy(ima->rect, rect, w * h * sizeof(unsigned int)); filelist->filelist[i + 1].image = ima; filelist->filelist[i + 1].flags = IMAGEFILE; } @@ -1108,13 +1108,13 @@ void filelist_from_library(struct FileList* filelist) filelist_sort(filelist, FILE_SORT_ALPHA); - BLI_strncpy(G.main->name, filename, sizeof(filename)); // prevent G.main->name to change + BLI_strncpy(G.main->name, filename, sizeof(filename)); /* prevent G.main->name to change */ filelist->filter = 0; filelist_filter(filelist); } -void filelist_hideparent(struct FileList* filelist, short hide) +void filelist_hideparent(struct FileList *filelist, short hide) { filelist->hide_parent = hide; } @@ -1128,110 +1128,110 @@ void filelist_from_main(struct FileList *filelist) // filelist->type = FILE_MAIN; // XXXXX TODO: add modes to filebrowser - if (filelist->dir[0]=='/') filelist->dir[0]= 0; + if (filelist->dir[0] == '/') filelist->dir[0] = 0; if (filelist->dir[0]) { - idcode= groupname_to_code(filelist->dir); - if (idcode==0) filelist->dir[0]= 0; + idcode = groupname_to_code(filelist->dir); + if (idcode == 0) filelist->dir[0] = 0; } - if ( filelist->dir[0]==0) { + if (filelist->dir[0] == 0) { /* make directories */ - filelist->numfiles= 25; - filelist->filelist= (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); + filelist->numfiles = 25; + filelist->filelist = (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); - for (a=0; a<filelist->numfiles; a++) { + for (a = 0; a < filelist->numfiles; a++) { memset(&(filelist->filelist[a]), 0, sizeof(struct direntry)); filelist->filelist[a].type |= S_IFDIR; } - filelist->filelist[0].relname= BLI_strdup(".."); - filelist->filelist[2].relname= BLI_strdup("Scene"); - filelist->filelist[3].relname= BLI_strdup("Object"); - filelist->filelist[4].relname= BLI_strdup("Mesh"); - filelist->filelist[5].relname= BLI_strdup("Curve"); - filelist->filelist[6].relname= BLI_strdup("Metaball"); - filelist->filelist[7].relname= BLI_strdup("Material"); - filelist->filelist[8].relname= BLI_strdup("Texture"); - filelist->filelist[9].relname= BLI_strdup("Image"); - filelist->filelist[10].relname= BLI_strdup("Ika"); - filelist->filelist[11].relname= BLI_strdup("Wave"); - filelist->filelist[12].relname= BLI_strdup("Lattice"); - filelist->filelist[13].relname= BLI_strdup("Lamp"); - filelist->filelist[14].relname= BLI_strdup("Camera"); - filelist->filelist[15].relname= BLI_strdup("Ipo"); - filelist->filelist[16].relname= BLI_strdup("World"); - filelist->filelist[17].relname= BLI_strdup("Screen"); - filelist->filelist[18].relname= BLI_strdup("VFont"); - filelist->filelist[19].relname= BLI_strdup("Text"); - filelist->filelist[20].relname= BLI_strdup("Armature"); - filelist->filelist[21].relname= BLI_strdup("Action"); - filelist->filelist[22].relname= BLI_strdup("NodeTree"); - filelist->filelist[23].relname= BLI_strdup("Speaker"); + filelist->filelist[0].relname = BLI_strdup(".."); + filelist->filelist[2].relname = BLI_strdup("Scene"); + filelist->filelist[3].relname = BLI_strdup("Object"); + filelist->filelist[4].relname = BLI_strdup("Mesh"); + filelist->filelist[5].relname = BLI_strdup("Curve"); + filelist->filelist[6].relname = BLI_strdup("Metaball"); + filelist->filelist[7].relname = BLI_strdup("Material"); + filelist->filelist[8].relname = BLI_strdup("Texture"); + filelist->filelist[9].relname = BLI_strdup("Image"); + filelist->filelist[10].relname = BLI_strdup("Ika"); + filelist->filelist[11].relname = BLI_strdup("Wave"); + filelist->filelist[12].relname = BLI_strdup("Lattice"); + filelist->filelist[13].relname = BLI_strdup("Lamp"); + filelist->filelist[14].relname = BLI_strdup("Camera"); + filelist->filelist[15].relname = BLI_strdup("Ipo"); + filelist->filelist[16].relname = BLI_strdup("World"); + filelist->filelist[17].relname = BLI_strdup("Screen"); + filelist->filelist[18].relname = BLI_strdup("VFont"); + filelist->filelist[19].relname = BLI_strdup("Text"); + filelist->filelist[20].relname = BLI_strdup("Armature"); + filelist->filelist[21].relname = BLI_strdup("Action"); + filelist->filelist[22].relname = BLI_strdup("NodeTree"); + filelist->filelist[23].relname = BLI_strdup("Speaker"); filelist->filelist[24].relname= BLI_strdup("FreestyleLineStyle"); filelist_sort(filelist, FILE_SORT_ALPHA); } else { /* make files */ - idcode= groupname_to_code(filelist->dir); + idcode = groupname_to_code(filelist->dir); - lb= which_libbase(G.main, idcode ); + lb = which_libbase(G.main, idcode); if (lb == NULL) return; - id= lb->first; - filelist->numfiles= 0; + id = lb->first; + filelist->numfiles = 0; while (id) { if (!filelist->hide_dot || id->name[2] != '.') { filelist->numfiles++; } - id= id->next; + id = id->next; } /* XXXXX TODO: if databrowse F4 or append/link filelist->hide_parent has to be set */ - if (!filelist->hide_parent) filelist->numfiles+= 1; - filelist->filelist= filelist->numfiles > 0 ? (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)) : NULL; + if (!filelist->hide_parent) filelist->numfiles += 1; + filelist->filelist = filelist->numfiles > 0 ? (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)) : NULL; files = filelist->filelist; if (!filelist->hide_parent) { memset(&(filelist->filelist[0]), 0, sizeof(struct direntry)); - filelist->filelist[0].relname= BLI_strdup(".."); + filelist->filelist[0].relname = BLI_strdup(".."); filelist->filelist[0].type |= S_IFDIR; files++; } - id= lb->first; - totlib= totbl= 0; + id = lb->first; + totlib = totbl = 0; while (id) { ok = 1; if (ok) { if (!filelist->hide_dot || id->name[2] != '.') { memset(files, 0, sizeof(struct direntry)); - if (id->lib==NULL) - files->relname= BLI_strdup(id->name+2); + if (id->lib == NULL) + files->relname = BLI_strdup(id->name + 2); else { - files->relname= MEM_mallocN(FILE_MAX+32, "filename for lib"); - sprintf(files->relname, "%s | %s", id->lib->name, id->name+2); + files->relname = MEM_mallocN(FILE_MAX + 32, "filename for lib"); + sprintf(files->relname, "%s | %s", id->lib->name, id->name + 2); } files->type |= S_IFREG; -#if 0 // XXXXX TODO show the selection status of the objects +#if 0 // XXXXX TODO show the selection status of the objects if (!filelist->has_func) { /* F4 DATA BROWSE */ - if (idcode==ID_OB) { + if (idcode == ID_OB) { if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; } - else if (idcode==ID_SCE) { + else if (idcode == ID_SCE) { if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE; } } #endif - files->nr= totbl+1; - files->poin= id; - fake= id->flag & LIB_FAKEUSER; + files->nr = totbl + 1; + files->poin = id; + fake = id->flag & LIB_FAKEUSER; if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { files->flags |= IMAGEFILE; } @@ -1241,7 +1241,7 @@ void filelist_from_main(struct FileList *filelist) else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us); if (id->lib) { - if (totlib==0) firstlib= files; + if (totlib == 0) firstlib = files; totlib++; } @@ -1250,11 +1250,11 @@ void filelist_from_main(struct FileList *filelist) totbl++; } - id= id->next; + id = id->next; } /* only qsort of library blocks */ - if (totlib>1) { + if (totlib > 1) { qsort(firstlib, totlib, sizeof(struct direntry), compare_name); } } @@ -1264,10 +1264,10 @@ void filelist_from_main(struct FileList *filelist) static void thumbnail_joblist_free(ThumbnailJob *tj) { - FileImage* limg = tj->loadimages.first; + FileImage *limg = tj->loadimages.first; /* free the images not yet copied to the filelist -> these will get freed with the filelist */ - for ( ; limg; limg= limg->next) { + for (; limg; limg = limg->next) { if ((limg->img) && (!limg->done)) { IMB_freeImBuf(limg->img); } @@ -1277,26 +1277,26 @@ static void thumbnail_joblist_free(ThumbnailJob *tj) static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float *UNUSED(progress)) { - ThumbnailJob *tj= tjv; - FileImage* limg = tj->loadimages.first; + ThumbnailJob *tj = tjv; + FileImage *limg = tj->loadimages.first; - tj->stop= stop; - tj->do_update= do_update; + tj->stop = stop; + tj->do_update = do_update; - while ( (*stop==0) && (limg) ) { - if ( limg->flags & IMAGEFILE ) { + while ( (*stop == 0) && (limg) ) { + if (limg->flags & IMAGEFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE); } - else if ( limg->flags & BLENDERFILE ) { + else if (limg->flags & BLENDERFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND); } - else if ( limg->flags & MOVIEFILE ) { + else if (limg->flags & MOVIEFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_MOVIE); if (!limg->img) { - /* remember that file can't be loaded via IMB_open_anim */ - limg->flags &= ~MOVIEFILE; - limg->flags |= MOVIEFILE_ICON; - } + /* remember that file can't be loaded via IMB_open_anim */ + limg->flags &= ~MOVIEFILE; + limg->flags |= MOVIEFILE_ICON; + } } *do_update = TRUE; PIL_sleep_ms(10); @@ -1306,10 +1306,10 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float static void thumbnails_update(void *tjv) { - ThumbnailJob *tj= tjv; + ThumbnailJob *tj = tjv; if (tj->filelist && tj->filelist->filelist) { - FileImage* limg = tj->loadimages.first; + FileImage *limg = tj->loadimages.first; while (limg) { if (!limg->done && limg->img) { tj->filelist->filelist[limg->index].image = limg->img; @@ -1327,28 +1327,28 @@ static void thumbnails_update(void *tjv) static void thumbnails_free(void *tjv) { - ThumbnailJob *tj= tjv; + ThumbnailJob *tj = tjv; thumbnail_joblist_free(tj); MEM_freeN(tj); } -void thumbnails_start(struct FileList* filelist, const struct bContext* C) +void thumbnails_start(struct FileList *filelist, const struct bContext *C) { wmJob *steve; ThumbnailJob *tj; int idx; /* prepare job data */ - tj= MEM_callocN(sizeof(ThumbnailJob), "thumbnails\n"); + tj = MEM_callocN(sizeof(ThumbnailJob), "thumbnails\n"); tj->filelist = filelist; - for (idx = 0; idx < filelist->numfiles;idx++) { + for (idx = 0; idx < filelist->numfiles; idx++) { if (!filelist->filelist[idx].image) { - if ( (filelist->filelist[idx].flags & (IMAGEFILE|MOVIEFILE|BLENDERFILE)) ) { - FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); + if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE)) ) { + FileImage *limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); BLI_strncpy(limg->path, filelist->filelist[idx].path, FILE_MAX); - limg->index= idx; - limg->flags= filelist->filelist[idx].flags; + limg->index = idx; + limg->flags = filelist->filelist[idx].flags; BLI_addtail(&tj->loadimages, limg); } } @@ -1357,7 +1357,7 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C) BKE_reports_init(&tj->reports, RPT_PRINT); /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); WM_jobs_customdata(steve, tj, thumbnails_free); WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW); WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL); @@ -1366,12 +1366,12 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C) WM_jobs_start(CTX_wm_manager(C), steve); } -void thumbnails_stop(struct FileList* filelist, const struct bContext* C) +void thumbnails_stop(struct FileList *filelist, const struct bContext *C) { WM_jobs_kill(CTX_wm_manager(C), filelist, NULL); } -int thumbnails_running(struct FileList* filelist, const struct bContext* C) +int thumbnails_running(struct FileList *filelist, const struct bContext *C) { return WM_jobs_test(CTX_wm_manager(C), filelist); } diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 7a37c5fb3c5..32a31c51229 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -49,8 +49,8 @@ struct FileSelection; typedef enum FileSelType { FILE_SEL_REMOVE = 0, - FILE_SEL_ADD = 1, - FILE_SEL_TOGGLE = 2 + FILE_SEL_ADD = 1, + FILE_SEL_TOGGLE = 2 } FileSelType; typedef enum FileCheckType { @@ -59,49 +59,49 @@ typedef enum FileCheckType { CHECK_ALL = 3 } FileCheckType; -struct FileList * filelist_new(short type); -void filelist_init_icons(void); -void filelist_free_icons(void); -int filelist_find(struct FileList* filelist, const char *file); -void filelist_free(struct FileList* filelist); -void filelist_sort(struct FileList* filelist, short sort); -int filelist_numfiles(struct FileList* filelist); -const char * filelist_dir(struct FileList* filelist); -void filelist_setdir(struct FileList* filelist, const char *dir); -struct direntry * filelist_file(struct FileList* filelist, int index); -void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag, FileCheckType check); -void filelist_select_file(struct FileList* filelist, int index, FileSelType select, unsigned int flag, FileCheckType check); -int filelist_is_selected(struct FileList* filelist, int index, FileCheckType check); -void filelist_hidedot(struct FileList* filelist, short hide); -void filelist_setfilter(struct FileList* filelist, unsigned int filter); -void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob); -void filelist_filter(struct FileList* filelist); -void filelist_imgsize(struct FileList* filelist, short w, short h); -struct ImBuf * filelist_getimage(struct FileList* filelist, int index); -struct ImBuf * filelist_geticon(struct FileList* filelist, int index); -short filelist_changed(struct FileList* filelist); -void filelist_readdir(struct FileList* filelist); +struct FileList * filelist_new(short type); +void filelist_init_icons(void); +void filelist_free_icons(void); +int filelist_find(struct FileList *filelist, const char *file); +void filelist_free(struct FileList *filelist); +void filelist_sort(struct FileList *filelist, short sort); +int filelist_numfiles(struct FileList *filelist); +const char * filelist_dir(struct FileList *filelist); +void filelist_setdir(struct FileList *filelist, const char *dir); +struct direntry * filelist_file(struct FileList *filelist, int index); +void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType select, unsigned int flag, FileCheckType check); +void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check); +int filelist_is_selected(struct FileList *filelist, int index, FileCheckType check); +void filelist_hidedot(struct FileList *filelist, short hide); +void filelist_setfilter(struct FileList *filelist, unsigned int filter); +void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob); +void filelist_filter(struct FileList *filelist); +void filelist_imgsize(struct FileList *filelist, short w, short h); +struct ImBuf * filelist_getimage(struct FileList *filelist, int index); +struct ImBuf * filelist_geticon(struct FileList *filelist, int index); +short filelist_changed(struct FileList *filelist); +void filelist_readdir(struct FileList *filelist); -int filelist_empty(struct FileList* filelist); -void filelist_parent(struct FileList* filelist); +int filelist_empty(struct FileList *filelist); +void filelist_parent(struct FileList *filelist); -struct BlendHandle *filelist_lib(struct FileList* filelist); -int filelist_islibrary (struct FileList* filelist, char* dir, char* group); -void filelist_from_main(struct FileList* filelist); -void filelist_from_library(struct FileList* filelist); -void filelist_freelib(struct FileList* filelist); -void filelist_hideparent(struct FileList* filelist, short hide); +struct BlendHandle *filelist_lib(struct FileList *filelist); +int filelist_islibrary(struct FileList *filelist, char *dir, char *group); +void filelist_from_main(struct FileList *filelist); +void filelist_from_library(struct FileList *filelist); +void filelist_freelib(struct FileList *filelist); +void filelist_hideparent(struct FileList *filelist, short hide); -struct ListBase * folderlist_new(void); -void folderlist_free(struct ListBase* folderlist); -struct ListBase * folderlist_duplicate(ListBase* folderlist); -void folderlist_popdir(struct ListBase* folderlist, char *dir); -void folderlist_pushdir(struct ListBase* folderlist, const char *dir); -int folderlist_clear_next(struct SpaceFile* sfile); +struct ListBase * folderlist_new(void); +void folderlist_free(struct ListBase *folderlist); +struct ListBase * folderlist_duplicate(ListBase *folderlist); +void folderlist_popdir(struct ListBase *folderlist, char *dir); +void folderlist_pushdir(struct ListBase *folderlist, const char *dir); +int folderlist_clear_next(struct SpaceFile *sfile); -void thumbnails_stop(struct FileList* filelist, const struct bContext* C); -void thumbnails_start(struct FileList* filelist, const struct bContext* C); -int thumbnails_running(struct FileList* filelist, const struct bContext* C); +void thumbnails_stop(struct FileList *filelist, const struct bContext *C); +void thumbnails_start(struct FileList *filelist, const struct bContext *C); +int thumbnails_running(struct FileList *filelist, const struct bContext *C); #ifdef __cplusplus } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index b0818d40e53..adb3e7acca5 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -86,7 +86,7 @@ # include <fnmatch.h> #endif -FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) +FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile) { if (!sfile->params) { ED_fileselect_set_params(sfile); @@ -101,7 +101,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* create new parameters if necessary */ if (!sfile->params) { - sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); + sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams"); /* set path to most recently opened .blend */ BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); sfile->params->filter_glob[0] = '\0'; @@ -111,11 +111,11 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* set the parameters from the operator, if it exists */ if (op) { - const short is_files= (RNA_struct_find_property(op->ptr, "files") != NULL); - const short is_filepath= (RNA_struct_find_property(op->ptr, "filepath") != NULL); - const short is_filename= (RNA_struct_find_property(op->ptr, "filename") != NULL); - const short is_directory= (RNA_struct_find_property(op->ptr, "directory") != NULL); - const short is_relative_path= (RNA_struct_find_property(op->ptr, "relative_path") != NULL); + const short is_files = (RNA_struct_find_property(op->ptr, "files") != NULL); + const short is_filepath = (RNA_struct_find_property(op->ptr, "filepath") != NULL); + const short is_filename = (RNA_struct_find_property(op->ptr, "filename") != NULL); + const short is_directory = (RNA_struct_find_property(op->ptr, "directory") != NULL); + const short is_relative_path = (RNA_struct_find_property(op->ptr, "relative_path") != NULL); BLI_strncpy(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); @@ -129,7 +129,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) RNA_string_get(op->ptr, "filepath", name); if (params->type == FILE_LOADLIB) { BLI_strncpy(params->dir, name, sizeof(params->dir)); - sfile->params->file[0]= '\0'; + sfile->params->file[0] = '\0'; } else { BLI_split_dirfile(name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); @@ -138,7 +138,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else { if (is_directory && RNA_struct_property_is_set(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", params->dir); - sfile->params->file[0]= '\0'; + sfile->params->file[0] = '\0'; } if (is_filename && RNA_struct_property_is_set(op->ptr, "filename")) { @@ -151,7 +151,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_path_abs(params->dir, G.main->name); } - if (is_directory==TRUE && is_filename==FALSE && is_filepath==FALSE && is_files==FALSE) { + if (is_directory == TRUE && is_filename == FALSE && is_filepath == FALSE && is_files == FALSE) { params->flag |= FILE_DIRSEL_ONLY; } else { @@ -183,7 +183,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->filter |= RNA_boolean_get(op->ptr, "filter_collada") ? COLLADAFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_glob")) { RNA_string_get(op->ptr, "filter_glob", params->filter_glob); - params->filter |= (OPERATORFILE|FOLDERFILE); + params->filter |= (OPERATORFILE | FOLDERFILE); } else { params->filter_glob[0] = '\0'; @@ -213,17 +213,17 @@ short ED_fileselect_set_params(SpaceFile *sfile) } if (RNA_struct_find_property(op->ptr, "display_type")) - params->display= RNA_enum_get(op->ptr, "display_type"); + params->display = RNA_enum_get(op->ptr, "display_type"); - if (params->display==FILE_DEFAULTDISPLAY) { + if (params->display == FILE_DEFAULTDISPLAY) { if (U.uiflag & USER_SHOW_THUMBNAILS) { - if (params->filter & (IMAGEFILE|MOVIEFILE)) - params->display= FILE_IMGDISPLAY; + if (params->filter & (IMAGEFILE | MOVIEFILE)) + params->display = FILE_IMGDISPLAY; else - params->display= FILE_SHORTDISPLAY; + params->display = FILE_SHORTDISPLAY; } else { - params->display= FILE_SHORTDISPLAY; + params->display = FILE_SHORTDISPLAY; } } @@ -252,7 +252,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* switching thumbnails needs to recalc layout [#28809] */ if (sfile->layout) { - sfile->layout->dirty= TRUE; + sfile->layout->dirty = TRUE; } return 1; @@ -265,28 +265,28 @@ void ED_fileselect_reset_params(SpaceFile *sfile) sfile->params->title[0] = '\0'; } -int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) +int ED_fileselect_layout_numfiles(FileLayout *layout, struct ARegion *ar) { int numfiles; if (layout->flag & FILE_LAYOUT_HOR) { - int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x); + int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2 * layout->tile_border_x); numfiles = (int)((float)width / (float)layout->tile_w + 0.5f); - return numfiles*layout->rows; + return numfiles * layout->rows; } else { - int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y); - numfiles = (int)((float)height/(float)layout->tile_h + 0.5f); - return numfiles*layout->columns; + int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2 * layout->tile_border_y); + numfiles = (int)((float)height / (float)layout->tile_h + 0.5f); + return numfiles * layout->columns; } } static int is_inside(int x, int y, int cols, int rows) { - return ( (x >= 0) && (x<cols) && (y>=0) && (y<rows) ); + return ( (x >= 0) && (x < cols) && (y >= 0) && (y < rows) ); } -FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* rect) +FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *rect) { int colmin, colmax, rowmin, rowmax; FileSelection sel; @@ -295,43 +295,43 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* r if (layout == NULL) return sel; - colmin = (rect->xmin)/(layout->tile_w + 2*layout->tile_border_x); - rowmin = (rect->ymin)/(layout->tile_h + 2*layout->tile_border_y); - colmax = (rect->xmax)/(layout->tile_w + 2*layout->tile_border_x); - rowmax = (rect->ymax)/(layout->tile_h + 2*layout->tile_border_y); + colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x); + rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y); + colmax = (rect->xmax) / (layout->tile_w + 2 * layout->tile_border_x); + rowmax = (rect->ymax) / (layout->tile_h + 2 * layout->tile_border_y); if (is_inside(colmin, rowmin, layout->columns, layout->rows) || is_inside(colmax, rowmax, layout->columns, layout->rows) ) { - CLAMP(colmin, 0, layout->columns-1); - CLAMP(rowmin, 0, layout->rows-1); - CLAMP(colmax, 0, layout->columns-1); - CLAMP(rowmax, 0, layout->rows-1); + CLAMP(colmin, 0, layout->columns - 1); + CLAMP(rowmin, 0, layout->rows - 1); + CLAMP(colmax, 0, layout->columns - 1); + CLAMP(rowmax, 0, layout->rows - 1); } - if ((colmin > layout->columns-1) || (rowmin > layout->rows-1)) { + if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) { sel.first = -1; } else { if (layout->flag & FILE_LAYOUT_HOR) - sel.first = layout->rows*colmin + rowmin; + sel.first = layout->rows * colmin + rowmin; else - sel.first = colmin + layout->columns*rowmin; + sel.first = colmin + layout->columns * rowmin; } - if ((colmax > layout->columns-1) || (rowmax > layout->rows-1)) { + if ((colmax > layout->columns - 1) || (rowmax > layout->rows - 1)) { sel.last = -1; } else { if (layout->flag & FILE_LAYOUT_HOR) - sel.last = layout->rows*colmax + rowmax; + sel.last = layout->rows * colmax + rowmax; else - sel.last = colmax + layout->columns*rowmax; + sel.last = colmax + layout->columns * rowmax; } return sel; } -int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) +int ED_fileselect_layout_offset(FileLayout *layout, int x, int y) { int offsetx, offsety; int active_file; @@ -339,35 +339,35 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) if (layout == NULL) return -1; - offsetx = (x)/(layout->tile_w + 2*layout->tile_border_x); - offsety = (y)/(layout->tile_h + 2*layout->tile_border_y); + offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x); + offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y); if (offsetx > layout->columns - 1) return -1; if (offsety > layout->rows - 1) return -1; if (layout->flag & FILE_LAYOUT_HOR) - active_file = layout->rows*offsetx + offsety; + active_file = layout->rows * offsetx + offsety; else - active_file = offsetx + layout->columns*offsety; + active_file = offsetx + layout->columns * offsety; return active_file; } -void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y) +void ED_fileselect_layout_tilepos(FileLayout *layout, int tile, int *x, int *y) { if (layout->flag == FILE_LAYOUT_HOR) { - *x = layout->tile_border_x + (tile/layout->rows)*(layout->tile_w+2*layout->tile_border_x); - *y = layout->tile_border_y + (tile%layout->rows)*(layout->tile_h+2*layout->tile_border_y); + *x = layout->tile_border_x + (tile / layout->rows) * (layout->tile_w + 2 * layout->tile_border_x); + *y = layout->tile_border_y + (tile % layout->rows) * (layout->tile_h + 2 * layout->tile_border_y); } else { - *x = layout->tile_border_x + ((tile)%layout->columns)*(layout->tile_w+2*layout->tile_border_x); - *y = layout->tile_border_y + ((tile)/layout->columns)*(layout->tile_h+2*layout->tile_border_y); + *x = layout->tile_border_x + ((tile) % layout->columns) * (layout->tile_w + 2 * layout->tile_border_x); + *y = layout->tile_border_y + ((tile) / layout->columns) * (layout->tile_h + 2 * layout->tile_border_y); } } /* Shorten a string to a given width w. * If front is set, shorten from the front, * otherwise shorten from the end. */ -float file_shorten_string(char* string, float w, int front) +float file_shorten_string(char *string, float w, int front) { char temp[FILE_MAX]; short shortened = 0; @@ -384,23 +384,23 @@ float file_shorten_string(char* string, float w, int front) char *s = string; BLI_strncpy(temp, "...", 4); pad = file_string_width(temp); - while ((*s) && (sw+pad>w)) { + while ((*s) && (sw + pad > w)) { s++; sw = file_string_width(s); shortened = 1; } if (shortened) { int slen = strlen(s); - BLI_strncpy(temp+3, s, slen+1); - temp[slen+4] = '\0'; - BLI_strncpy(string, temp, slen+4); + BLI_strncpy(temp + 3, s, slen + 1); + temp[slen + 4] = '\0'; + BLI_strncpy(string, temp, slen + 4); } } else { char *s = string; - while (sw>w) { + while (sw > w) { int slen = strlen(string); - string[slen-1] = '\0'; + string[slen - 1] = '\0'; sw = file_string_width(s); shortened = 1; } @@ -408,7 +408,7 @@ float file_shorten_string(char* string, float w, int front) if (shortened) { int slen = strlen(string); if (slen > 3) { - BLI_strncpy(string+slen-3, "...", 4); + BLI_strncpy(string + slen - 3, "...", 4); } } } @@ -416,9 +416,9 @@ float file_shorten_string(char* string, float w, int front) return sw; } -float file_string_width(const char* str) +float file_string_width(const char *str) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); return BLF_width(style->widget.uifont_id, str); } @@ -428,28 +428,28 @@ float file_font_pointsize(void) #if 0 float s; char tmp[2] = "X"; - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); s = BLF_height(style->widget.uifont_id, tmp); return style->widget.points; #else - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); return style->widget.points * UI_DPI_FAC; #endif } -static void column_widths(struct FileList* files, struct FileLayout* layout) +static void column_widths(struct FileList *files, struct FileLayout *layout) { int i; int numfiles = filelist_numfiles(files); - for (i=0; i<MAX_FILE_COLUMN; ++i) { + for (i = 0; i < MAX_FILE_COLUMN; ++i) { layout->column_widths[i] = 0; } - for (i=0; (i < numfiles); ++i) { - struct direntry* file = filelist_file(files, i); + for (i = 0; (i < numfiles); ++i) { + struct direntry *file = filelist_file(files, i); if (file) { float len; len = file_string_width(file->relname); @@ -475,8 +475,8 @@ static void column_widths(struct FileList* files, struct FileLayout* layout) void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) { FileSelectParams *params = ED_fileselect_get_params(sfile); - FileLayout *layout= NULL; - View2D *v2d= &ar->v2d; + FileLayout *layout = NULL; + View2D *v2d = &ar->v2d; int maxlen = 0; int numfiles; int textheight; @@ -501,17 +501,17 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_border_y = 6; layout->prv_border_x = 6; layout->prv_border_y = 6; - layout->tile_w = layout->prv_w + 2*layout->prv_border_x; - layout->tile_h = layout->prv_h + 2*layout->prv_border_y + textheight; - layout->width= (int)(v2d->cur.xmax - v2d->cur.xmin - 2*layout->tile_border_x); - layout->columns= layout->width / (layout->tile_w + 2*layout->tile_border_x); + layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; + layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight; + layout->width = (int)(v2d->cur.xmax - v2d->cur.xmin - 2 * layout->tile_border_x); + layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x); if (layout->columns > 0) - layout->rows= numfiles/layout->columns + 1; // XXX dirty, modulo is zero + layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero else { layout->columns = 1; - layout->rows= numfiles + 1; // XXX dirty, modulo is zero + layout->rows = numfiles + 1; // XXX dirty, modulo is zero } - layout->height= sfile->layout->rows*(layout->tile_h+2*layout->tile_border_y) + layout->tile_border_y*2; + layout->height = sfile->layout->rows * (layout->tile_h + 2 * layout->tile_border_y) + layout->tile_border_y * 2; layout->flag = FILE_LAYOUT_VER; } else { @@ -521,45 +521,45 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_border_y = 2; layout->prv_border_x = 0; layout->prv_border_y = 0; - layout->tile_h = textheight*3/2; - layout->height= (int)(v2d->cur.ymax - v2d->cur.ymin - 2*layout->tile_border_y); - layout->rows = layout->height / (layout->tile_h + 2*layout->tile_border_y); + layout->tile_h = textheight * 3 / 2; + layout->height = (int)(v2d->cur.ymax - v2d->cur.ymin - 2 * layout->tile_border_y); + layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y); column_widths(sfile->files, layout); if (params->display == FILE_SHORTDISPLAY) { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_NAME] + 12 + + (int)layout->column_widths[COLUMN_SIZE] + 12; } else { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + + (int)layout->column_widths[COLUMN_NAME] + 12 + #ifndef WIN32 - (int)layout->column_widths[COLUMN_MODE1] + 12 + - (int)layout->column_widths[COLUMN_MODE2] + 12 + - (int)layout->column_widths[COLUMN_MODE3] + 12 + - (int)layout->column_widths[COLUMN_OWNER] + 12 + + (int)layout->column_widths[COLUMN_MODE1] + 12 + + (int)layout->column_widths[COLUMN_MODE2] + 12 + + (int)layout->column_widths[COLUMN_MODE3] + 12 + + (int)layout->column_widths[COLUMN_OWNER] + 12 + #endif - (int)layout->column_widths[COLUMN_DATE] + 12 + - (int)layout->column_widths[COLUMN_TIME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_DATE] + 12 + + (int)layout->column_widths[COLUMN_TIME] + 12 + + (int)layout->column_widths[COLUMN_SIZE] + 12; } layout->tile_w = maxlen; if (layout->rows > 0) - layout->columns = numfiles/layout->rows + 1; // XXX dirty, modulo is zero + layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero else { layout->rows = 1; layout->columns = numfiles + 1; // XXX dirty, modulo is zero } - layout->width = sfile->layout->columns * (layout->tile_w + 2*layout->tile_border_x) + layout->tile_border_x*2; + layout->width = sfile->layout->columns * (layout->tile_w + 2 * layout->tile_border_x) + layout->tile_border_x * 2; layout->flag = FILE_LAYOUT_HOR; } - layout->dirty= FALSE; + layout->dirty = FALSE; } -FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) +FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) { if (!sfile->layout) { ED_fileselect_init_layout(sfile, ar); @@ -569,13 +569,13 @@ FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar void file_change_dir(bContext *C, int checkdir) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { ED_fileselect_clear(C, sfile); - if (checkdir && BLI_is_dir(sfile->params->dir)==0) { + if (checkdir && BLI_is_dir(sfile->params->dir) == 0) { BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir)); /* could return but just refresh the current dir */ } @@ -589,28 +589,34 @@ void file_change_dir(bContext *C, int checkdir) } } -int file_select_match(struct SpaceFile *sfile, const char *pattern) +int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; - if (strchr(pattern, '*') || strchr(pattern, '?') || strchr(pattern, '[')) { - int i; - struct direntry *file; - int n = filelist_numfiles(sfile->files); - - for (i = 0; i < n; i++) { - file = filelist_file(sfile->files, i); - if (fnmatch(pattern, file->relname, 0) == 0) { - file->selflag |= SELECTED_FILE; - match = 1; + + int i; + struct direntry *file; + int n = filelist_numfiles(sfile->files); + + /* select any file that matches the pattern, this includes exact match + * if the user selects a single file by entering the filename + */ + for (i = 0; i < n; i++) { + file = filelist_file(sfile->files, i); + if (fnmatch(pattern, file->relname, 0) == 0) { + file->selflag |= SELECTED_FILE; + if (!match) { + BLI_strncpy(matched_file, file->relname, FILE_MAX); } + match = 1; } } + return match; } void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); /* search if str matches the beginning of name */ if (str[0] && sfile->files) { @@ -624,10 +630,10 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) dir = opendir(dirname); if (dir) { - AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { - if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) { + if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { /* pass */ } else { @@ -658,16 +664,16 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) void autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); /* search if str matches the beginning of name */ if (str[0] && sfile->files) { - AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); int nentries = filelist_numfiles(sfile->files); int i; - for (i= 0; i<nentries; ++i) { - struct direntry* file = filelist_file(sfile->files, i); + for (i = 0; i < nentries; ++i) { + struct direntry *file = filelist_file(sfile->files, i); if (file && S_ISREG(file->type)) { autocomplete_do_name(autocpl, file->relname); } @@ -686,7 +692,7 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) } sfile->params->active_file = -1; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) @@ -703,7 +709,7 @@ void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) if (sfile->files) { ED_fileselect_clear(C, sfile); MEM_freeN(sfile->files); - sfile->files= NULL; + sfile->files = NULL; } } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 6d2381e64d5..0366043aaa0 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -449,9 +449,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, + &cfURL, NULL); if (err != noErr) continue; diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index e5b3d54ac9f..d7576d71933 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -45,42 +45,42 @@ typedef enum FSMenuCategory { struct FSMenu; -struct FSMenu* fsmenu_get (void); +struct FSMenu *fsmenu_get(void); - /** Returns the number of entries in the Fileselect Menu */ -int fsmenu_get_nentries (struct FSMenu* fsmenu, FSMenuCategory category); +/** Returns the number of entries in the Fileselect Menu */ +int fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category); - /** Returns the fsmenu entry at \a index (or NULL if a bad index) - * or a separator. - */ -char* fsmenu_get_entry (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Returns the fsmenu entry at \a index (or NULL if a bad index) + * or a separator. + */ +char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** Inserts a new fsmenu entry with the given \a path. - * Duplicate entries are not added. - * \param sorted Should entry be inserted in sorted order? - */ -void fsmenu_insert_entry (struct FSMenu* fsmenu, FSMenuCategory category, const char *path, int sorted, short save); +/** Inserts a new fsmenu entry with the given \a path. + * Duplicate entries are not added. + * \param sorted Should entry be inserted in sorted order? + */ +void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save); - /** Return whether the entry was created by the user and can be saved and deleted */ -short fsmenu_can_save (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Return whether the entry was created by the user and can be saved and deleted */ +short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** Removes the fsmenu entry at the given \a index. */ -void fsmenu_remove_entry (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Removes the fsmenu entry at the given \a index. */ +void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** saves the 'bookmarks' to the specified file */ -void fsmenu_write_file (struct FSMenu* fsmenu, const char *filename); +/** saves the 'bookmarks' to the specified file */ +void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename); - /** reads the 'bookmarks' from the specified file */ -void fsmenu_read_bookmarks (struct FSMenu* fsmenu, const char *filename); +/** reads the 'bookmarks' from the specified file */ +void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename); - /** adds system specific directories */ -void fsmenu_read_system (struct FSMenu* fsmenu, int read_bookmarks); +/** adds system specific directories */ +void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks); - /** Free's all the memory associated with the fsmenu */ -void fsmenu_free (struct FSMenu* fsmenu); +/** Free's all the memory associated with the fsmenu */ +void fsmenu_free(struct FSMenu *fsmenu); - /** Refresh system directory menu */ -void fsmenu_refresh_system_category (struct FSMenu* fsmenu); +/** Refresh system directory menu */ +void fsmenu_refresh_system_category(struct FSMenu *fsmenu); #endif diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index a90daa7e1e9..79979603f54 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -63,7 +63,7 @@ #include "UI_view2d.h" -#include "file_intern.h" // own include +#include "file_intern.h" // own include #include "fsmenu.h" #include "filelist.h" @@ -74,36 +74,36 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) ARegion *ar; SpaceFile *sfile; - sfile= MEM_callocN(sizeof(SpaceFile), "initfile"); - sfile->spacetype= SPACE_FILE; + sfile = MEM_callocN(sizeof(SpaceFile), "initfile"); + sfile->spacetype = SPACE_FILE; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for file"); + ar = MEM_callocN(sizeof(ARegion), "header for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_TOP; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel area for file"); + ar = MEM_callocN(sizeof(ARegion), "channel area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; /* ui list region */ - ar= MEM_callocN(sizeof(ARegion), "ui area for file"); + ar = MEM_callocN(sizeof(ARegion), "ui area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_TOP; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for file"); + ar = MEM_callocN(sizeof(ARegion), "main area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; return (SpaceLink *)sfile; } @@ -111,31 +111,31 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void file_free(SpaceLink *sl) { - SpaceFile *sfile= (SpaceFile *) sl; + SpaceFile *sfile = (SpaceFile *) sl; if (sfile->files) { // XXXXX would need to do thumbnails_stop here, but no context available filelist_freelib(sfile->files); filelist_free(sfile->files); MEM_freeN(sfile->files); - sfile->files= NULL; + sfile->files = NULL; } if (sfile->folders_prev) { folderlist_free(sfile->folders_prev); MEM_freeN(sfile->folders_prev); - sfile->folders_prev= NULL; + sfile->folders_prev = NULL; } if (sfile->folders_next) { folderlist_free(sfile->folders_next); MEM_freeN(sfile->folders_next); - sfile->folders_next= NULL; + sfile->folders_next = NULL; } if (sfile->params) { MEM_freeN(sfile->params); - sfile->params= NULL; + sfile->params = NULL; } if (sfile->layout) { @@ -148,27 +148,27 @@ static void file_free(SpaceLink *sl) /* spacetype; init callback, area size changes, screen set, etc */ static void file_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceFile *sfile= (SpaceFile*)sa->spacedata.first; + SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; //printf("file_init\n"); /* refresh system directory list */ fsmenu_refresh_system_category(fsmenu_get()); - if (sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty = TRUE; } static SpaceLink *file_duplicate(SpaceLink *sl) { - SpaceFile *sfileo= (SpaceFile*)sl; - SpaceFile *sfilen= MEM_dupallocN(sl); + SpaceFile *sfileo = (SpaceFile *)sl; + SpaceFile *sfilen = MEM_dupallocN(sl); /* clear or remove stuff from old */ sfilen->op = NULL; /* file window doesn't own operators */ if (sfileo->params) { sfilen->files = filelist_new(sfileo->params->type); - sfilen->params= MEM_dupallocN(sfileo->params); + sfilen->params = MEM_dupallocN(sfileo->params); filelist_setdir(sfilen->files, sfilen->params->dir); } @@ -179,14 +179,14 @@ static SpaceLink *file_duplicate(SpaceLink *sl) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); if (sfileo->layout) { - sfilen->layout= MEM_dupallocN(sfileo->layout); + sfilen->layout = MEM_dupallocN(sfileo->layout); } return (SpaceLink *)sfilen; } static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); if (!sfile->folders_prev) @@ -203,7 +203,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (filelist_empty(sfile->files)) { thumbnails_stop(sfile->files, C); filelist_readdir(sfile->files); - if (params->sort!=FILE_SORT_NONE) { + if (params->sort != FILE_SORT_NONE) { filelist_sort(sfile->files, params->sort); } BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX); @@ -212,7 +212,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) } } else { - if (params->sort!=FILE_SORT_NONE) { + if (params->sort != FILE_SORT_NONE) { thumbnails_stop(sfile->files, C); filelist_sort(sfile->files, params->sort); if (params->display == FILE_IMGDISPLAY) { @@ -237,7 +237,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (params->renamefile[0] != '\0') { int idx = filelist_find(sfile->files, params->renamefile); if (idx >= 0) { - struct direntry *file= filelist_file(sfile->files, idx); + struct direntry *file = filelist_file(sfile->files, idx); if (file) { file->selflag |= EDITING_FILE; } @@ -245,7 +245,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit)); params->renamefile[0] = '\0'; } - if (sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty = TRUE; } @@ -307,11 +307,11 @@ static void file_main_area_listener(ARegion *ar, wmNotifier *wmn) static void file_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); - FileLayout *layout=NULL; + FileLayout *layout = NULL; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; float col[3]; @@ -355,7 +355,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* on first read, find active file */ if (params->active_file == -1) { - wmEvent *event= CTX_wm_window(C)->eventstate; + wmEvent *event = CTX_wm_window(C)->eventstate; file_hilight_set(sfile, ar, event->x, event->y); } @@ -365,7 +365,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); @@ -553,58 +553,58 @@ static void file_ui_area_listener(ARegion *ar, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_file(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype file"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file"); ARegionType *art; - st->spaceid= SPACE_FILE; + st->spaceid = SPACE_FILE; strncpy(st->name, "File", BKE_ST_MAXNAME); - st->new= file_new; - st->free= file_free; - st->init= file_init; - st->duplicate= file_duplicate; - st->refresh= file_refresh; - st->listener= file_listener; - st->operatortypes= file_operatortypes; - st->keymap= file_keymap; + st->new = file_new; + st->free = file_free; + st->init = file_init; + st->duplicate = file_duplicate; + st->refresh = file_refresh; + st->listener = file_listener; + st->operatortypes = file_operatortypes; + st->keymap = file_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_WINDOW; - art->init= file_main_area_init; - art->draw= file_main_area_draw; - art->listener= file_main_area_listener; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->init = file_main_area_init; + art->draw = file_main_area_draw; + art->listener = file_main_area_listener; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; - art->init= file_header_area_init; - art->draw= file_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; + art->init = file_header_area_init; + art->draw = file_header_area_draw; // art->listener= file_header_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: ui */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_UI; - art->prefsizey= 60; - art->keymapflag= ED_KEYMAP_UI; - art->listener= file_ui_area_listener; - art->init= file_ui_area_init; - art->draw= file_ui_area_draw; + art->prefsizey = 60; + art->keymapflag = ED_KEYMAP_UI; + art->listener = file_ui_area_listener; + art->init = file_ui_area_init; + art->draw = file_ui_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: channels (directories) */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 240; - art->keymapflag= ED_KEYMAP_UI; - art->listener= file_channel_area_listener; - art->init= file_channel_area_init; - art->draw= file_channel_area_draw; + art->prefsizex = 240; + art->keymapflag = ED_KEYMAP_UI; + art->listener = file_channel_area_listener; + art->init = file_channel_area_init; + art->draw = file_channel_area_draw; BLI_addhead(&st->regiontypes, art); file_panels_register(art); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index ddcd46ba817..efe62eaf495 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -142,19 +142,19 @@ static void graph_panel_view(const bContext *C, Panel *pa) RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - row = uiLayoutSplit(sub, 0.7, 1); + row = uiLayoutSplit(sub, 0.7f, TRUE); uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); - row = uiLayoutSplit(sub, 0.7, 1); + row = uiLayoutSplit(sub, 0.7f, TRUE); uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); } @@ -183,24 +183,24 @@ static void graph_panel_properties(const bContext *C, Panel *pa) /* user-friendly 'name' for F-Curve */ /* TODO: only show the path if this is invalid? */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); icon = getname_anim_fcurve(name, ale->id, fcu); uiItemL(col, name, icon); /* RNA-Path Editing - only really should be enabled when things aren't working */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0); uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); /* color settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Display Color:"), ICON_NONE); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM)); uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); @@ -307,7 +307,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) } /* interpolation */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); /* numerical coordinate editing @@ -315,7 +315,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) * and unit conversion magic that cannot be achieved using a purely RNA-approach */ // XXX: - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* keyframe itself */ { uiItemL(col, IFACE_("Key:"), ICON_NONE); @@ -469,7 +469,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* Target ID */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); /* Target Property */ @@ -480,7 +480,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* get pointer for resolving the property selected */ RNA_id_pointer_create(dtar->id, &root_ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* rna path */ uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path")); } @@ -501,7 +501,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); if (dtar->id && ob1->pose) { @@ -511,7 +511,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); if (dtar2->id && ob2->pose) { @@ -537,7 +537,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); if (dtar->id && ob1->pose) { @@ -549,7 +549,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); if (dtar2->id && ob2->pose) { @@ -574,7 +574,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* properties */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); if (dtar->id && ob->pose) { @@ -584,7 +584,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - sub = uiLayoutColumn(layout, 1); + sub = uiLayoutColumn(layout, TRUE); uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); } @@ -612,7 +612,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); @@ -625,7 +625,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); block = uiLayoutGetBlock(col); uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); @@ -644,13 +644,13 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); } - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); /* debug setting */ uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); /* value of driver */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - uiLayout *row = uiLayoutRow(col, 1); + uiLayout *row = uiLayoutRow(col, TRUE); char valBuf[32]; uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); @@ -660,7 +660,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) } /* add driver variables */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); @@ -672,14 +672,14 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiLayout *box, *row; /* sub-layout column for this variable's settings */ - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); /* header panel */ box = uiLayoutBox(col); /* first row context info for driver */ RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); /* variable name */ uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); @@ -692,7 +692,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiBlockSetEmboss(block, UI_EMBOSS); /* variable type */ - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ @@ -718,7 +718,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) char valBuf[32]; box = uiLayoutBox(col); - row = uiLayoutRow(box, 1); + row = uiLayoutRow(box, TRUE); uiItemL(row, IFACE_("Value:"), ICON_NONE); BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); @@ -760,7 +760,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a 'add modifier' operator @@ -768,14 +768,14 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) 10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); /* copy/paste (as sub-row)*/ - row = uiLayoutRow(row, 1); + row = uiLayoutRow(row, TRUE); uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } /* draw each modifier */ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 332a2ecada4..aa596b8b635 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -512,7 +512,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image int wmenu1, wmenu2, wmenu3, layer; char *strp; - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); /* layer menu is 1/3 larger than pass */ wmenu1 = (2 * w) / 5; @@ -552,7 +552,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, uiBut *but; const float dpi_fac = UI_DPI_FAC; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (rr == NULL || iuser == NULL) return; @@ -693,13 +693,13 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - row = uiLayoutRow(row, 0); + row = uiLayoutRow(row, FALSE); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); @@ -733,26 +733,26 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* XXX Why only display fields_per_frame only for video image types? * And why allow fields for non-video image types at all??? */ if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - uiLayout *subsplit = uiLayoutSplit(col, 0, 0); - uiLayout *subcol = uiLayoutColumn(subsplit, 0); + uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE); + uiLayout *subcol = uiLayoutColumn(subsplit, FALSE); uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE); - subcol = uiLayoutColumn(subsplit, 0); + subcol = uiLayoutColumn(subsplit, FALSE); uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE); } else uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE); } @@ -761,24 +761,24 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length"); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); @@ -804,12 +804,12 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiLayout *col, *row, *split, *sub; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); - split = uiLayoutSplit(col, 0.5f, 0); + split = uiLayoutSplit(col, 0.5f, FALSE); uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE); - sub = uiLayoutRow(split, 0); + sub = uiLayoutRow(split, FALSE); uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); /* only display depth setting if multiple depths can be used */ @@ -821,7 +821,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) R_IMF_CHAN_DEPTH_24, R_IMF_CHAN_DEPTH_32)) == 0) { - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -837,7 +837,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); } - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); if (BKE_imtype_supports_zbuf(imf->imtype)) { uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); } @@ -847,7 +847,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) } if (imf->imtype == R_IMF_IMTYPE_JP2) { - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7e67e737cc2..3dc1fbd738f 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1926,6 +1926,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) if (ibuf == NULL) { ED_space_image_release_buffer(sima, lock); + info->draw = 0; return; } @@ -2018,8 +2019,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) } #endif } - else + else { info->draw = 0; + } ED_space_image_release_buffer(sima, lock); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 32e6f588e27..59e47363a22 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -550,7 +550,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) /* fast switch to render slots */ for (i = 0; i < MAX2(IMA_MAX_RENDER_SLOT, 9); i++) { - kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY+i, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slot"); RNA_int_set(kmi->ptr, "value", i); } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 0eec61f599e..08842698214 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3197,8 +3197,8 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiLayout *box, *row, *sub; bSensor *sens= (bSensor *)ptr->data; - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3210,13 +3210,13 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiItemL(row, sens->name, ICON_NONE); } - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3228,19 +3228,19 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) { uiLayout *box, *split, *sub, *row; - box= uiLayoutBox(layout); - split = uiLayoutSplit(box, 0.45, 0); + box = uiLayoutBox(layout); + split = uiLayoutSplit(box, 0.45f, FALSE); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP); uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN); - sub=uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") || RNA_boolean_get(ptr, "use_pulse_false_level"))); uiItemR(sub, ptr, "frequency", 0, "Freq", ICON_NONE); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3282,7 +3282,7 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, as->posechannel, &pchan_ptr)) uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE); } - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "test_type", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "test_type") != SENS_ARM_STATE_CHANGED) uiItemR(row, ptr, "value", 0, NULL, ICON_NONE); @@ -3295,8 +3295,8 @@ static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C RNA_main_pointer_create(CTX_data_main(C), &main_ptr); - split = uiLayoutSplit(layout, 0.3, 0); - row = uiLayoutRow(split, 1); + split = uiLayoutSplit(layout, 0.3f, FALSE); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3314,7 +3314,7 @@ static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "delay", 0, NULL, ICON_NONE); uiItemR(row, ptr, "duration", 0, NULL, ICON_NONE); @@ -3332,17 +3332,17 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) case SENS_JOY_BUTTON: uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "button_number", 0, NULL, ICON_NONE); break; case SENS_JOY_AXIS: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "axis_number", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "axis_direction", 0, NULL, ICON_NONE); break; @@ -3350,12 +3350,12 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "hat_number", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "hat_direction", 0, NULL, ICON_NONE); break; case SENS_JOY_AXIS_SINGLE: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "single_axis_number", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE); break; @@ -3368,21 +3368,21 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; uiLayout *row, *col; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, "Key:", ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemL(row, "First Modifier:", ICON_NONE); uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemL(row, "Second Modifier:", ICON_NONE); uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE); @@ -3407,7 +3407,7 @@ static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(row, ptr, "reset_distance", 0, NULL, ICON_NONE); } @@ -3425,7 +3425,7 @@ static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "evaluation_type")) { case SENS_PROP_INTERVAL: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "value_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "value_max", 0, NULL, ICON_NONE); break; @@ -3447,7 +3447,7 @@ static void draw_sensor_radar(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "axis", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "angle", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); } @@ -3463,7 +3463,7 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) PointerRNA main_ptr; RNA_main_pointer_create(CTX_data_main(C), &main_ptr); - split= uiLayoutSplit(layout, 0.3, 0); + split = uiLayoutSplit(layout, 0.3f, FALSE); uiItemR(split, ptr, "ray_type", 0, "", ICON_NONE); switch (RNA_enum_get(ptr, "ray_type")) { case SENS_RAY_PROPERTY: @@ -3474,9 +3474,9 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) break; } - split= uiLayoutSplit(layout, 0.3, 0); + split = uiLayoutSplit(layout, 0.3, FALSE); uiItemR(split, ptr, "axis", 0, "", ICON_NONE); - row= uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "range", 0, NULL, ICON_NONE); uiItemR(row, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } @@ -3555,8 +3555,8 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i char state[3]; BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states")); - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3574,7 +3574,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3590,13 +3590,13 @@ static void draw_controller_python(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *sub; - split = uiLayoutSplit(layout, 0.3, 1); + split = uiLayoutSplit(layout, 0.3, TRUE); uiItemR(split, ptr, "mode", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "mode") == CONT_PY_SCRIPT) { uiItemR(split, ptr, "text", 0, "", ICON_NONE); } else { - sub = uiLayoutSplit(split, 0.8, 0); + sub = uiLayoutSplit(split, 0.8f, FALSE); uiItemR(sub, ptr, "module", 0, "", ICON_NONE); uiItemR(sub, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } @@ -3646,8 +3646,8 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiLayout *box, *row, *sub; bActuator *act= (bActuator *)ptr->data; - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3659,13 +3659,13 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiItemL(row, act->name, ICON_NONE); } - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3680,22 +3680,22 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE); - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemR(sub, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(sub, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutColumn(sub, 0); + row = uiLayoutColumn(sub, FALSE); uiLayoutSetActive(row, (RNA_boolean_get(ptr, "use_additive") || RNA_boolean_get(ptr, "use_force"))); uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if ((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); @@ -3706,11 +3706,11 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "apply_to_children", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE); uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE); uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE); @@ -3798,11 +3798,11 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) uiLayout *row; uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "height", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "max", 0, NULL, ICON_NONE); @@ -3821,7 +3821,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext case ACT_CONST_TYPE_LOC: uiItemR(layout, ptr, "limit", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "limit_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "limit_max", 0, NULL, ICON_NONE); @@ -3829,36 +3829,36 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext break; case ACT_CONST_TYPE_DIST: - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8, FALSE); uiItemR(split, ptr, "direction", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 1); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, TRUE); uiItemL(col, "Range:", ICON_NONE); uiItemR(col, ptr, "range", 0, "", ICON_NONE); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_force_distance") == TRUE); uiItemR(sub, ptr, "distance", 0, "", ICON_NONE); uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15f, FALSE); uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_material_detect")) uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA); else uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; @@ -3866,43 +3866,43 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext case ACT_CONST_TYPE_ORI: uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 1); + row=uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 0); + row=uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "rotation_max", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 1); + row=uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "angle_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "angle_max", 0, NULL, ICON_NONE); break; case ACT_CONST_TYPE_FH: - split=uiLayoutSplit(layout, 0.75, 0); - row= uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.75, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "fh_height", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_fh_paralel_axis", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "direction_axis", 0, NULL, ICON_NONE); - split = uiLayoutSplit(row, 0.9, 0); + split = uiLayoutSplit(row, 0.9f, FALSE); uiItemR(split, ptr, "fh_force", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_fh_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_material_detect")) uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA); else uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; @@ -3917,17 +3917,17 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_EDOB_ADD_OBJECT: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "object", 0, NULL, ICON_NONE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -3938,16 +3938,16 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); break; } - split = uiLayoutSplit(layout, 0.6, 0); + split = uiLayoutSplit(layout, 0.6, FALSE); uiItemR(split, ptr, "mesh", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "use_replace_display_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_replace_physics_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; case ACT_EDOB_TRACK_TO: - split = uiLayoutSplit(layout, 0.5, 0); + split = uiLayoutSplit(layout, 0.5, FALSE); uiItemR(split, ptr, "track_object", 0, NULL, ICON_NONE); - sub = uiLayoutSplit(split, 0.7, 0); + sub = uiLayoutSplit(split, 0.7f, FALSE); uiItemR(sub, ptr, "time", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -3974,8 +3974,8 @@ static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "glsl_shader", 0, NULL, ICON_NONE); break; case ACT_2DFILTER_MOTIONBLUR: - split=uiLayoutSplit(layout, 0.75, 1); - row= uiLayoutRow(split, 0); + split=uiLayoutSplit(layout, 0.75f, TRUE); + row = uiLayoutRow(split, FALSE); uiLayoutSetActive(row, RNA_boolean_get(ptr, "use_motion_blur") == TRUE); uiItemR(row, ptr, "motion_blur_factor", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_motion_blur", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4007,7 +4007,7 @@ static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr, bContext *C uiItemPointerR(layout, ptr, "to_property", &main_ptr, "objects", NULL, ICON_OBJECT_DATA); uiItemR(layout, ptr, "subject", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "body_type", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) @@ -4031,37 +4031,37 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_OBJECT_NORMAL: - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "offset_location", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) { uiItemL(layout, "Dynamic Object Settings:", ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "force", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "torque", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_torque", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_add_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4071,29 +4071,29 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) case ACT_OBJECT_SERVO: uiItemR(layout, ptr, "reference_object", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_x", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_x") == TRUE); uiItemR(sub, ptr, "force_max_x", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_x", 0, NULL, ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_y", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_y") == TRUE); uiItemR(sub, ptr, "force_max_y", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_y", 0, NULL, ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_z", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_z") == TRUE); uiItemR(sub, ptr, "force_max_z", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_z", 0, NULL, ICON_NONE); @@ -4102,7 +4102,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) //Layout designers willing to help on that, please compare with 2.49 ui // (since the old code is going to be deleted ... soon) - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "integral_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "derivate_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -4119,9 +4119,9 @@ static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr) if (RNA_enum_get(ptr, "mode") == ACT_PARENT_SET) { uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "use_compound", 0, NULL, ICON_NONE); - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_compound") == TRUE); uiItemR(sub, ptr, "use_ghost", 0, NULL, ICON_NONE); } @@ -4152,15 +4152,15 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE); break; case ACT_PROP_COPY: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "object", 0, NULL, ICON_NONE); if (ob_from) { RNA_pointer_create((ID *)ob_from, &RNA_GameObjectSettings, ob_from, &obj_settings_ptr); uiItemPointerR(row, ptr, "object_property", &obj_settings_ptr, "properties", NULL, ICON_NONE); } else { - sub= uiLayoutRow(row, 0); - uiLayoutSetActive(sub, 0); + sub = uiLayoutRow(row, FALSE); + uiLayoutSetActive(sub, FALSE); uiItemR(sub, ptr, "object_property", 0, NULL, ICON_NONE); } break; @@ -4176,15 +4176,15 @@ static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "seed", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distribution", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); switch (RNA_enum_get(ptr, "distribution")) { case ACT_RANDOM_BOOL_CONST: @@ -4261,12 +4261,12 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "mode", 0, "", ICON_NONE); uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if ((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); @@ -4275,11 +4275,11 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE); } - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE); uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR @@ -4298,28 +4298,28 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) } uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "volume", 0, NULL, ICON_NONE); uiItemR(row, ptr, "pitch", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_sound_3d", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_sound_3d") == TRUE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gain_3d_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "gain_3d_max", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "distance_3d_reference", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distance_3d_max", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "rolloff_factor_3d", 0, NULL, ICON_NONE); uiItemR(row, ptr, "cone_outer_gain_3d", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "cone_outer_angle_3d", 0, NULL, ICON_NONE); uiItemR(row, ptr, "cone_inner_angle_3d", 0, NULL, ICON_NONE); } @@ -4331,7 +4331,7 @@ static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - split = uiLayoutSplit(layout, 0.35, 0); + split = uiLayoutSplit(layout, 0.35, FALSE); uiItemR(split, ptr, "operation", 0, NULL, ICON_NONE); uiTemplateLayers(split, ptr, "states", &settings_ptr, "used_states", 0); @@ -4340,7 +4340,7 @@ static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "use_visible", 0, NULL, ICON_NONE); uiItemR(row, ptr, "use_occlusion", 0, NULL, ICON_NONE); @@ -4356,32 +4356,32 @@ static void draw_actuator_steering(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "target", 0, NULL, 0); uiItemR(layout, ptr, "navmesh", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "distance", 0, NULL, 0); uiItemR(row, ptr, "velocity", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "acceleration", 0, NULL, 0); uiItemR(row, ptr, "turn_speed", 0, NULL, 0); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "facing", 0, NULL, 0); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "facing_axis", 0, NULL, 0); if (!RNA_boolean_get(ptr, "facing")) { - uiLayoutSetActive(col, 0); + uiLayoutSetActive(col, FALSE); } - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "normal_up", 0, NULL, 0); if (!RNA_pointer_get(ptr, "navmesh").data) { - uiLayoutSetActive(col, 0); + uiLayoutSetActive(col, FALSE); } - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "self_terminated", 0, NULL, 0); if (RNA_enum_get(ptr, "mode")==ACT_STEERING_PATHFOLLOWING) { uiItemR(row, ptr, "update_period", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); } uiItemR(row, ptr, "show_visualization", 0, NULL, 0); } @@ -4522,7 +4522,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 420; yco= 170; width= 300; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4545,32 +4545,32 @@ static void logic_buttons_new(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - split= uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE); if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { - box= uiLayoutBox(layout); - split= uiLayoutSplit(box, 0.2, 0); + box = uiLayoutBox(layout); + split = uiLayoutSplit(box, 0.2f, FALSE); - col= uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemL(col, "Visible", ICON_NONE); uiItemL(col, "Initial", ICON_NONE); - subsplit= uiLayoutSplit(split, 0.85, 0); - col= uiLayoutColumn(subsplit, 0); - row= uiLayoutRow(col, 0); + subsplit = uiLayoutSplit(split, 0.85f, FALSE); + col = uiLayoutColumn(subsplit, FALSE); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == FALSE); uiTemplateLayers(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0); - row= uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiTemplateLayers(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0); - col= uiLayoutColumn(subsplit, 0); + col = uiLayoutColumn(subsplit, FALSE); uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(col, &settings_ptr, "show_debug_state", 0, "", ICON_NONE); } @@ -4589,18 +4589,18 @@ static void logic_buttons_new(bContext *C, ARegion *ar) continue; /* use two nested splits to align inlinks/links properly */ - split = uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); /* put inlink button to the left */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, ""); - //col = uiLayoutColumn(split, 1); + //col = uiLayoutColumn(split, TRUE); /* nested split for middle and right columns */ - subsplit = uiLayoutSplit(split, 0.95, 0); + subsplit = uiLayoutSplit(split, 0.95f, FALSE); - col = uiLayoutColumn(subsplit, 1); + col = uiLayoutColumn(subsplit, TRUE); uiLayoutSetContextPointer(col, "controller", &ptr); /* should make UI template for controller header.. function will do for now */ @@ -4612,7 +4612,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* put link button to the right */ - col = uiLayoutColumn(subsplit, 0); + col = uiLayoutColumn(subsplit, FALSE); uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); @@ -4625,7 +4625,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 10; yco= 170; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4643,7 +4643,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* only draw the sensor common header if "use_visible" */ if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE); @@ -4667,8 +4667,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* make as visible, for move operator */ sens->flag |= SENS_VISIBLE; - split = uiLayoutSplit(layout, 0.95, 0); - col = uiLayoutColumn(split, 1); + split = uiLayoutSplit(layout, 0.95f, FALSE); + col = uiLayoutColumn(split, TRUE); uiLayoutSetContextPointer(col, "sensor", &ptr); /* should make UI template for sensor header.. function will do for now */ @@ -4678,7 +4678,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) draw_brick_sensor(col, &ptr, C); /* put link button to the right */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* use old-school uiButtons for links for now */ but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); @@ -4691,7 +4691,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 800; yco= 170; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4709,7 +4709,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* only draw the actuator common header if "use_visible" */ if ( (ob->scavisflag & OB_VIS_ACT) == 0) continue; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE); @@ -4734,13 +4734,13 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* make as visible, for move operator */ act->flag |= ACT_VISIBLE; - split = uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); /* put inlink button to the left */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, ""); - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiLayoutSetContextPointer(col, "actuator", &ptr); /* should make UI template for actuator header.. function will do for now */ diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index be60e47ac8f..9b0e342505b 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -253,19 +253,19 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators /* extrapolation */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); /* blending */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); /* influence */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); } @@ -285,7 +285,7 @@ static void nla_panel_track(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Info - Active NLA-Context:Track ---------------------- */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); } @@ -306,12 +306,12 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* strip type */ - row = uiLayoutColumn(layout, 1); + row = uiLayoutColumn(layout, TRUE); uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); /* strip extents */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiItemL(column, "Strip Extents:", ICON_NONE); uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); @@ -325,27 +325,27 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* only show if allowed to... */ if (showEvalProps) { /* extrapolation */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); /* blending */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence") == FALSE); uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - sub = uiLayoutColumn(column, 1); + sub = uiLayoutColumn(column, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == FALSE); uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); /* settings */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); uiItemL(column, "Playback Settings:", ICON_NONE); uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); @@ -371,19 +371,19 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* action pointer */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiItemL(column, "Action Extents:", ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); /* action usage */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == FALSE); uiItemL(column, "Playback Settings:", ICON_NONE); uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); @@ -405,19 +405,19 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); - sub = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, TRUE); + sub = uiLayoutRow(col, FALSE); uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); - sub = uiLayoutRow(col, 0); + sub = uiLayoutRow(col, FALSE); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time")); uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } @@ -441,7 +441,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a temporary 'add modifier' operator @@ -450,14 +450,14 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) TIP_("Adds a new F-Modifier for the active NLA Strip")); /* copy/paste (as sub-row)*/ - row = uiLayoutRow(row, 1); + row = uiLayoutRow(row, TRUE); uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } /* draw each modifier */ for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 8aa56823baf..22017a2d8b9 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -140,7 +140,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), 0); + layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -291,7 +291,7 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr prop = RNA_struct_find_property(ptr, "outputs"); RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0); uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -302,7 +302,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA bNodeTree *ntree = (bNodeTree *)ptr->id.data; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); if (ntree->type == NTREE_COMPOSIT) uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); @@ -325,7 +325,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE); uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); } @@ -340,25 +340,30 @@ static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0); } -static float *_sample_col = NULL; // bad bad, 2.5 will do better? -#if 0 -static void node_curvemap_sample(float *col) +static float _sample_col[4]; // bad bad, 2.5 will do better? +#define SAMPLE_FLT_ISNONE FLT_MAX +void ED_node_sample_set(const float col[4]) { - _sample_col = col; + if (col) { + copy_v4_v4(_sample_col, col); + } + else { + copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE); + } } -#endif static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { bNode *node = ptr->data; CurveMapping *cumap = node->storage; - if (_sample_col) { + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { cumap->flag |= CUMA_DRAW_SAMPLE; copy_v3_v3(cumap->sample, _sample_col); } - else + else { cumap->flag &= ~CUMA_DRAW_SAMPLE; + } uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0); } @@ -1002,7 +1007,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN glDisable(GL_BLEND); /* outline active and selected emphasis */ - if (node->flag & (NODE_ACTIVE | SELECT) ) { + if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1105,7 +1110,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* XXX only kept for debugging * selection state is indicated by socket outline below! */ - #if 0 +#if 0 /* body */ uiSetRoundBox(15); UI_ThemeColor4(TH_NODE); @@ -1116,18 +1121,18 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* outline active and selected emphasis */ if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); - glEnable( GL_LINE_SMOOTH ); + glEnable(GL_LINE_SMOOTH); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ - if( node->flag & NODE_ACTIVE ) + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); else UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); - glDisable( GL_LINE_SMOOTH ); + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - #endif +#endif /* only draw input socket. as they all are placed on the same position. * highlight also if node itself is selected, since we don't display the node body separately! @@ -1194,10 +1199,10 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap uiLayout *col; int source; - if(!imaptr->data) + if (!imaptr->data) return; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, imaptr, "source", 0, "", ICON_NONE); @@ -1214,7 +1219,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE); uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE); @@ -1222,7 +1227,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); } - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE); @@ -1238,7 +1243,7 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA if (!node->id) return; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE); @@ -1249,22 +1254,22 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin uiLayout *row; uiItemL(layout, IFACE_("Location:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "translation", 0, "", ICON_NONE); uiItemL(layout, IFACE_("Rotation:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "rotation", 0, "", ICON_NONE); uiItemL(layout, IFACE_("Scale:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "scale", 0, "", ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE); uiItemR(row, ptr, "min", 0, "", ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE); uiItemR(row, ptr, "max", 0, "", ICON_NONE); } @@ -1279,7 +1284,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); @@ -1471,8 +1476,8 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point if (!node->id) return; - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); prop = RNA_struct_find_property(ptr, "layer"); @@ -1494,7 +1499,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point { uiLayout *col, *row; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "filter_type") != R_FILTER_FAST_GAUSS) { @@ -1506,15 +1511,15 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point if (RNA_boolean_get(ptr, "use_relative")) { uiItemL(col, IFACE_("Aspect Correction"), 0); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE); } else { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE); } @@ -1527,14 +1532,14 @@ static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), Poin uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Center:"), ICON_NONE); uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE); uiItemS(layout); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); @@ -1548,7 +1553,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED( { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE); @@ -1558,29 +1563,26 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *sub, *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE); uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == TRUE); uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); - uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_preview")); - uiItemR(sub, ptr, "samples", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == FALSE); uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE); } @@ -1620,7 +1622,7 @@ static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "tonemap_type") == 0) { uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1639,10 +1641,10 @@ static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), P { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE); - col = uiLayoutColumn(col, 0); + col = uiLayoutColumn(col, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == FALSE); uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE); @@ -1652,11 +1654,11 @@ static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Speed:"), ICON_NONE); uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE); @@ -1681,7 +1683,7 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); if (RNA_boolean_get(ptr, "relative")) { uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE); uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE); @@ -1700,8 +1702,8 @@ static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C) { uiLayout *row, *col; - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE); } @@ -1710,7 +1712,7 @@ static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUS { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE); uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE); @@ -1722,19 +1724,19 @@ static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), { uiLayout *sub, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "size", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min")); uiItemR(sub, ptr, "min", 0, "", ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max")); uiItemR(sub, ptr, "max", 0, "", ICON_NONE); } @@ -1743,7 +1745,7 @@ static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE); } @@ -1752,7 +1754,7 @@ static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), P { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE); } @@ -1761,7 +1763,7 @@ static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1771,8 +1773,13 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C) { uiItemR(layout, ptr, "type", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "type") == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { - uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE); + switch (RNA_enum_get(ptr, "type")) { + case CMP_NODE_DILATEERODE_DISTANCE_THRESH: + uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE); + break; + case CMP_NODE_DILATEERODE_DISTANCE_FEATHER: + uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE); + break; } } @@ -1780,7 +1787,7 @@ static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -1789,10 +1796,10 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED { uiLayout *col, *row; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1804,15 +1811,15 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) uiLayout *row, *col; uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "limit_method") == 0) { uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1829,11 +1836,11 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/ @@ -1843,7 +1850,7 @@ static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C) { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1854,20 +1861,20 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( uiLayout *col, *row; uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Key Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "limit_method") == 0) { uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1879,7 +1886,7 @@ static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -1892,7 +1899,7 @@ static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); } /* draw function for file output node sockets, displays only sub-path and format, no value button */ @@ -1907,7 +1914,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); imfptr = RNA_pointer_get(&nodeptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); @@ -1976,7 +1983,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ active_input_ptr.id.data = ptr->id.data; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&op_ptr, "direction", 1); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); @@ -1985,30 +1992,30 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C if (active_input_ptr.data) { if (multilayer) { uiLayout *row, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Layer:"), 0); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "name", 0, "", 0); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); } else { uiLayout *row, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("File Path:"), 0); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "path", 0, "", 0); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Format:"), 0); uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE); uiTemplateImageSettings(col, &imfptr); } @@ -2037,7 +2044,7 @@ static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), Poi { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE); } @@ -2060,39 +2067,39 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C if (RNA_enum_get(ptr, "correction_method") == 0) { - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE); } else { - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "power", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE); } @@ -2127,6 +2134,17 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { + bNode *node = ptr->data; + CurveMapping *cumap = node->storage; + + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { + cumap->flag |= CUMA_DRAW_SAMPLE; + copy_v3_v3(cumap->sample, _sample_col); + } + else { + cumap->flag &= ~CUMA_DRAW_SAMPLE; + } + uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0); } @@ -2173,12 +2191,12 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, "", 0); uiItemL(row, IFACE_("Saturation"), 0); uiItemL(row, IFACE_("Contrast"), 0); @@ -2186,7 +2204,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemL(row, IFACE_("Gain"), 0); uiItemL(row, IFACE_("Lift"), 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Master"), 0); uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2194,7 +2212,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Highlights"), 0); uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2202,7 +2220,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Midtones"), 0); uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2210,7 +2228,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Shadows"), 0); uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2218,7 +2236,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -2227,7 +2245,7 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); @@ -2262,7 +2280,7 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE); } @@ -2276,11 +2294,11 @@ static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2403,10 +2421,10 @@ void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2420,7 +2438,7 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE); uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE); } @@ -2429,7 +2447,8 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL); - uiItemR(layout, ptr, "smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE); } @@ -2446,7 +2465,7 @@ static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, Point RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA); } } @@ -2675,11 +2694,11 @@ static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), Poin { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); } @@ -2694,23 +2713,23 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); switch (tex->type) { case TEX_BLEND: uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; case TEX_MARBLE: - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; @@ -2719,9 +2738,9 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe break; case TEX_STUCCI: - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); break; @@ -2729,18 +2748,18 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe case TEX_WOOD: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "wood_type") == TEX_BAND || RNA_enum_get(&tex_ptr, "wood_type") == TEX_RING)); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; case TEX_CLOUDS: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE); break; diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index f2ec2289ad1..bc4c391720a 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -100,7 +100,7 @@ static void active_node_panel(const bContext *C, Panel *pa) //else RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); - layout = uiLayoutColumn(pa->layout, 0); + layout = uiLayoutColumn(pa->layout, FALSE); uiLayoutSetContextPointer(layout, "node", &ptr); /* draw this node's name, etc. */ @@ -113,17 +113,17 @@ static void active_node_panel(const bContext *C, Panel *pa) uiItemS(layout); uiItemS(layout); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemM(col, (bContext *)C, "NODE_MT_node_color_presets", NULL, 0); uiItemR(col, &ptr, "use_custom_color", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); - sub = uiLayoutRow(col, 0); + sub = uiLayoutRow(col, FALSE); if (!(node->flag & NODE_CUSTOM_COLOR)) uiLayoutSetEnabled(sub, 0); uiItemR(sub, &ptr, "color", 0, "", 0); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemO(col, "", ICON_ZOOMIN, "node.node_color_preset_add"); opptr = uiItemFullO(col, "node.node_color_preset_add", "", ICON_ZOOMOUT, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_boolean_set(&opptr, "remove_active", 1); @@ -164,7 +164,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa) for (sock=node->inputs.first; sock; sock=sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); - split = uiLayoutSplit(layout, 0.35f, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); uiItemL(split, name, ICON_NONE); uiTemplateNodeLink(split, ntree, node, sock); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 81e375f26bc..48f772e8008 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -120,7 +120,7 @@ typedef struct CompoJob { /* called by compo, only to check job 'stop' value */ static int compo_breakjob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; return *(cj->stop); } @@ -128,14 +128,14 @@ static int compo_breakjob(void *cjv) /* called by compo, wmJob sends notifier */ static void compo_redrawjob(void *cjv, char *UNUSED(str)) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; *(cj->do_update) = TRUE; } static void compo_freejob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; if (cj->localtree) { ntreeLocalMerge(cj->localtree, cj->ntree); @@ -147,22 +147,22 @@ static void compo_freejob(void *cjv) * sliding buttons doesn't frustrate */ static void compo_initjob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; - cj->localtree= ntreeLocalize(cj->ntree); + cj->localtree = ntreeLocalize(cj->ntree); } /* called before redraw notifiers, it moves finished previews over */ static void compo_updatejob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; ntreeLocalSync(cj->localtree, cj->ntree); } static void compo_progressjob(void *cjv, float progress) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; *(cj->progress) = progress; } @@ -171,49 +171,49 @@ static void compo_progressjob(void *cjv, float progress) /* only this runs inside thread */ static void compo_startjob(void *cjv, short *stop, short *do_update, float *progress) { - CompoJob *cj= cjv; - bNodeTree *ntree= cj->localtree; + CompoJob *cj = cjv; + bNodeTree *ntree = cj->localtree; if (cj->scene->use_nodes == FALSE) return; - cj->stop= stop; - cj->do_update= do_update; - cj->progress= progress; - - ntree->test_break= compo_breakjob; - ntree->tbh= cj; - ntree->stats_draw= compo_redrawjob; - ntree->sdh= cj; - ntree->progress= compo_progressjob; - ntree->prh= cj; + cj->stop = stop; + cj->do_update = do_update; + cj->progress = progress; + + ntree->test_break = compo_breakjob; + ntree->tbh = cj; + ntree->stats_draw = compo_redrawjob; + ntree->sdh = cj; + ntree->progress = compo_progressjob; + ntree->prh = cj; // XXX BIF_store_spare(); - ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ + ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ - ntree->test_break= NULL; - ntree->stats_draw= NULL; - ntree->progress= NULL; + ntree->test_break = NULL; + ntree->stats_draw = NULL; + ntree->progress = NULL; } void snode_composite_job(const bContext *C, ScrArea *sa) { - SpaceNode *snode= sa->spacedata.first; + SpaceNode *snode = sa->spacedata.first; wmJob *steve; CompoJob *cj; - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER|WM_JOB_PROGRESS); - cj= MEM_callocN(sizeof(CompoJob), "compo job"); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS); + cj = MEM_callocN(sizeof(CompoJob), "compo job"); /* customdata for preview thread */ - cj->scene= CTX_data_scene(C); - cj->ntree= snode->nodetree; + cj->scene = CTX_data_scene(C); + cj->ntree = snode->nodetree; /* setup job */ WM_jobs_customdata(steve, cj, compo_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE|ND_COMPO_RESULT); + WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL); WM_jobs_start(CTX_wm_manager(C), steve); @@ -225,9 +225,9 @@ void snode_composite_job(const bContext *C, ScrArea *sa) /* operator poll callback */ static int composite_node_active(bContext *C) { - if ( ED_operator_node_active(C)) { - SpaceNode *snode= CTX_wm_space_node(C); - if (snode->treetype==NTREE_COMPOSIT) + if (ED_operator_node_active(C)) { + SpaceNode *snode = CTX_wm_space_node(C); + if (snode->treetype == NTREE_COMPOSIT) return 1; } return 0; @@ -239,7 +239,7 @@ static bNode *editnode_get_active(bNodeTree *ntree) bNode *node; /* check for edited group */ - for (node= ntree->nodes.first; node; node= node->next) + for (node = ntree->nodes.first; node; node = node->next) if (nodeGroupEditGet(node)) break; if (node) @@ -255,9 +255,9 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) if (ntree == lookup) return 1; - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) + if (has_nodetree((bNodeTree *)node->id, lookup)) return 1; return 0; @@ -274,8 +274,8 @@ void snode_dag_update(bContext *C, SpaceNode *snode) Main *bmain = CTX_data_main(C); /* for groups, update all ID's using this */ - if (snode->edittree!=snode->nodetree) { - bNodeTreeType *tti= ntreeGetType(snode->edittree->type); + if (snode->edittree != snode->nodetree) { + bNodeTreeType *tti = ntreeGetType(snode->edittree->type); tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group); } @@ -284,14 +284,14 @@ void snode_dag_update(bContext *C, SpaceNode *snode) void snode_notify(bContext *C, SpaceNode *snode) { - WM_event_add_notifier(C, NC_NODE|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL); - if (snode->treetype==NTREE_SHADER) - WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); - else if (snode->treetype==NTREE_COMPOSIT) - WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if (snode->treetype==NTREE_TEXTURE) - WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + if (snode->treetype == NTREE_SHADER) + WM_event_add_notifier(C, NC_MATERIAL | ND_NODES, snode->id); + else if (snode->treetype == NTREE_COMPOSIT) + WM_event_add_notifier(C, NC_SCENE | ND_NODES, snode->id); + else if (snode->treetype == NTREE_TEXTURE) + WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, snode->id); } bNode *node_tree_get_editgroup(bNodeTree *nodetree) @@ -299,7 +299,7 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree) bNode *gnode; /* get the groupnode */ - for (gnode= nodetree->nodes.first; gnode; gnode= gnode->next) + for (gnode = nodetree->nodes.first; gnode; gnode = gnode->next) if (nodeGroupEditGet(gnode)) break; return gnode; @@ -316,11 +316,11 @@ void ED_node_shader_default(Scene *scene, ID *id) int output_type, shader_type; float color[3], strength = 1.0f; - ntree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); + ntree = ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); switch (GS(id->name)) { case ID_MA: { - Material *ma= (Material*)id; + Material *ma = (Material *)id; ma->nodetree = ntree; if (BKE_scene_use_new_shading_nodes(scene)) { @@ -333,22 +333,22 @@ void ED_node_shader_default(Scene *scene, ID *id) } copy_v3_v3(color, &ma->r); - strength= 0.0f; + strength = 0.0f; break; } case ID_WO: { - World *wo= (World*)id; + World *wo = (World *)id; wo->nodetree = ntree; output_type = SH_NODE_OUTPUT_WORLD; shader_type = SH_NODE_BACKGROUND; copy_v3_v3(color, &wo->horr); - strength= 1.0f; + strength = 1.0f; break; } case ID_LA: { - Lamp *la= (Lamp*)id; + Lamp *la = (Lamp *)id; la->nodetree = ntree; output_type = SH_NODE_OUTPUT_LAMP; @@ -356,9 +356,9 @@ void ED_node_shader_default(Scene *scene, ID *id) copy_v3_v3(color, &la->r); if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) - strength= 100.0f; + strength = 100.0f; else - strength= 1.0f; + strength = 1.0f; break; } default: @@ -367,27 +367,27 @@ void ED_node_shader_default(Scene *scene, ID *id) } ntemp.type = output_type; - out= nodeAddNode(ntree, &ntemp); - out->locx= 300.0f; out->locy= 300.0f; + out = nodeAddNode(ntree, &ntemp); + out->locx = 300.0f; out->locy = 300.0f; ntemp.type = shader_type; - in= nodeAddNode(ntree, &ntemp); - in->locx= 10.0f; in->locy= 300.0f; + in = nodeAddNode(ntree, &ntemp); + in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(ntree, in); /* only a link from color to color */ - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ if (BKE_scene_use_new_shading_nodes(scene)) { - sock= in->inputs.first; - copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); + sock = in->inputs.first; + copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, color); if (strength != 0.0f) { - sock= in->inputs.last; - ((bNodeSocketValueFloat*)sock->default_value)->value= strength; + sock = in->inputs.last; + ((bNodeSocketValueFloat *)sock->default_value)->value = strength; } } @@ -409,28 +409,28 @@ void ED_node_composit_default(Scene *sce) return; } - sce->nodetree= ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); + sce->nodetree = ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; ntemp.type = CMP_NODE_COMPOSITE; - out= nodeAddNode(sce->nodetree, &ntemp); - out->locx= 300.0f; out->locy= 400.0f; - out->id= &sce->id; + out = nodeAddNode(sce->nodetree, &ntemp); + out->locx = 300.0f; out->locy = 400.0f; + out->id = &sce->id; id_us_plus(out->id); ntemp.type = CMP_NODE_R_LAYERS; - in= nodeAddNode(sce->nodetree, &ntemp); - in->locx= 10.0f; in->locy= 400.0f; - in->id= &sce->id; + in = nodeAddNode(sce->nodetree, &ntemp); + in->locx = 10.0f; in->locy = 400.0f; + in->id = &sce->id; id_us_plus(in->id); nodeSetActive(sce->nodetree, in); /* links from color to color */ - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(sce->nodetree, in, fromsock, out, tosock); ntreeUpdateTree(sce->nodetree); @@ -453,19 +453,19 @@ void ED_node_texture_default(Tex *tx) return; } - tx->nodetree= ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); + tx->nodetree = ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); ntemp.type = TEX_NODE_OUTPUT; - out= nodeAddNode(tx->nodetree, &ntemp); - out->locx= 300.0f; out->locy= 300.0f; + out = nodeAddNode(tx->nodetree, &ntemp); + out->locx = 300.0f; out->locy = 300.0f; ntemp.type = TEX_NODE_CHECKER; - in= nodeAddNode(tx->nodetree, &ntemp); - in->locx= 10.0f; in->locy= 300.0f; + in = nodeAddNode(tx->nodetree, &ntemp); + in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(tx->nodetree, in); - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(tx->nodetree, in, fromsock, out, tosock); ntreeUpdateTree(tx->nodetree); @@ -475,128 +475,128 @@ void ED_node_texture_default(Tex *tx) void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype) { if (id) { - bNode *node= NULL; - short idtype= GS(id->name); + bNode *node = NULL; + short idtype = GS(id->name); if (idtype == ID_NT) { - *ntree= (bNodeTree*)id; - if (treetype) *treetype= (*ntree)->type; + *ntree = (bNodeTree *)id; + if (treetype) *treetype = (*ntree)->type; } else if (idtype == ID_MA) { - *ntree= ((Material*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((Material *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_LA) { - *ntree= ((Lamp*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((Lamp *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_WO) { - *ntree= ((World*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((World *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_SCE) { - *ntree= ((Scene*)id)->nodetree; - if (treetype) *treetype= NTREE_COMPOSIT; + *ntree = ((Scene *)id)->nodetree; + if (treetype) *treetype = NTREE_COMPOSIT; } else if (idtype == ID_TE) { - *ntree= ((Tex*)id)->nodetree; - if (treetype) *treetype= NTREE_TEXTURE; + *ntree = ((Tex *)id)->nodetree; + if (treetype) *treetype = NTREE_TEXTURE; } else { - if (treetype) *treetype= 0; + if (treetype) *treetype = 0; return; } /* find editable group */ if (edittree) { if (*ntree) - for (node= (*ntree)->nodes.first; node; node= node->next) + for (node = (*ntree)->nodes.first; node; node = node->next) if (nodeGroupEditGet(node)) break; if (node && node->id) - *edittree= (bNodeTree *)node->id; + *edittree = (bNodeTree *)node->id; else - *edittree= *ntree; + *edittree = *ntree; } } else { - *ntree= NULL; - *edittree= NULL; - if (treetype) *treetype= 0; + *ntree = NULL; + *edittree = NULL; + if (treetype) *treetype = 0; } } /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ void snode_set_context(SpaceNode *snode, Scene *scene) { - Object *ob= OBACT; + Object *ob = OBACT; - snode->id= snode->from= NULL; + snode->id = snode->from = NULL; - if (snode->treetype==NTREE_SHADER) { + if (snode->treetype == NTREE_SHADER) { /* need active object, or we allow pinning... */ if (snode->shaderfrom == SNODE_SHADER_OBJECT) { if (ob) { if (ob->type == OB_LAMP) { - snode->from= &ob->id; - snode->id= ob->data; + snode->from = &ob->id; + snode->id = ob->data; } else { - Material *ma= give_current_material(ob, ob->actcol); + Material *ma = give_current_material(ob, ob->actcol); if (ma) { - snode->from= &ob->id; - snode->id= &ma->id; + snode->from = &ob->id; + snode->id = &ma->id; } } } } else { /* SNODE_SHADER_WORLD */ if (scene->world) { - snode->from= NULL; - snode->id= &scene->world->id; + snode->from = NULL; + snode->id = &scene->world->id; } } } - else if (snode->treetype==NTREE_COMPOSIT) { - snode->id= &scene->id; + else if (snode->treetype == NTREE_COMPOSIT) { + snode->id = &scene->id; /* update output sockets based on available layers */ ntreeCompositForceHidden(scene->nodetree, scene); } - else if (snode->treetype==NTREE_TEXTURE) { - Tex *tx= NULL; + else if (snode->treetype == NTREE_TEXTURE) { + Tex *tx = NULL; - if (snode->texfrom==SNODE_TEX_OBJECT) { + if (snode->texfrom == SNODE_TEX_OBJECT) { if (ob) { - tx= give_current_object_texture(ob); + tx = give_current_object_texture(ob); if (ob->type == OB_LAMP) - snode->from= (ID*)ob->data; + snode->from = (ID *)ob->data; else - snode->from= (ID*)give_current_material(ob, ob->actcol); + snode->from = (ID *)give_current_material(ob, ob->actcol); /* from is not set fully for material nodes, should be ID + Node then */ - snode->id= &tx->id; + snode->id = &tx->id; } } - else if (snode->texfrom==SNODE_TEX_WORLD) { - tx= give_current_world_texture(scene->world); - snode->from= (ID *)scene->world; - snode->id= &tx->id; + else if (snode->texfrom == SNODE_TEX_WORLD) { + tx = give_current_world_texture(scene->world); + snode->from = (ID *)scene->world; + snode->id = &tx->id; } else { - struct Brush *brush= NULL; + struct Brush *brush = NULL; if (ob && (ob->mode & OB_MODE_SCULPT)) - brush= paint_brush(&scene->toolsettings->sculpt->paint); + brush = paint_brush(&scene->toolsettings->sculpt->paint); else - brush= paint_brush(&scene->toolsettings->imapaint.paint); + brush = paint_brush(&scene->toolsettings->imapaint.paint); if (brush) { - snode->from= (ID *)brush; - tx= give_current_brush_texture(brush); - snode->id= &tx->id; + snode->from = (ID *)brush; + tx = give_current_brush_texture(brush); + snode->id = &tx->id; } } } @@ -618,7 +618,7 @@ static void snode_update(SpaceNode *snode, bNode *node) nodeUpdate(snode->edittree, node); /* if inside group, tag entire group */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) nodeUpdateID(snode->nodetree, gnode->id); } @@ -629,24 +629,24 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) nodeSetActive(ntree, node); - if (node->type!=NODE_GROUP) { - int was_output= (node->flag & NODE_DO_OUTPUT); + if (node->type != NODE_GROUP) { + int was_output = (node->flag & NODE_DO_OUTPUT); /* tree specific activate calls */ - if (ntree->type==NTREE_SHADER) { + if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if (node->id && ELEM3(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - if (node->type==SH_NODE_OUTPUT) { + if (node->type == SH_NODE_OUTPUT) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( tnode->type==SH_NODE_OUTPUT) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (tnode->type == SH_NODE_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if (was_output==0) + if (was_output == 0) ED_node_generic_update(bmain, ntree, node); } @@ -654,49 +654,49 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { Material *ma; - for (ma=bmain->mat.first; ma; ma=ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree)) GPU_material_free(ma); WM_main_add_notifier(NC_IMAGE, NULL); } - WM_main_add_notifier(NC_MATERIAL|ND_NODES, node->id); + WM_main_add_notifier(NC_MATERIAL | ND_NODES, node->id); } - else if (ntree->type==NTREE_COMPOSIT) { + else if (ntree->type == NTREE_COMPOSIT) { /* make active viewer, currently only 1 supported... */ - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if (was_output==0) + if (was_output == 0) ED_node_generic_update(bmain, ntree, node); /* addnode() doesnt link this yet... */ - node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } - else if (node->type==CMP_NODE_R_LAYERS) { + else if (node->type == CMP_NODE_R_LAYERS) { Scene *scene; - for (scene=bmain->scene.first; scene; scene=scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->nodetree && scene->use_nodes && has_nodetree(scene->nodetree, ntree)) { - if (node->id==NULL || node->id==(ID *)scene) { - scene->r.actlay= node->custom1; + if (node->id == NULL || node->id == (ID *)scene) { + scene->r.actlay = node->custom1; } } } } - else if (node->type==CMP_NODE_COMPOSITE) { - if (was_output==0) { + else if (node->type == CMP_NODE_COMPOSITE) { + if (was_output == 0) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( tnode->type==CMP_NODE_COMPOSITE) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (tnode->type == CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; @@ -704,11 +704,11 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) } } } - else if (ntree->type==NTREE_TEXTURE) { + else if (ntree->type == NTREE_TEXTURE) { // XXX #if 0 if (node->id) - ; // XXX BIF_preview_changed(-1); + ; // XXX BIF_preview_changed(-1); // allqueue(REDRAWBUTSSHADING, 1); // allqueue(REDRAWIPO, 0); #endif @@ -745,7 +745,7 @@ static void edit_node_properties(wmOperatorType *ot) static int edit_node_invoke_properties(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "node")) { - bNode *node= CTX_data_pointer_get_type(C, "node", &RNA_Node).data; + bNode *node = CTX_data_pointer_get_type(C, "node", &RNA_Node).data; if (!node) return 0; else @@ -764,7 +764,7 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op) static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **rnode, bNodeSocket **rsock, int *rin_out) { bNode *node; - bNodeSocket *sock=NULL; + bNodeSocket *sock = NULL; char nodename[MAX_NAME]; int sockindex; int in_out; @@ -776,8 +776,8 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r sockindex = RNA_int_get(op->ptr, "socket"); switch (in_out) { - case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; - case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; + case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; + case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; } if (rnode) @@ -796,25 +796,25 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode) bNode *node; /* make sure nothing has group editing on */ - for (node=snode->nodetree->nodes.first; node; node=node->next) + for (node = snode->nodetree->nodes.first; node; node = node->next) nodeGroupEditClear(node); - if (gnode==NULL) { + if (gnode == NULL) { /* with NULL argument we do a toggle */ - if (snode->edittree==snode->nodetree) - gnode= nodeGetActive(snode->nodetree); + if (snode->edittree == snode->nodetree) + gnode = nodeGetActive(snode->nodetree); } if (gnode) { snode->edittree = nodeGroupEditSet(gnode, 1); /* deselect all other nodes, so we can also do grabbing of entire subtree */ - for (node= snode->nodetree->nodes.first; node; node= node->next) + for (node = snode->nodetree->nodes.first; node; node = node->next) node_deselect(node); node_select(gnode); } else - snode->edittree= snode->nodetree; + snode->edittree = snode->nodetree; } static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op)) @@ -823,14 +823,14 @@ static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - if (snode->nodetree==snode->edittree) { + if (snode->nodetree == snode->edittree) { bNode *gnode = nodeGetActive(snode->edittree); snode_make_group_editable(snode, gnode); } else snode_make_group_editable(snode, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL); return OPERATOR_FINISHED; } @@ -841,9 +841,9 @@ static int node_group_edit_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e bNode *gnode; /* XXX callback? */ - if (snode->nodetree==snode->edittree) { + if (snode->nodetree == snode->edittree) { gnode = nodeGetActive(snode->edittree); - if (gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) { + if (gnode && gnode->id && GS(gnode->id->name) == ID_NT && gnode->id->lib) { uiPupMenuOkee(C, op->type->idname, "Make group local?"); return OPERATOR_CANCELLED; } @@ -865,7 +865,7 @@ void NODE_OT_group_edit(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Add Group Socket operator ************* */ @@ -873,10 +873,10 @@ void NODE_OT_group_edit(wmOperatorType *ot) static int node_group_socket_add_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int in_out= -1; - char name[MAX_NAME]= ""; - int type= SOCK_FLOAT; - bNodeTree *ngroup= snode->edittree; + int in_out = -1; + char name[MAX_NAME] = ""; + int type = SOCK_FLOAT; + bNodeTree *ngroup = snode->edittree; /* bNodeSocket *sock; */ /* UNUSED */ ED_preview_kill_jobs(C); @@ -914,7 +914,7 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Group socket name"); @@ -926,9 +926,9 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) static int node_group_socket_remove_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock; ED_preview_kill_jobs(C); @@ -943,7 +943,7 @@ static int node_group_socket_remove_exec(bContext *C, wmOperator *op) else return OPERATOR_CANCELLED; - sock = (bNodeSocket*)BLI_findlink(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, index); + sock = (bNodeSocket *)BLI_findlink(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, index); if (sock) { node_group_remove_socket(ngroup, sock, in_out); ntreeUpdateTree(ngroup); @@ -966,7 +966,7 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -977,9 +977,9 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock, *prev; ED_preview_kill_jobs(C); @@ -995,8 +995,8 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* swap */ - if (in_out==SOCK_IN) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->inputs, index); + if (in_out == SOCK_IN) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->inputs, index); prev = sock->prev; /* can't move up the first socket */ if (!prev) @@ -1006,8 +1006,8 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) ngroup->update |= NTREE_UPDATE_GROUP_IN; } - else if (in_out==SOCK_OUT) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->outputs, index); + else if (in_out == SOCK_OUT) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->outputs, index); prev = sock->prev; /* can't move up the first socket */ if (!prev) @@ -1036,7 +1036,7 @@ void NODE_OT_group_socket_move_up(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -1047,9 +1047,9 @@ void NODE_OT_group_socket_move_up(wmOperatorType *ot) static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock, *next; ED_preview_kill_jobs(C); @@ -1065,8 +1065,8 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* swap */ - if (in_out==SOCK_IN) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->inputs, index); + if (in_out == SOCK_IN) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->inputs, index); next = sock->next; /* can't move down the last socket */ if (!next) @@ -1076,8 +1076,8 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) ngroup->update |= NTREE_UPDATE_GROUP_IN; } - else if (in_out==SOCK_OUT) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->outputs, index); + else if (in_out == SOCK_OUT) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->outputs, index); next = sock->next; /* can't move down the last socket */ if (!next) @@ -1106,7 +1106,7 @@ void NODE_OT_group_socket_move_down(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -1122,22 +1122,22 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bNodeTree *ngroup, *wgroup; ListBase anim_basepaths = {NULL, NULL}; - ngroup= (bNodeTree *)gnode->id; - if (ngroup==NULL) return 0; + ngroup = (bNodeTree *)gnode->id; + if (ngroup == NULL) return 0; /* clear new pointers, set in copytree */ - for (node= ntree->nodes.first; node; node= node->next) - node->new_node= NULL; + for (node = ntree->nodes.first; node; node = node->next) + node->new_node = NULL; /* wgroup is a temporary copy of the NodeTree we're merging in * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed */ - wgroup= ntreeCopyTree(ngroup); + wgroup = ntreeCopyTree(ngroup); /* add the nodes into the ntree */ - for (node= wgroup->nodes.first; node; node= nextn) { - nextn= node->next; + for (node = wgroup->nodes.first; node; node = nextn) { + nextn = node->next; /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node @@ -1164,10 +1164,10 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* restore external links to and from the gnode */ - for (link= ntree->links.first; link; link= link->next) { - if (link->fromnode==gnode) { + for (link = ntree->links.first; link; link = link->next) { + if (link->fromnode == gnode) { if (link->fromsock->groupsock) { - bNodeSocket *gsock= link->fromsock->groupsock; + bNodeSocket *gsock = link->fromsock->groupsock; if (gsock->link) { if (gsock->link->fromnode) { /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */ @@ -1176,7 +1176,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } else { /* group output directly maps to group input */ - bNodeSocket *insock= node_group_find_input(gnode, gsock->link->fromsock); + bNodeSocket *insock = node_group_find_input(gnode, gsock->link->fromsock); if (insock->link) { link->fromnode = insock->link->fromnode; link->fromsock = insock->link->fromsock; @@ -1191,20 +1191,20 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } } /* remove internal output links, these are not used anymore */ - for (link=wgroup->links.first; link; link= linkn) { + for (link = wgroup->links.first; link; link = linkn) { linkn = link->next; if (!link->tonode) nodeRemLink(wgroup, link); } /* restore links from internal nodes */ - for (link= wgroup->links.first; link; link= link->next) { + for (link = wgroup->links.first; link; link = link->next) { /* indicates link to group input */ if (!link->fromnode) { /* NB: can't use find_group_node_input here, * because gnode sockets still point to the old tree! */ bNodeSocket *insock; - for (insock= gnode->inputs.first; insock; insock= insock->next) + for (insock = gnode->inputs.first; insock; insock = insock->next) if (insock->groupsock->new_sock == link->fromsock) break; if (insock->link) { @@ -1220,8 +1220,8 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* add internal links to the ntree */ - for (link= wgroup->links.first; link; link= linkn) { - linkn= link->next; + for (link = wgroup->links.first; link; link = linkn) { + linkn = link->next; BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); } @@ -1229,7 +1229,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* and copy across the animation, * note that the animation data's action can be NULL here */ if (wgroup->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; bAction *waction; /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ @@ -1271,15 +1271,15 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* are we inside of a group? */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) snode_make_group_editable(snode, NULL); - gnode= nodeGetActive(snode->edittree); - if (gnode==NULL) + gnode = nodeGetActive(snode->edittree); + if (gnode == NULL) return OPERATOR_CANCELLED; - if (gnode->type!=NODE_GROUP) { + if (gnode->type != NODE_GROUP) { BKE_report(op->reports, RPT_WARNING, "Not a group"); return OPERATOR_CANCELLED; } @@ -1309,7 +1309,7 @@ void NODE_OT_group_ungroup(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Separate operator ********************** */ @@ -1322,19 +1322,19 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make bNodeTree *ngroup; ListBase anim_basepaths = {NULL, NULL}; - ngroup= (bNodeTree *)gnode->id; - if (ngroup==NULL) return 0; + ngroup = (bNodeTree *)gnode->id; + if (ngroup == NULL) return 0; /* deselect all nodes in the target tree */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node_deselect(node); /* clear new pointers, set in nodeCopyNode */ - for (node= ngroup->nodes.first; node; node= node->next) - node->new_node= NULL; + for (node = ngroup->nodes.first; node; node = node->next) + node->new_node = NULL; /* add selected nodes into the ntree */ - for (node= ngroup->nodes.first; node; node= node_next) { + for (node = ngroup->nodes.first; node; node = node_next) { node_next = node->next; if (!(node->flag & NODE_SELECT)) continue; @@ -1375,7 +1375,7 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make } /* add internal links to the ntree */ - for (link= ngroup->links.first; link; link= link_next) { + for (link = ngroup->links.first; link; link = link_next) { int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT)); int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT)); link_next = link->next; @@ -1400,7 +1400,7 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make /* and copy across the animation, * note that the animation data's action can be NULL here */ if (ngroup->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; /* now perform the moving */ BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths); @@ -1428,7 +1428,7 @@ typedef enum eNodeGroupSeparateType { /* Operator Property */ EnumPropertyItem node_group_separate_types[] = { - {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, + {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"}, {0, NULL, 0, NULL, NULL} }; @@ -1442,25 +1442,25 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* are we inside of a group? */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (!gnode) { BKE_report(op->reports, RPT_WARNING, "Not inside node group"); return OPERATOR_CANCELLED; } switch (type) { - case NODE_GS_COPY: - if (!node_group_separate_selected(snode->nodetree, gnode, 1)) { - BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); - return OPERATOR_CANCELLED; - } - break; - case NODE_GS_MOVE: - if (!node_group_separate_selected(snode->nodetree, gnode, 0)) { - BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); - return OPERATOR_CANCELLED; - } - break; + case NODE_GS_COPY: + if (!node_group_separate_selected(snode->nodetree, gnode, 1)) { + BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); + return OPERATOR_CANCELLED; + } + break; + case NODE_GS_MOVE: + if (!node_group_separate_selected(snode->nodetree, gnode, 0)) { + BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); + return OPERATOR_CANCELLED; + } + break; } /* switch to parent tree */ @@ -1501,7 +1501,7 @@ void NODE_OT_group_separate(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", ""); } @@ -1513,7 +1513,7 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct) { bNode *node; - for (node=snode->edittree->nodes.last; node; node=node->prev) { + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (BLI_isect_rctf(&node->totr, rct, NULL)) break; } @@ -1529,17 +1529,17 @@ typedef struct NodeViewMove { static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - NodeViewMove *nvm= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + NodeViewMove *nvm = op->customdata; switch (event->type) { case MOUSEMOVE: - snode->xof -= (nvm->mvalo[0]-event->mval[0]); - snode->yof -= (nvm->mvalo[1]-event->mval[1]); - nvm->mvalo[0]= event->mval[0]; - nvm->mvalo[1]= event->mval[1]; + snode->xof -= (nvm->mvalo[0] - event->mval[0]); + snode->yof -= (nvm->mvalo[1] - event->mval[1]); + nvm->mvalo[0] = event->mval[0]; + nvm->mvalo[1] = event->mval[1]; /* prevent dragging image outside of the window and losing it! */ CLAMP(snode->xof, nvm->xmin, nvm->xmax); @@ -1554,9 +1554,9 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTMOUSE: MEM_freeN(nvm); - op->customdata= NULL; + op->customdata = NULL; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE, NULL); return OPERATOR_FINISHED; } @@ -1566,30 +1566,30 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); NodeViewMove *nvm; Image *ima; ImBuf *ibuf; - int pad= 10; + int pad = 10; void *lock; - ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf == NULL) { BKE_image_release_ibuf(ima, lock); return OPERATOR_CANCELLED; } - nvm= MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); - op->customdata= nvm; - nvm->mvalo[0]= event->mval[0]; - nvm->mvalo[1]= event->mval[1]; + nvm = MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); + op->customdata = nvm; + nvm->mvalo[0] = event->mval[0]; + nvm->mvalo[1] = event->mval[1]; - nvm->xmin = -(ar->winx/2) - ibuf->x/2 + pad; - nvm->xmax = ar->winx/2 + ibuf->x/2 - pad; - nvm->ymin = -(ar->winy/2) - ibuf->y/2 + pad; - nvm->ymax = ar->winy/2 + ibuf->y/2 - pad; + nvm->xmin = -(ar->winx / 2) - ibuf->x / 2 + pad; + nvm->xmax = ar->winx / 2 + ibuf->x / 2 - pad; + nvm->ymin = -(ar->winy / 2) - ibuf->y / 2 + pad; + nvm->ymax = ar->winy / 2 + ibuf->y / 2 - pad; BKE_image_release_ibuf(ima, lock); @@ -1602,7 +1602,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } @@ -1621,14 +1621,14 @@ void NODE_OT_backimage_move(wmOperatorType *ot) ot->cancel = snode_bg_viewmove_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; } static int backimage_zoom(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - float fac= RNA_float_get(op->ptr, "factor"); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + float fac = RNA_float_get(op->ptr, "factor"); snode->zoom *= fac; ED_region_tag_redraw(ar); @@ -1674,28 +1674,32 @@ typedef struct ImageSampleInfo { static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) { Scene *scene = CTX_data_scene(C); - ImageSampleInfo *info= arg_info; + ImageSampleInfo *info = arg_info; - ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, - info->x, info->y, info->col, info->colf, - NULL, NULL /* zbuf - unused for nodes */ - ); + if (info->draw) { + ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + info->x, info->y, info->col, info->colf, + NULL, NULL /* zbuf - unused for nodes */ + ); + } } static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - ImageSampleInfo *info= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + ImageSampleInfo *info = op->customdata; void *lock; Image *ima; ImBuf *ibuf; float fx, fy, bufx, bufy; - ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if (!ibuf) + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + if (!ibuf) { + info->draw = 0; return; + } if (!ibuf->rect) { if (info->color_manage) @@ -1708,46 +1712,50 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) /* map the mouse coords to the backdrop image space */ bufx = ibuf->x * snode->zoom; bufy = ibuf->y * snode->zoom; - fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); - fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); + fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f); + fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f); - if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { float *fp; char *cp; - int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); - CLAMP(x, 0, ibuf->x-1); - CLAMP(y, 0, ibuf->y-1); + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); - info->x= x; - info->y= y; - info->draw= 1; - info->channels= ibuf->channels; + info->x = x; + info->y = y; + info->draw = 1; + info->channels = ibuf->channels; if (ibuf->rect) { - cp= (char *)(ibuf->rect + y*ibuf->x + x); + cp = (char *)(ibuf->rect + y * ibuf->x + x); - info->col[0]= cp[0]; - info->col[1]= cp[1]; - info->col[2]= cp[2]; - info->col[3]= cp[3]; + info->col[0] = cp[0]; + info->col[1] = cp[1]; + info->col[2] = cp[2]; + info->col[3] = cp[3]; - info->colf[0]= (float)cp[0]/255.0f; - info->colf[1]= (float)cp[1]/255.0f; - info->colf[2]= (float)cp[2]/255.0f; - info->colf[3]= (float)cp[3]/255.0f; + info->colf[0] = (float)cp[0] / 255.0f; + info->colf[1] = (float)cp[1] / 255.0f; + info->colf[2] = (float)cp[2] / 255.0f; + info->colf[3] = (float)cp[3] / 255.0f; } if (ibuf->rect_float) { - fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - info->colf[0]= fp[0]; - info->colf[1]= fp[1]; - info->colf[2]= fp[2]; - info->colf[3]= fp[3]; + info->colf[0] = fp[0]; + info->colf[1] = fp[1]; + info->colf[2] = fp[2]; + info->colf[3] = fp[3]; } + + ED_node_sample_set(info->colf); + } + else { + info->draw = 0; + ED_node_sample_set(NULL); } - else - info->draw= 0; BKE_image_release_ibuf(ima, lock); @@ -1756,8 +1764,9 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) static void sample_exit(bContext *C, wmOperator *op) { - ImageSampleInfo *info= op->customdata; + ImageSampleInfo *info = op->customdata; + ED_node_sample_set(NULL); ED_region_draw_cb_exit(info->art, info->draw_handle); ED_area_tag_redraw(CTX_wm_area(C)); MEM_freeN(info); @@ -1765,17 +1774,17 @@ static void sample_exit(bContext *C, wmOperator *op) static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); ImageSampleInfo *info; - if (snode->treetype!=NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) + if (snode->treetype != NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) return OPERATOR_CANCELLED; - info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); - info->art= ar->type; + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info->art = ar->type; info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); - op->customdata= info; + op->customdata = info; sample_apply(C, op, event); @@ -1837,20 +1846,20 @@ static void node_resize_init(bContext *C, wmOperator *op, wmEvent *UNUSED(event) { SpaceNode *snode = CTX_wm_space_node(C); - NodeSizeWidget *nsw= MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); + NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); - op->customdata= nsw; - nsw->mxstart= snode->mx; - nsw->mystart= snode->my; + op->customdata = nsw; + nsw->mxstart = snode->mx; + nsw->mystart = snode->my; /* store old */ - nsw->oldlocx= node->locx; - nsw->oldlocy= node->locy; - nsw->oldoffsetx= node->offsetx; - nsw->oldoffsety= node->offsety; - nsw->oldwidth= node->width; - nsw->oldheight= node->height; - nsw->oldminiwidth= node->miniwidth; + nsw->oldlocx = node->locx; + nsw->oldlocy = node->locy; + nsw->oldoffsetx = node->offsetx; + nsw->oldoffsety = node->offsety; + nsw->oldwidth = node->width; + nsw->oldheight = node->height; + nsw->oldminiwidth = node->miniwidth; nsw->directions = dir; WM_cursor_modal(CTX_wm_window(C), node_get_resize_cursor(dir)); @@ -1863,15 +1872,15 @@ static void node_resize_exit(bContext *C, wmOperator *op, int UNUSED(cancel)) WM_cursor_restore(CTX_wm_window(C)); MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNode *node= editnode_get_active(snode->edittree); - NodeSizeWidget *nsw= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node = editnode_get_active(snode->edittree); + NodeSizeWidget *nsw = op->customdata; float mx, my, dx, dy; switch (event->type) { @@ -1886,46 +1895,46 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) float widthmin = 0.0f; float widthmax = 100.0f; if (nsw->directions & NODE_RESIZE_RIGHT) { - node->miniwidth= nsw->oldminiwidth + dx; + node->miniwidth = nsw->oldminiwidth + dx; CLAMP(node->miniwidth, widthmin, widthmax); } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + nsw->oldminiwidth; - node->locx= nsw->oldlocx + dx; + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); - node->miniwidth= locmax - node->locx; + node->miniwidth = locmax - node->locx; } } else { - float widthmin = UI_DPI_FAC*node->typeinfo->minwidth; - float widthmax = UI_DPI_FAC*node->typeinfo->maxwidth; + float widthmin = UI_DPI_FAC * node->typeinfo->minwidth; + float widthmax = UI_DPI_FAC * node->typeinfo->maxwidth; if (nsw->directions & NODE_RESIZE_RIGHT) { - node->width= nsw->oldwidth + dx; + node->width = nsw->oldwidth + dx; CLAMP(node->width, widthmin, widthmax); } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + nsw->oldwidth; - node->locx= nsw->oldlocx + dx; + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); - node->width= locmax - node->locx; + node->width = locmax - node->locx; } } /* height works the other way round ... */ { - float heightmin = UI_DPI_FAC*node->typeinfo->minheight; - float heightmax = UI_DPI_FAC*node->typeinfo->maxheight; + float heightmin = UI_DPI_FAC * node->typeinfo->minheight; + float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; - node->locy= nsw->oldlocy + dy; + node->locy = nsw->oldlocy + dy; CLAMP(node->locy, locmin + heightmin, locmin + heightmax); - node->height= node->locy - locmin; + node->height = node->locy - locmin; } if (nsw->directions & NODE_RESIZE_BOTTOM) { - node->height= nsw->oldheight - dy; + node->height = nsw->oldheight - dy; CLAMP(node->height, heightmin, heightmax); } } @@ -1934,20 +1943,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) if (node->type == NODE_FRAME) { /* keep the offset symmetric around center point */ if (nsw->directions & NODE_RESIZE_LEFT) { - node->locx = nsw->oldlocx + 0.5f*dx; - node->offsetx = nsw->oldoffsetx + 0.5f*dx; + node->locx = nsw->oldlocx + 0.5f * dx; + node->offsetx = nsw->oldoffsetx + 0.5f * dx; } if (nsw->directions & NODE_RESIZE_RIGHT) { - node->locx = nsw->oldlocx + 0.5f*dx; - node->offsetx = nsw->oldoffsetx - 0.5f*dx; + node->locx = nsw->oldlocx + 0.5f * dx; + node->offsetx = nsw->oldoffsetx - 0.5f * dx; } if (nsw->directions & NODE_RESIZE_TOP) { - node->locy = nsw->oldlocy + 0.5f*dy; - node->offsety = nsw->oldoffsety + 0.5f*dy; + node->locy = nsw->oldlocy + 0.5f * dy; + node->offsety = nsw->oldoffsety + 0.5f * dy; } if (nsw->directions & NODE_RESIZE_BOTTOM) { - node->locy = nsw->oldlocy + 0.5f*dy; - node->offsety = nsw->oldoffsety - 0.5f*dy; + node->locy = nsw->oldlocy + 0.5f * dy; + node->offsety = nsw->oldoffsety - 0.5f * dy; } } } @@ -1971,9 +1980,9 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNode *node= editnode_get_active(snode->edittree); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node = editnode_get_active(snode->edittree); int dir; if (node) { @@ -1986,7 +1995,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static int node_resize_cancel(bContext *C, wmOperator *op) @@ -2020,10 +2029,10 @@ int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - for (sock= node->inputs.first; sock; sock= sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; - for (sock= node->outputs.first; sock; sock= sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; return 0; @@ -2033,20 +2042,20 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set) { bNodeSocket *sock; - if (set==0) { - for (sock= node->inputs.first; sock; sock= sock->next) + if (set == 0) { + for (sock = node->inputs.first; sock; sock = sock->next) sock->flag &= ~SOCK_HIDDEN; - for (sock= node->outputs.first; sock; sock= sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) sock->flag &= ~SOCK_HIDDEN; } else { /* hide unused sockets */ - for (sock= node->inputs.first; sock; sock= sock->next) { - if (sock->link==NULL) + for (sock = node->inputs.first; sock; sock = sock->next) { + if (sock->link == NULL) sock->flag |= SOCK_HIDDEN; } - for (sock= node->outputs.first; sock; sock= sock->next) { - if (nodeCountSocketLinks(snode->edittree, sock)==0) + for (sock = node->outputs.first; sock; sock = sock->next) { + if (nodeCountSocketLinks(snode->edittree, sock) == 0) sock->flag |= SOCK_HIDDEN; } } @@ -2060,20 +2069,20 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if (tonode==NULL || tonode->outputs.first==NULL) + if (tonode == NULL || tonode->outputs.first == NULL) return OPERATOR_CANCELLED; - if ( ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) return OPERATOR_CANCELLED; /* get viewer */ - for (node= snode->edittree->nodes.first; node; node= node->next) - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (node = snode->edittree->nodes.first; node; node = node->next) + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) if (node->flag & NODE_DO_OUTPUT) break; /* no viewer, we make one active */ - if (node==NULL) { - for (node= snode->edittree->nodes.first; node; node= node->next) { - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node == NULL) { + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { node->flag |= NODE_DO_OUTPUT; break; } @@ -2085,17 +2094,17 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* try to find an already connected socket to cycle to the next */ if (node) { link = NULL; - for (link= snode->edittree->links.first; link; link= link->next) - if (link->tonode==node && link->fromnode==tonode) - if (link->tosock==node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) + if (link->tonode == node && link->fromnode == tonode) + if (link->tosock == node->inputs.first) break; if (link) { /* unlink existing connection */ - sock= link->fromsock; + sock = link->fromsock; nodeRemLink(snode->edittree, link); /* find a socket after the previously connected socket */ - for (sock=sock->next; sock; sock= sock->next) + for (sock = sock->next; sock; sock = sock->next) if (!nodeSocketIsHidden(sock)) break; } @@ -2103,7 +2112,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* find a socket starting from the first socket */ if (!sock) { - for (sock= tonode->outputs.first; sock; sock= sock->next) + for (sock = tonode->outputs.first; sock; sock = sock->next) if (!nodeSocketIsHidden(sock)) break; } @@ -2125,17 +2134,17 @@ static int node_link_viewer(const bContext *C, bNode *tonode) } else { /* get link to viewer */ - for (link= snode->edittree->links.first; link; link= link->next) - if (link->tonode==node && link->tosock==node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) + if (link->tonode == node && link->tosock == node->inputs.first) break; } - if (link==NULL) { + if (link == NULL) { nodeAddLink(snode->edittree, tonode, sock, node, node->inputs.first); } else { - link->fromnode= tonode; - link->fromsock= sock; + link->fromnode = tonode; + link->fromsock = sock; /* make sure the dependency sorting is updated */ snode->edittree->update |= NTREE_UPDATE_LINKS; } @@ -2149,10 +2158,10 @@ static int node_link_viewer(const bContext *C, bNode *tonode) static int node_active_link_viewer(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - node= editnode_get_active(snode->edittree); + node = editnode_get_active(snode->edittree); if (!node) return OPERATOR_CANCELLED; @@ -2181,31 +2190,31 @@ void NODE_OT_link_viewer(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* return 0, nothing done */ -static int UNUSED_FUNCTION(node_mouse_groupheader)(SpaceNode *snode) +static int UNUSED_FUNCTION(node_mouse_groupheader) (SpaceNode * snode) { bNode *gnode; - float mx=0, my=0; + float mx = 0, my = 0; // XXX int mval[2]; - gnode= node_tree_get_editgroup(snode->nodetree); - if (gnode==NULL) return 0; + gnode = node_tree_get_editgroup(snode->nodetree); + if (gnode == NULL) return 0; // XXX getmouseco_areawin(mval); // XXX areamouseco_to_ipoco(G.v2d, mval, &mx, &my); /* click in header or outside? */ - if (BLI_in_rctf(&gnode->totr, mx, my)==0) { - rctf rect= gnode->totr; + if (BLI_in_rctf(&gnode->totr, mx, my) == 0) { + rctf rect = gnode->totr; rect.ymax += NODE_DY; - if (BLI_in_rctf(&rect, mx, my)==0) - snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ + if (BLI_in_rctf(&rect, mx, my) == 0) + snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ // else // XXX transform_nodes(snode->nodetree, 'g', "Move group"); @@ -2222,36 +2231,36 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so bNodeSocket *sock; rctf rect; - *nodep= NULL; - *sockp= NULL; + *nodep = NULL; + *sockp = NULL; /* check if we click in a socket */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { - rect.xmin = snode->mx - (NODE_SOCKSIZE+4); - rect.ymin = snode->my - (NODE_SOCKSIZE+4); - rect.xmax = snode->mx + (NODE_SOCKSIZE+4); - rect.ymax = snode->my + (NODE_SOCKSIZE+4); + rect.xmin = snode->mx - (NODE_SOCKSIZE + 4); + rect.ymin = snode->my - (NODE_SOCKSIZE + 4); + rect.xmax = snode->mx + (NODE_SOCKSIZE + 4); + rect.ymax = snode->my + (NODE_SOCKSIZE + 4); if (!(node->flag & NODE_HIDDEN)) { /* extra padding inside and out - allow dragging on the text areas too */ if (in_out == SOCK_IN) { rect.xmax += NODE_SOCKSIZE; - rect.xmin -= NODE_SOCKSIZE*4; + rect.xmin -= NODE_SOCKSIZE * 4; } else if (in_out == SOCK_OUT) { - rect.xmax += NODE_SOCKSIZE*4; + rect.xmax += NODE_SOCKSIZE * 4; rect.xmin -= NODE_SOCKSIZE; } } if (in_out & SOCK_IN) { - for (sock= node->inputs.first; sock; sock= sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { - *nodep= node; - *sockp= sock; + *nodep = node; + *sockp = sock; return 1; } } @@ -2259,12 +2268,12 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } if (in_out & SOCK_OUT) { - for (sock= node->outputs.first; sock; sock= sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { - *nodep= node; - *sockp= sock; + *nodep = node; + *sockp = sock; return 1; } } @@ -2277,22 +2286,22 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so * NB: using ngroup->outputs as input sockets and vice versa here! */ if (in_out & SOCK_IN) { - for (sock= snode->edittree->outputs.first; sock; sock= sock->next) { + for (sock = snode->edittree->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { - *nodep= NULL; /* NULL node pointer indicates group socket */ - *sockp= sock; + *nodep = NULL; /* NULL node pointer indicates group socket */ + *sockp = sock; return 1; } } } } if (in_out & SOCK_OUT) { - for (sock= snode->edittree->inputs.first; sock; sock= sock->next) { + for (sock = snode->edittree->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { - *nodep= NULL; /* NULL node pointer indicates group socket */ - *sockp= sock; + *nodep = NULL; /* NULL node pointer indicates group socket */ + *sockp = sock; return 1; } } @@ -2304,7 +2313,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so static int outside_group_rect(SpaceNode *snode) { - bNode *gnode= node_tree_get_editgroup(snode->nodetree); + bNode *gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) { return (snode->mx < gnode->totr.xmin || snode->mx >= gnode->totr.xmax || @@ -2351,7 +2360,7 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke bNodeSocket *sock; /* first look for selected output */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; @@ -2360,19 +2369,19 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke } /* try to find a socket with a matching name */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; /* check for same types */ if (sock->type == sock_target->type) { - if (strcmp(sock->name, sock_target->name)==0) + if (strcmp(sock->name, sock_target->name) == 0) return sock; } } /* otherwise settle for the first available socket of the right type */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; @@ -2391,16 +2400,16 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, int replace) { bNodeSocket *sock; - int socktype, maxtype=0; + int socktype, maxtype = 0; int a = 0; - for (sock=node->inputs.first; sock; sock=sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { maxtype = MAX2(sock->type, maxtype); } /* find sockets of higher 'types' first (i.e. image) */ - for (socktype=maxtype; socktype >= 0; socktype--) { - for (sock=node->inputs.first; sock; sock=sock->next) { + for (socktype = maxtype; socktype >= 0; socktype--) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, replace)) { a++; @@ -2447,9 +2456,9 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list"); bNodeListItem *nli; bNode *node; - int i, numlinks=0; + int i, numlinks = 0; - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item"); nli->node = node; @@ -2460,7 +2469,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* sort nodes left to right */ BLI_sortlist(nodelist, sort_nodes_locx); - for (nli=nodelist->first; nli; nli=nli->next) { + for (nli = nodelist->first; nli; nli = nli->next) { bNode *node_fr, *node_to; bNodeSocket *sock_fr, *sock_to; int has_selected_inputs = 0; @@ -2471,7 +2480,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) node_to = nli->next->node; /* if there are selected sockets, connect those */ - for (sock_to = node_to->inputs.first; sock_to; sock_to=sock_to->next) { + for (sock_to = node_to->inputs.first; sock_to; sock_to = sock_to->next) { if (sock_to->flag & SELECT) { has_selected_inputs = 1; @@ -2492,7 +2501,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* no selected inputs, connect by finding suitable match */ int num_inputs = BLI_countlist(&node_to->inputs); - for (i=0; i<num_inputs; i++) { + for (i = 0; i < num_inputs; i++) { /* find the best guess input socket */ sock_to = best_socket_input(ntree, node_to, i, replace); @@ -2523,7 +2532,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* can be called from menus too, but they should do own undopush and redraws */ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate *ntemp, float locx, float locy) { - bNode *node= NULL, *gnode; + bNode *node = NULL, *gnode; node_deselect_all(snode); @@ -2531,11 +2540,11 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate /* generics */ if (node) { - node->locx= locx; - node->locy= locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node + node->locx = locx; + node->locy = locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node node_select(node); - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) { node->locx -= gnode->locx; node->locy -= gnode->locy; @@ -2544,7 +2553,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate ntreeUpdateTree(snode->edittree); ED_node_set_active(bmain, snode->edittree, node); - if (snode->nodetree->type==NTREE_COMPOSIT) { + if (snode->nodetree->type == NTREE_COMPOSIT) { if (ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) { node->id = &scene->id; } @@ -2561,7 +2570,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate snode_update(snode, node); } - if (snode->nodetree->type==NTREE_TEXTURE) { + if (snode->nodetree->type == NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); } @@ -2577,7 +2586,7 @@ static void node_duplicate_reparent_recursive(bNode *node) node->flag |= NODE_TEST; /* find first selected parent */ - for (parent=node->parent; parent; parent=parent->parent) { + for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { if (!(parent->flag & NODE_TEST)) node_duplicate_reparent_recursive(parent); @@ -2593,8 +2602,8 @@ static void node_duplicate_reparent_recursive(bNode *node) static int node_duplicate_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeTree *ntree= snode->edittree; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeTree *ntree = snode->edittree; bNode *node, *newnode, *lastnode; bNodeLink *link, *newlink, *lastlink; int keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs"); @@ -2602,7 +2611,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); lastnode = ntree->nodes.last; - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); @@ -2616,7 +2625,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node==lastnode) + if (node == lastnode) break; } @@ -2624,7 +2633,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) * NB: this depends on correct node->new_node and sock->new_sock pointers from above copy! */ lastlink = ntree->links.last; - for (link=ntree->links.first; link; link=link->next) { + for (link = ntree->links.first; link; link = link->next) { /* This creates new links between copied nodes. * If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)! */ @@ -2649,25 +2658,25 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new links again! */ - if (link==lastlink) + if (link == lastlink) break; } /* clear flags for recursive depth-first iteration */ - for (node= ntree->nodes.first; node; node= node->next) + for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; /* reparent copied nodes */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) node_duplicate_reparent_recursive(node); /* only has to check old nodes */ - if (node==lastnode) + if (node == lastnode) break; } /* deselect old nodes, select the copies instead */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; @@ -2678,7 +2687,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node==lastnode) + if (node == lastnode) break; } @@ -2702,7 +2711,7 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes"); } @@ -2716,21 +2725,21 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) { - for (tlink= snode->edittree->links.first; tlink; tlink= tlink->next) { - if (link!=tlink && tlink->tosock==link->tosock) + for (tlink = snode->edittree->links.first; tlink; tlink = tlink->next) { + if (link != tlink && tlink->tosock == link->tosock) break; } if (tlink) { /* try to move the existing link to the next available socket */ if (tlink->tonode) { /* is there a free input socket with the target type? */ - for (sock= tlink->tonode->inputs.first; sock; sock= sock->next) { - if (sock->type==tlink->tosock->type) + for (sock = tlink->tonode->inputs.first; sock; sock = sock->next) { + if (sock->type == tlink->tosock->type) if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit) break; } if (sock) { - tlink->tosock= sock; + tlink->tosock = sock; sock->flag &= ~SOCK_HIDDEN; } else { @@ -2749,12 +2758,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL /* in_out = starting socket */ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNodeLinkDrag *nldrag= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNodeLinkDrag *nldrag = op->customdata; bNodeTree *ntree = snode->edittree; bNode *tnode; - bNodeSocket *tsock= NULL; + bNodeSocket *tsock = NULL; bNodeLink *link; LinkData *linkdata; int in_out; @@ -2762,14 +2771,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) in_out = nldrag->in_out; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); switch (event->type) { case MOUSEMOVE: - if (in_out==SOCK_OUT) { + if (in_out == SOCK_OUT) { if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_IN)) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; /* skip if this is already the target socket */ @@ -2792,14 +2801,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { int do_update = FALSE; - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->tonode || link->tosock) { BLI_remlink(&ntree->links, link); link->prev = link->next = NULL; - link->tonode= NULL; - link->tosock= NULL; + link->tonode = NULL; + link->tosock = NULL; ntree->update |= NTREE_UPDATE_LINKS; do_update = TRUE; @@ -2812,7 +2821,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_OUT)) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; /* skip if this is already the target socket */ @@ -2835,14 +2844,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { int do_update = FALSE; - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->fromnode || link->fromsock) { BLI_remlink(&ntree->links, link); link->prev = link->next = NULL; - link->fromnode= NULL; - link->fromsock= NULL; + link->fromnode = NULL; + link->fromsock = NULL; ntree->update |= NTREE_UPDATE_LINKS; do_update = TRUE; @@ -2860,7 +2869,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->tosock && link->fromsock) { @@ -2869,7 +2878,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) snode_update(snode, link->tonode); /* we might need to remove a link */ - if (in_out==SOCK_OUT) + if (in_out == SOCK_OUT) node_remove_extra_links(snode, link->tosock, link); /* when linking to group outputs, update the socket type */ @@ -2930,16 +2939,16 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) /* output indicated? */ if (node_find_indicated_socket(snode, &node, &sock, SOCK_OUT)) { - nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); + nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); num_links = nodeCountSocketLinks(snode->edittree, sock); if (num_links > 0 && (num_links >= sock->limit || detach)) { /* dragged links are fixed on input side */ nldrag->in_out = SOCK_IN; /* detach current links and store them in the operator data */ - for (link= snode->edittree->links.first; link; link= link_next) { + for (link = snode->edittree->links.first; link; link = link_next) { link_next = link->next; - if (link->fromsock==sock) { + if (link->fromsock == sock) { linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data"); linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link"); *oplink = *link; @@ -2962,16 +2971,16 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) } /* or an input? */ else if (node_find_indicated_socket(snode, &node, &sock, SOCK_IN)) { - nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); + nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); num_links = nodeCountSocketLinks(snode->edittree, sock); if (num_links > 0 && (num_links >= sock->limit || detach)) { /* dragged links are fixed on output side */ nldrag->in_out = SOCK_OUT; /* detach current links and store them in the operator data */ - for (link= snode->edittree->links.first; link; link= link_next) { + for (link = snode->edittree->links.first; link; link = link_next) { link_next = link->next; - if (link->tosock==sock) { + if (link->tosock == sock) { linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data"); linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link"); *oplink = *link; @@ -3002,20 +3011,20 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); bNodeLinkDrag *nldrag; int detach = RNA_boolean_get(op->ptr, "detach"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); ED_preview_kill_jobs(C); nldrag = node_link_init(snode, detach); if (nldrag) { - op->customdata= nldrag; + op->customdata = nldrag; BLI_addtail(&snode->linkdrag, nldrag); /* add modal handler */ @@ -3024,13 +3033,13 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } else - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static int node_link_cancel(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeLinkDrag *nldrag= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeLinkDrag *nldrag = op->customdata; BLI_remlink(&snode->linkdrag, nldrag); @@ -3055,7 +3064,7 @@ void NODE_OT_link(wmOperatorType *ot) ot->cancel = node_link_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_boolean(ot->srna, "detach", FALSE, "Detach", "Detach and redirect existing links"); } @@ -3065,7 +3074,7 @@ void NODE_OT_link(wmOperatorType *ot) /* makes a link between selected output and input sockets */ static int node_make_link_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); int replace = RNA_boolean_get(op->ptr, "replace"); ED_preview_kill_jobs(C); @@ -3095,7 +3104,7 @@ void NODE_OT_link_make(wmOperatorType *ot) ot->poll = ED_operator_node_active; // XXX we need a special poll which checks that there are selected input/output sockets /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "replace", 0, "Replace", "Replace socket connections with the new links"); } @@ -3104,16 +3113,16 @@ void NODE_OT_link_make(wmOperatorType *ot) #define LINK_RESOL 12 static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int tot, float result[2]) { - float coord_array[LINK_RESOL+1][2]; + float coord_array[LINK_RESOL + 1][2]; int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for (i=0; i<tot-1; i++) - for (b=0; b<LINK_RESOL; b++) - if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) { - result[0] = (mcoords[i][0]+mcoords[i+1][0])/2.0f; - result[1] = (mcoords[i][1]+mcoords[i+1][1])/2.0f; + for (i = 0; i < tot - 1; i++) + for (b = 0; b < LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { + result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f; + result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f; return 1; } } @@ -3122,29 +3131,30 @@ static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int static int add_reroute_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; - RNA_BEGIN(op->ptr, itemptr, "path") { + RNA_BEGIN(op->ptr, itemptr, "path") + { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1], - &mcoords[i][0], &mcoords[i][1]); + &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; - if (i>1) { + if (i > 1) { bNodeLink *link; float insertPoint[2]; ED_preview_kill_jobs(C); - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (add_reroute_intersect_check(link, mcoords, i, insertPoint)) { bNodeTemplate ntemp; bNode *rerouteNode; @@ -3171,27 +3181,27 @@ static int add_reroute_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } void NODE_OT_add_reroute(wmOperatorType *ot) { PropertyRNA *prop; - ot->name= "Add reroute"; - ot->idname= "NODE_OT_add_reroute"; + ot->name = "Add reroute"; + ot->idname = "NODE_OT_add_reroute"; - ot->invoke= WM_gesture_lines_invoke; - ot->modal= WM_gesture_lines_modal; - ot->exec= add_reroute_exec; - ot->cancel= WM_gesture_lines_cancel; + ot->invoke = WM_gesture_lines_invoke; + ot->modal = WM_gesture_lines_modal; + ot->exec = add_reroute_exec; + ot->cancel = WM_gesture_lines_cancel; - ot->poll= ED_operator_node_active; + ot->poll = ED_operator_node_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_CROSSCURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); @@ -3201,14 +3211,14 @@ void NODE_OT_add_reroute(wmOperatorType *ot) /* ********************** Cut Link operator ***************** */ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) { - float coord_array[LINK_RESOL+1][2]; + float coord_array[LINK_RESOL + 1][2]; int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for (i=0; i<tot-1; i++) - for (b=0; b<LINK_RESOL; b++) - if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) + for (i = 0; i < tot - 1; i++) + for (b = 0; b < LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) return 1; } return 0; @@ -3216,30 +3226,30 @@ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) static int cut_links_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; - RNA_BEGIN (op->ptr, itemptr, "path") + RNA_BEGIN(op->ptr, itemptr, "path") { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1], - &mcoords[i][0], &mcoords[i][1]); + &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; - if (i>1) { + if (i > 1) { bNodeLink *link, *next; ED_preview_kill_jobs(C); - for (link= snode->edittree->links.first; link; link= next) { - next= link->next; + for (link = snode->edittree->links.first; link; link = next) { + next = link->next; if (cut_links_intersect(link, mcoords, i)) { snode_update(snode, link->tonode); @@ -3254,7 +3264,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } void NODE_OT_links_cut(wmOperatorType *ot) @@ -3273,9 +3283,9 @@ void NODE_OT_links_cut(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); @@ -3285,13 +3295,13 @@ void NODE_OT_links_cut(wmOperatorType *ot) static int detach_links_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeTree *ntree= snode->edittree; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeTree *ntree = snode->edittree; bNode *node; ED_preview_kill_jobs(C); - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { nodeInternalRelink(ntree, node); } @@ -3315,7 +3325,7 @@ void NODE_OT_links_detach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************* automatic node insert on dragging ******************* */ @@ -3324,25 +3334,25 @@ void NODE_OT_links_detach(wmOperatorType *ot) static bNodeSocket *socket_best_match(ListBase *sockets) { bNodeSocket *sock; - int type, maxtype=0; + int type, maxtype = 0; /* find type range */ - for (sock=sockets->first; sock; sock=sock->next) + for (sock = sockets->first; sock; sock = sock->next) maxtype = MAX2(sock->type, maxtype); /* try all types, starting from 'highest' (i.e. colors, vectors, values) */ - for (type=maxtype; type >= 0; --type) { - for (sock= sockets->first; sock; sock= sock->next) { - if (!nodeSocketIsHidden(sock) && type==sock->type) { + for (type = maxtype; type >= 0; --type) { + for (sock = sockets->first; sock; sock = sock->next) { + if (!nodeSocketIsHidden(sock) && type == sock->type) { return sock; } } } /* no visible sockets, unhide first of highest type */ - for (type=maxtype; type >= 0; --type) { - for (sock= sockets->first; sock; sock= sock->next) { - if (type==sock->type) { + for (type = maxtype; type >= 0; --type) { + for (sock = sockets->first; sock; sock = sock->next) { + if (type == sock->type) { sock->flag &= ~SOCK_HIDDEN; return sock; } @@ -3355,31 +3365,31 @@ static bNodeSocket *socket_best_match(ListBase *sockets) /* prevent duplicate testing code below */ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) { - SpaceNode *snode= sa?sa->spacedata.first:NULL; + SpaceNode *snode = sa ? sa->spacedata.first : NULL; bNode *node; bNodeLink *link; /* no unlucky accidents */ - if (sa==NULL || sa->spacetype!=SPACE_NODE) return NULL; + if (sa == NULL || sa->spacetype != SPACE_NODE) return NULL; - *select= NULL; + *select = NULL; - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (*select) break; else - *select= node; + *select = node; } } /* only one selected */ - if (node || *select==NULL) return NULL; + if (node || *select == NULL) return NULL; /* correct node */ - if ((*select)->inputs.first==NULL || (*select)->outputs.first==NULL) return NULL; + if ((*select)->inputs.first == NULL || (*select)->outputs.first == NULL) return NULL; /* test node for links */ - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (link->tonode == *select || link->fromnode == *select) return NULL; } @@ -3391,27 +3401,27 @@ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) void ED_node_link_insert(ScrArea *sa) { bNode *node, *select; - SpaceNode *snode= ed_node_link_conditions(sa, &select); + SpaceNode *snode = ed_node_link_conditions(sa, &select); bNodeLink *link; bNodeSocket *sockto; - if (snode==NULL) return; + if (snode == NULL) return; /* get the link */ - for (link= snode->edittree->links.first; link; link=link->next) + for (link = snode->edittree->links.first; link; link = link->next) if (link->flag & NODE_LINKFLAG_HILITE) break; if (link) { - node= link->tonode; - sockto= link->tosock; + node = link->tonode; + sockto = link->tosock; - link->tonode= select; - link->tosock= socket_best_match(&select->inputs); + link->tonode = select; + link->tosock = socket_best_match(&select->inputs); link->flag &= ~NODE_LINKFLAG_HILITE; nodeAddLink(snode->edittree, select, socket_best_match(&select->outputs), node, sockto); - ntreeUpdateTree(snode->edittree); /* needed for pointers */ + ntreeUpdateTree(snode->edittree); /* needed for pointers */ snode_update(snode, select); ED_node_changed_update(snode->id, select); } @@ -3422,44 +3432,44 @@ void ED_node_link_insert(ScrArea *sa) void ED_node_link_intersect_test(ScrArea *sa, int test) { bNode *select; - SpaceNode *snode= ed_node_link_conditions(sa, &select); - bNodeLink *link, *selink=NULL; + SpaceNode *snode = ed_node_link_conditions(sa, &select); + bNodeLink *link, *selink = NULL; float mcoords[6][2]; - if (snode==NULL) return; + if (snode == NULL) return; /* clear flags */ - for (link= snode->edittree->links.first; link; link=link->next) + for (link = snode->edittree->links.first; link; link = link->next) link->flag &= ~NODE_LINKFLAG_HILITE; - if (test==0) return; + if (test == 0) return; /* okay, there's 1 node, without links, now intersect */ - mcoords[0][0]= select->totr.xmin; - mcoords[0][1]= select->totr.ymin; - mcoords[1][0]= select->totr.xmax; - mcoords[1][1]= select->totr.ymin; - mcoords[2][0]= select->totr.xmax; - mcoords[2][1]= select->totr.ymax; - mcoords[3][0]= select->totr.xmin; - mcoords[3][1]= select->totr.ymax; - mcoords[4][0]= select->totr.xmin; - mcoords[4][1]= select->totr.ymin; - mcoords[5][0]= select->totr.xmax; - mcoords[5][1]= select->totr.ymax; + mcoords[0][0] = select->totr.xmin; + mcoords[0][1] = select->totr.ymin; + mcoords[1][0] = select->totr.xmax; + mcoords[1][1] = select->totr.ymin; + mcoords[2][0] = select->totr.xmax; + mcoords[2][1] = select->totr.ymax; + mcoords[3][0] = select->totr.xmin; + mcoords[3][1] = select->totr.ymax; + mcoords[4][0] = select->totr.xmin; + mcoords[4][1] = select->totr.ymin; + mcoords[5][0] = select->totr.xmax; + mcoords[5][1] = select->totr.ymax; /* we only tag a single link for intersect now */ /* idea; use header dist when more? */ - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (cut_links_intersect(link, mcoords, 5)) { /* intersect code wants edges */ if (selink) break; - selink= link; + selink = link; } } - if (link==NULL && selink) + if (link == NULL && selink) selink->flag |= NODE_LINKFLAG_HILITE; } @@ -3471,20 +3481,20 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) /* goes over all scenes, reads render layers */ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *curscene= CTX_data_scene(C), *scene; + Main *bmain = CTX_data_main(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *curscene = CTX_data_scene(C), *scene; bNode *node; ED_preview_kill_jobs(C); /* first tag scenes unread */ - for (scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene = bmain->scene.first; scene; scene = scene->id.next) scene->id.flag |= LIB_DOIT; - for (node= snode->edittree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_R_LAYERS) { - ID *id= node->id; + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_R_LAYERS) { + ID *id = node->id; if (id->flag & LIB_DOIT) { RE_ReadRenderResult(curscene, (Scene *)id); ntreeCompositTagRender((Scene *)id); @@ -3516,10 +3526,10 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - SpaceNode *snode= CTX_wm_space_node(C); - Scene *curscene= CTX_data_scene(C); - Render *re= RE_NewRender(curscene->id.name); + Main *bmain = CTX_data_main(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *curscene = CTX_data_scene(C); + Render *re = RE_NewRender(curscene->id.name); WM_cursor_wait(1); RE_MergeFullSample(re, bmain, curscene, snode->nodetree); @@ -3527,7 +3537,7 @@ static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) /* note we are careful to send the right notifier, as otherwise the * compositor would reexecute and overwrite the full sample result */ - WM_event_add_notifier(C, NC_SCENE|ND_COMPO_RESULT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_COMPO_RESULT, NULL); return OPERATOR_FINISHED; } @@ -3550,23 +3560,23 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *sce= CTX_data_scene(C); + Scene *sce = CTX_data_scene(C); bNode *node; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)sce && node->need_exec) { + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)sce && node->need_exec) { break; } } if (node) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl) { PointerRNA op_ptr; WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); RNA_string_set(&op_ptr, "layer", srl->name); - RNA_string_set(&op_ptr, "scene", sce->id.name+2); + RNA_string_set(&op_ptr, "scene", sce->id.name + 2); /* to keep keypositions */ sce->r.scemode |= R_NO_FRAME_UPDATE; @@ -3607,35 +3617,35 @@ static int node_group_make_test(bNodeTree *ntree, bNode *gnode) int totnode = 0; /* is there something to group? also do some clearing */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { /* no groups in groups */ - if (node->type==NODE_GROUP) + if (node->type == NODE_GROUP) return 0; totnode++; } node->done = 0; } - if (totnode==0) return 0; + if (totnode == 0) return 0; /* check if all connections are OK, no unselected node has both * inputs and outputs to a selection */ - for (link= ntree->links.first; link; link= link->next) { + for (link = ntree->links.first; link; link = link->next) { if (link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT && link->fromnode != gnode) link->tonode->done |= 1; if (link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT && link->tonode != gnode) link->fromnode->done |= 2; } - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; - if ((node->flag & NODE_SELECT)==0) - if (node->done==3) + if ((node->flag & NODE_SELECT) == 0) + if (node->done == 3) break; } if (node) @@ -3648,7 +3658,7 @@ static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, { bNode *node; INIT_MINMAX2(min, max); - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { @@ -3667,14 +3677,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) float min[2], max[2]; /* deselect all nodes in the target tree */ - for (node = ngroup->nodes.first; node; node=node->next) + for (node = ngroup->nodes.first; node; node = node->next) node_deselect(node); node_get_selected_minmax(ntree, gnode, min, max); /* move nodes over */ - for (node= ntree->nodes.first; node; node= nextn) { - nextn= node->next; + for (node = ntree->nodes.first; node; node = nextn) { + nextn = node->next; if (node == gnode) continue; if (node->flag & NODE_SELECT) { @@ -3700,14 +3710,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); - node->locx-= 0.5f*(min[0]+max[0]); - node->locy-= 0.5f*(min[1]+max[1]); + node->locx -= 0.5f * (min[0] + max[0]); + node->locy -= 0.5f * (min[1] + max[1]); } } /* move animation data over */ if (ntree->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); @@ -3724,10 +3734,10 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) ntreeFreeCache(ngroup); /* relink external sockets */ - for (link= ntree->links.first; link; link= linkn) { + for (link = ntree->links.first; link; link = linkn) { int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT) && link->fromnode != gnode); int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT) && link->tonode != gnode); - linkn= link->next; + linkn = link->next; if (gnode && ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode))) { /* remove all links to/from the gnode. @@ -3747,8 +3757,8 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) } else if (fromselect) { /* search for existing group node socket */ - for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) - if (gsock->link && gsock->link->fromsock==link->fromsock) + for (gsock = ngroup->outputs.first; gsock; gsock = gsock->next) + if (gsock->link && gsock->link->fromsock == link->fromsock) break; if (!gsock) { gsock = node_group_expose_socket(ngroup, link->fromsock, SOCK_OUT); @@ -3779,14 +3789,14 @@ static bNode *node_group_make_from_selected(bNodeTree *ntree) node_get_selected_minmax(ntree, NULL, min, max); /* new nodetree */ - ngroup= ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); + ngroup = ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); /* make group node */ ntemp.type = NODE_GROUP; ntemp.ngroup = ngroup; - gnode= nodeAddNode(ntree, &ntemp); - gnode->locx= 0.5f*(min[0]+max[0]); - gnode->locy= 0.5f*(min[1]+max[1]); + gnode = nodeAddNode(ntree, &ntemp); + gnode->locx = 0.5f * (min[0] + max[0]); + gnode->locy = 0.5f * (min[1] + max[1]); node_group_make_insert_selected(ntree, gnode); @@ -3814,16 +3824,16 @@ static int node_group_make_exec(bContext *C, wmOperator *op) bNode *gnode; int type = RNA_enum_get(op->ptr, "type"); - if (snode->edittree!=snode->nodetree) { + if (snode->edittree != snode->nodetree) { BKE_report(op->reports, RPT_WARNING, "Can not add a new Group in a Group"); return OPERATOR_CANCELLED; } /* for time being... is too complex to handle */ - if (snode->treetype==NTREE_COMPOSIT) { - for (gnode=snode->nodetree->nodes.first; gnode; gnode= gnode->next) { + if (snode->treetype == NTREE_COMPOSIT) { + for (gnode = snode->nodetree->nodes.first; gnode; gnode = gnode->next) { if (gnode->flag & SELECT) - if (gnode->type==CMP_NODE_R_LAYERS) + if (gnode->type == CMP_NODE_R_LAYERS) break; } @@ -3836,29 +3846,29 @@ static int node_group_make_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); switch (type) { - case NODE_GM_NEW: - if (node_group_make_test(snode->nodetree, NULL)) { - gnode = node_group_make_from_selected(snode->nodetree); - } - else { - BKE_report(op->reports, RPT_WARNING, "Can not make Group"); - return OPERATOR_CANCELLED; - } - break; - case NODE_GM_INSERT: - gnode = nodeGetActive(snode->nodetree); - if (!gnode || gnode->type != NODE_GROUP) { - BKE_report(op->reports, RPT_WARNING, "No active Group node"); - return OPERATOR_CANCELLED; - } - if (node_group_make_test(snode->nodetree, gnode)) { - node_group_make_insert_selected(snode->nodetree, gnode); - } - else { - BKE_report(op->reports, RPT_WARNING, "Can not insert into Group"); - return OPERATOR_CANCELLED; - } - break; + case NODE_GM_NEW: + if (node_group_make_test(snode->nodetree, NULL)) { + gnode = node_group_make_from_selected(snode->nodetree); + } + else { + BKE_report(op->reports, RPT_WARNING, "Can not make Group"); + return OPERATOR_CANCELLED; + } + break; + case NODE_GM_INSERT: + gnode = nodeGetActive(snode->nodetree); + if (!gnode || gnode->type != NODE_GROUP) { + BKE_report(op->reports, RPT_WARNING, "No active Group node"); + return OPERATOR_CANCELLED; + } + if (node_group_make_test(snode->nodetree, gnode)) { + node_group_make_insert_selected(snode->nodetree, gnode); + } + else { + BKE_report(op->reports, RPT_WARNING, "Can not insert into Group"); + return OPERATOR_CANCELLED; + } + break; } if (gnode) { @@ -3909,7 +3919,7 @@ void NODE_OT_group_make(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", node_group_make_types, NODE_GM_NEW, "Type", ""); } @@ -3919,18 +3929,18 @@ void NODE_OT_group_make(wmOperatorType *ot) static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) { bNode *node; - int tot_eq= 0, tot_neq= 0; + int tot_eq = 0, tot_neq = 0; /* Toggles the flag on all selected nodes. * If the flag is set on all nodes it is unset. * If the flag is not set on all nodes, it is set. */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) + if (toggle_flag == NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS) == 0) continue; if (node->flag & toggle_flag) @@ -3939,15 +3949,15 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) tot_neq++; } } - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) + if (toggle_flag == NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS) == 0) continue; - if ( (tot_eq && tot_neq) || tot_eq==0) + if ( (tot_eq && tot_neq) || tot_eq == 0) node->flag |= toggle_flag; else node->flag &= ~toggle_flag; @@ -3957,7 +3967,7 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -3982,12 +3992,12 @@ void NODE_OT_hide_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -4014,12 +4024,12 @@ void NODE_OT_preview_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -4044,12 +4054,12 @@ void NODE_OT_options_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; int hidden; @@ -4061,16 +4071,16 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) /* Toggle for all selected nodes */ hidden = 0; - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (node_has_hidden_sockets(node)) { - hidden= 1; + hidden = 1; break; } } } - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, !hidden); } @@ -4095,19 +4105,19 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Mute operator *********************** */ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { /* Only allow muting of nodes having a mute func! */ if ((node->flag & SELECT) && node->typeinfo->internal_connect) { node->flag ^= NODE_MUTED; @@ -4133,20 +4143,20 @@ void NODE_OT_mute_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Delete operator ******************* */ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node, *next; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= next) { - next= node->next; + for (node = snode->edittree->nodes.first; node; node = next) { + next = node->next; if (node->flag & SELECT) { /* check id user here, nodeFreeNode is called for free dbase too */ if (node->id) @@ -4175,19 +4185,19 @@ void NODE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Delete with reconnect ******************* */ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node, *next; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= next) { - next= node->next; + for (node = snode->edittree->nodes.first; node; node = next) { + next = node->next; if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); @@ -4218,14 +4228,14 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Show Cyclic Dependencies Operator ******************* */ static int node_show_cycles_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* this is just a wrapper around this call... */ ntreeUpdateTree(snode->nodetree); @@ -4246,18 +4256,18 @@ void NODE_OT_show_cyclic_dependencies(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Add File Node Operator ******************* */ static int node_add_file_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceNode *snode= CTX_wm_space_node(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - Image *ima= NULL; + Image *ima = NULL; bNodeTemplate ntemp; /* check input variables */ @@ -4265,9 +4275,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - errno= 0; + errno = 0; - ima= BKE_image_load_exists(path); + ima = BKE_image_load_exists(path); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); @@ -4275,9 +4285,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op) } } else if (RNA_struct_property_is_set(op->ptr, "name")) { - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)BKE_libblock_find_name(ID_IM, name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); @@ -4320,12 +4330,12 @@ static int node_add_file_exec(bContext *C, wmOperator *op) static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceNode *snode= CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) return node_add_file_exec(C, op); @@ -4346,10 +4356,10 @@ void NODE_OT_add_file(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path - RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign"); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Datablock name to assign"); } /********************** New node tree operator *********************/ @@ -4361,10 +4371,10 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) PointerRNA ptr, idptr; PropertyRNA *prop; int treetype; - char treename[MAX_ID_NAME-2] = "NodeTree"; + char treename[MAX_ID_NAME - 2] = "NodeTree"; /* retrieve state */ - snode= CTX_wm_space_node(C); + snode = CTX_wm_space_node(C); if (RNA_struct_property_is_set(op->ptr, "type")) treetype = RNA_enum_get(op->ptr, "type"); @@ -4391,7 +4401,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) RNA_property_update(C, &ptr, prop); } else if (snode) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); snode->nodetree = ntree; ED_node_tree_update(snode, scene); @@ -4412,18 +4422,18 @@ void NODE_OT_new_node_tree(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", nodetree_type_items, NTREE_COMPOSIT, "Tree Type", ""); - RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME-2, "Name", ""); + RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", ""); } /* ****************** File Output Add Socket ******************* */ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene = CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr; bNodeTree *ntree; bNode *node; @@ -4455,7 +4465,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "file_path", "Image", MAX_NAME, "File Path", "Sub-path of the output file"); } @@ -4464,7 +4474,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot) static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNodeTree *ntree; bNode *node; @@ -4494,14 +4504,14 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Multi File Output Move Socket ******************* */ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNode *node; NodeImageMultiFile *nimf; @@ -4519,7 +4529,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) direction = RNA_enum_get(op->ptr, "direction"); - if (direction==1) { + if (direction == 1) { bNodeSocket *before = sock->prev; if (!before) return OPERATOR_CANCELLED; @@ -4546,7 +4556,8 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) static EnumPropertyItem direction_items[] = { {1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, - { 0, NULL, 0, NULL, NULL }}; + { 0, NULL, 0, NULL, NULL } + }; /* identifiers */ ot->name = "Move File Node Socket"; @@ -4558,7 +4569,7 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", ""); } @@ -4577,7 +4588,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) if (!node) return OPERATOR_CANCELLED; - for (tnode=ntree->nodes.first; tnode; tnode=tnode->next) { + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { if (node->flag & NODE_CUSTOM_COLOR) { tnode->flag |= NODE_CUSTOM_COLOR; @@ -4589,7 +4600,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4606,7 +4617,7 @@ void NODE_OT_node_copy_color(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Set Parent ******************* */ @@ -4619,7 +4630,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (!frame || frame->type != NODE_FRAME) return OPERATOR_CANCELLED; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == frame) continue; if (node->flag & NODE_SELECT) { @@ -4629,7 +4640,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4646,7 +4657,7 @@ void NODE_OT_parent_set(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Clear Parent ******************* */ @@ -4657,13 +4668,13 @@ static int node_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTree *ntree = snode->edittree; bNode *node; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { nodeDetachNode(node); } } - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4680,14 +4691,14 @@ void NODE_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Join Nodes ******************* */ /* tags for depth-first search */ -#define NODE_JOIN_DONE 1 -#define NODE_JOIN_IS_DESCENDANT 2 +#define NODE_JOIN_DONE 1 +#define NODE_JOIN_IS_DESCENDANT 2 static void node_join_attach_recursive(bNode *node, bNode *frame) { @@ -4727,7 +4738,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTemplate ntemp; /* XXX save selection: node_add_node call below sets the new frame as single active+selected node */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) node->flag |= NODE_TEST; else @@ -4740,22 +4751,22 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) frame = node_add_node(snode, bmain, scene, &ntemp, 0.0f, 0.0f); /* reset tags */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->done = 0; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (!(node->done & NODE_JOIN_DONE)) node_join_attach_recursive(node, frame); } /* restore selection */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) node->flag |= NODE_SELECT; } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4772,7 +4783,7 @@ void NODE_OT_join(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Attach ******************* */ @@ -4784,7 +4795,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *frame; /* check nodes front to back */ - for (frame=ntree->nodes.last; frame; frame=frame->prev) { + for (frame = ntree->nodes.last; frame; frame = frame->prev) { /* skip selected, those are the nodes we want to attach */ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) continue; @@ -4793,7 +4804,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } if (frame) { bNode *node, *parent; - for (node=ntree->nodes.last; node; node=node->prev) { + for (node = ntree->nodes.last; node; node = node->prev) { if (node->flag & NODE_SELECT) { if (node->parent == NULL) { /* attach all unparented nodes */ @@ -4801,7 +4812,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } else { /* attach nodes which share parent with the frame */ - for (parent=frame->parent; parent; parent=parent->parent) + for (parent = frame->parent; parent; parent = parent->parent) if (parent == node->parent) break; if (parent) { @@ -4814,15 +4825,15 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } static int node_attach_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceNode *snode= CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); @@ -4843,14 +4854,14 @@ void NODE_OT_attach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Detach ******************* */ /* tags for depth-first search */ -#define NODE_DETACH_DONE 1 -#define NODE_DETACH_IS_DESCENDANT 2 +#define NODE_DETACH_DONE 1 +#define NODE_DETACH_IS_DESCENDANT 2 static void node_detach_recursive(bNode *node) { @@ -4883,18 +4894,18 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *node; /* reset tags */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->done = 0; /* detach nodes recursively * relative order is preserved here! */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (!(node->done & NODE_DETACH_DONE)) node_detach_recursive(node); } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4911,5 +4922,5 @@ void NODE_OT_detach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 0d03df2298f..d4cfa2a3ba2 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -239,7 +239,7 @@ static void node_menu_add(const bContext *C, Menu *menu) bNodeTreeType *ntreetype= ntreeGetType(snode->treetype); if (!snode->nodetree) - uiLayoutSetActive(layout, 0); + uiLayoutSetActive(layout, FALSE); if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, layout, node_menu_add_foreach_cb); diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 97e64c4acdf..bf0e539efe7 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -358,7 +358,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) continue; if (first) { - column= uiLayoutColumn(layout, 0); + column = uiLayoutColumn(layout, FALSE); uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); @@ -415,7 +415,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) continue; if (first) { - column= uiLayoutColumn(layout, 0); + column = uiLayoutColumn(layout, FALSE); uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); @@ -470,7 +470,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ bNodeTreeType *ntreetype= ntreeGetType(arg->ntree->type); uiBlockSetCurLayout(block, layout); - split= uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); arg->bmain= bmain; arg->scene= scene; @@ -479,7 +479,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); - column= uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); uiBlockSetCurLayout(block, column); if (sock->link) { @@ -547,9 +547,9 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b if (node->typeinfo->uifunc) { if (node->type != NODE_GROUP) { - split = uiLayoutSplit(layout, 0.35f, 0); - col = uiLayoutColumn(split, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); + col = uiLayoutColumn(split, FALSE); + col = uiLayoutColumn(split, FALSE); node->typeinfo->uifunc(col, C, &nodeptr); } @@ -590,9 +590,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name)); /* split in label and value */ - split = uiLayoutSplit(layout, 0.35f, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); if (depth > 0) { uiBlockSetEmboss(block, UI_EMBOSSN); @@ -615,7 +615,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bt->flag= UI_TEXT_LEFT; if (dependency_loop) { - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemL(row, IFACE_("Dependency Loop"), ICON_ERROR); } else if (lnode) { @@ -633,18 +633,18 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* input not linked, show value */ if (input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) { if (input->type == SOCK_VECTOR) { - row = uiLayoutRow(split, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(split, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, &inputptr, "default_value", 0, "", 0); } else { - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, &inputptr, "default_value", 0, "", 0); } } else - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiTemplateNodeLink(row, ntree, node, input); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f0ecaf3ab2c..2f5e32c61d1 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -202,26 +202,39 @@ static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; +#ifdef USE_GROUP_SELECT for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->restrictflag & flag) == 0) return 0; } - return 1; +#else + /* weak but fast */ + if ((gob = gr->gobject.first)) + if ((gob->ob->restrictflag & flag) == 0) + return 0; + return 1; +#endif } -#ifdef USE_GROUP_SELECT static int group_select_flag(Group *gr) { GroupObject *gob; +#ifdef USE_GROUP_SELECT for (gob = gr->gobject.first; gob; gob = gob->next) if ((gob->ob->flag & SELECT)) return 1; return 0; -} +#else + /* weak but fast */ + if ((gob = gr->gobject.first)) + if (gob->ob->flag & SELECT) + return 1; + return 0; #endif +} void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { @@ -428,25 +441,15 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); -#ifndef USE_GROUP_SELECT - restrict_bool = FALSE; -#endif - -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); @@ -1289,7 +1292,6 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } else if (te->idcode == ID_GR) { -#ifdef USE_GROUP_SELECT Group *gr = (Group *)tselem->id; if (group_select_flag(gr)) { char col[4]; @@ -1299,7 +1301,6 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene active = 2; } -#endif } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index e48450e93bd..9148373cb2d 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -72,8 +72,11 @@ #include "sequencer_intern.h" -#define SEQ_LEFTHANDLE 1 -#define SEQ_RIGHTHANDLE 2 +#define SEQ_LEFTHANDLE 1 +#define SEQ_RIGHTHANDLE 2 + +#define SEQ_HANDLE_SIZE_MIN 7.0f +#define SEQ_HANDLE_SIZE_MAX 40.0f /* Note, Don't use SEQ_BEGIN/SEQ_END while drawing! @@ -325,13 +328,19 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, glDisable(GL_BLEND); } +/* clamp handles to defined size in pixel space */ +static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx) +{ + const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN; + const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX; + return CLAMPIS(seq->handsize, minhandle, maxhandle); +} + /* draw a handle, for each end of a sequence strip */ -static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short direction) +static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, const short direction) { float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect float x1, x2, y1, y2; - float handsize; - float minhandle, maxhandle; char numstr[32]; unsigned int whichsel = 0; @@ -340,31 +349,25 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - - /* clamp handles to defined size in pixel space */ - handsize = seq->handsize; - minhandle = 7; - maxhandle = 40; - CLAMP(handsize, minhandle * pixelx, maxhandle * pixelx); - + /* set up co-ordinates/dimensions for either left or right handle */ if (direction == SEQ_LEFTHANDLE) { rx1 = x1; - rx2 = x1 + handsize * 0.75f; + rx2 = x1 + handsize_clamped * 0.75f; - v1[0] = x1 + handsize / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); - v2[0] = x1 + handsize / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); - v3[0] = v2[0] + handsize / 4; v3[1] = (y1 + y2) / 2.0f; + v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); + v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); + v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; whichsel = SEQ_LEFTSEL; } else if (direction == SEQ_RIGHTHANDLE) { - rx1 = x2 - handsize * 0.75f; + rx1 = x2 - handsize_clamped * 0.75f; rx2 = x2; - v1[0] = x2 - handsize / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); - v2[0] = x2 - handsize / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); - v3[0] = v2[0] - handsize / 4; v3[1] = (y1 + y2) / 2.0f; + v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); + v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); + v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; whichsel = SEQ_RIGHTSEL; } @@ -404,7 +407,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire } else { BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); - x1 = x2 - handsize * 0.75f; + x1 = x2 - handsize_clamped * 0.75f; y1 = y2 + 0.05f; } UI_view2d_text_cache_add(v2d, x1, y1, numstr, col); @@ -530,67 +533,67 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float name = give_seqname(seq); if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { - BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SCENE) { if (seq->scene) { if (seq->scene_camera) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s (%s)", - seq->len, name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d", + name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->scene->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->scene->id.name + 2, seq->len); } } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MOVIECLIP) { if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->clip->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->clip->id.name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MASK) { if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->mask->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->mask->id.name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MULTICAM) { - BLI_snprintf(str, sizeof(str), "Cam | %s: %d", + BLI_snprintf(str, sizeof(str), "Cam %s: %d", name, seq->multicam_source); } else if (seq->type == SEQ_TYPE_IMAGE) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", - seq->len, name, seq->strip->dir, seq->strip->stripdata->name); + BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", + name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } else if (seq->type & SEQ_TYPE_EFFECT) { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } else if (seq->type == SEQ_TYPE_SOUND_RAM) { if (seq->sound) - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->sound->name); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->sound->name, seq->len); else - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } else if (seq->type == SEQ_TYPE_MOVIE) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", - seq->len, name, seq->strip->dir, seq->strip->stripdata->name); + BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", + name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } if (seq->flag & SELECT) { @@ -679,6 +682,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline View2D *v2d = &ar->v2d; float x1, x2, y1, y2; unsigned char col[3], background_col[3], is_single_image; + const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx); /* we need to know if this is a single image/color or not for drawing */ is_single_image = (char)seq_single_check(seq); @@ -706,8 +710,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline if (!is_single_image) draw_seq_extensions(scene, ar, seq); - draw_seq_handle(v2d, seq, pixelx, SEQ_LEFTHANDLE); - draw_seq_handle(v2d, seq, pixelx, SEQ_RIGHTHANDLE); + draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE); + draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE); /* draw the strip outline */ x1 = seq->startdisp; @@ -766,8 +770,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline } /* calculate if seq is long enough to print a name */ - x1 = seq->startdisp + seq->handsize; - x2 = seq->enddisp - seq->handsize; + x1 = seq->startdisp + handsize_clamped; + x2 = seq->enddisp - handsize_clamped; /* info text on the strip */ if (x1 < v2d->cur.xmin) x1 = v2d->cur.xmin; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c686f8440a9..bc8133cded6 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1570,16 +1570,6 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } -static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - sequencer_add_duplicate_exec(C, op); - - RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); - WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); - - return OPERATOR_FINISHED; -} - void SEQUENCER_OT_duplicate(wmOperatorType *ot) { /* identifiers */ @@ -1588,7 +1578,6 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) ot->description = "Duplicate the selected strips"; /* api callbacks */ - ot->invoke = sequencer_add_duplicate_invoke; ot->exec = sequencer_add_duplicate_exec; ot->poll = ED_operator_sequencer_active; diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 79ecd9f7481..4a1c8f0c006 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -167,7 +167,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_offset_clear", OKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0); @@ -321,3 +321,13 @@ void sequencer_keymap(wmKeyConfig *keyconf) #endif } +void ED_operatormacros_sequencer(void) +{ + wmOperatorType *ot; + + ot = WM_operatortype_append_macro("SEQUENCER_OT_duplicate_move", "Duplicate Strips", + "Duplicate selected strips and move them", OPTYPE_UNDO | OPTYPE_REGISTER); + + WM_operatortype_macro_define(ot, "SEQUENCER_OT_duplicate"); + WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); +} diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 463a262c09c..8be5b644afb 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -825,7 +825,7 @@ typedef struct DrawCache { static void text_drawcache_init(SpaceText *st) { - DrawCache *drawcache = MEM_callocN(sizeof (DrawCache), "text draw cache"); + DrawCache *drawcache = MEM_callocN(sizeof(DrawCache), "text draw cache"); drawcache->winx = -1; drawcache->nlines = BLI_countlist(&st->text->lines); diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 43252111303..7d39a89a130 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -431,7 +431,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r } tend(); - // printf ( "Draw Time: %f\n",( float ) tval() ); + // printf ( "Draw Time: %f\n",(float) tval() ); if (tex_shadow) GPU_texture_unbind(tex_shadow); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 4a135f91d91..a9941dc326a 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -834,7 +834,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL); - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutAbsoluteBlock(col); uiBlockBeginAlign(block); @@ -865,7 +865,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *colsub; - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8f, FALSE); if (ptr->type == &RNA_PoseBone) { PointerRNA boneptr; @@ -875,19 +875,19 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) bone = boneptr.data; uiLayoutSetActive(split, !(bone->parent && bone->flag & BONE_CONNECTED)); } - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "location", 0, NULL, ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_location", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8f, FALSE); switch (RNA_enum_get(ptr, "rotation_mode")) { case ROT_MODE_QUAT: /* quaternion */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_quaternion", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -896,9 +896,9 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; case ROT_MODE_AXISANGLE: /* axis angle */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_axis_angle", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -907,19 +907,19 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; default: /* euler rotations */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_euler", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; } uiItemR(layout, ptr, "rotation_mode", 0, "", ICON_NONE); - split = uiLayoutSplit(layout, 0.8, 0); - colsub = uiLayoutColumn(split, 1); + split = uiLayoutSplit(layout, 0.8f, FALSE); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "scale", 0, NULL, ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_scale", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -948,7 +948,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &pchanptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); /* XXX: RNA buts show data in native types (i.e. quats, 4-component axis/angle, etc.) * but old-school UI shows in eulers always. Do we want to be able to still display in Eulers? @@ -972,7 +972,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &eboneptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &eboneptr, "head", 0, NULL, ICON_NONE); if (ebone->parent && ebone->flag & BONE_CONNECTED) { PointerRNA parptr = RNA_pointer_get(&eboneptr, "parent"); @@ -1002,7 +1002,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&mball->id, &RNA_MetaElement, mball->lastelem, &ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &ptr, "co", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "radius", 0, NULL, ICON_NONE); @@ -1010,7 +1010,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) uiItemR(col, &ptr, "type", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); switch (RNA_enum_get(&ptr, "type")) { case MB_BALL: break; @@ -1081,8 +1081,8 @@ static void view3d_panel_object(const bContext *C, Panel *pa) block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); - col = uiLayoutColumn(pa->layout, 0); - /* row = uiLayoutRow(col, 0); */ /* UNUSED */ + col = uiLayoutColumn(pa->layout, FALSE); + /* row = uiLayoutRow(col, FALSE); */ /* UNUSED */ RNA_id_pointer_create(&ob->id, &obptr); if (ob == obedit) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fcb4f97bcbe..709de274b8b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -153,12 +153,14 @@ static void view3d_draw_clipping(RegionView3D *rv3d) BoundBox *bb = rv3d->clipbb; if (bb) { - static unsigned int clipping_index[6][4] = {{0, 1, 2, 3}, - {0, 4, 5, 1}, - {4, 7, 6, 5}, - {7, 3, 2, 6}, - {1, 5, 6, 2}, - {7, 4, 0, 3}}; + static unsigned int clipping_index[6][4] = { + {0, 1, 2, 3}, + {0, 4, 5, 1}, + {4, 7, 6, 5}, + {7, 3, 2, 6}, + {1, 5, 6, 2}, + {7, 4, 0, 3} + }; /* fill in zero alpha for rendering & re-projection [#31530] */ unsigned char col[4]; @@ -1587,6 +1589,11 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, * be dereferenced after usage. */ freeibuf = ibuf; } + else { + /* perhaps when loading future files... */ + BLI_assert(0); + copy_v2_fl(image_aspect, 1.0f); + } if (ibuf == NULL) continue; @@ -2835,7 +2842,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw cliprct.xmax = CLAMPIS(cliprct.xmax, ar->winrct.xmin, ar->winrct.xmax); cliprct.ymax = CLAMPIS(cliprct.ymax, ar->winrct.ymin, ar->winrct.ymax); - if(cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { + if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index d632314f3ca..cc3d2d383b8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1669,7 +1669,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if (rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom = RV3D_CAMZOOM_MAX; } else if (rv3d->dist > 0.001f * v3d->grid) { - view_zoom_mouseloc(ar, .83333f, mx, my); + view_zoom_mouseloc(ar, 0.83333f, mx, my); } } @@ -1921,7 +1921,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 1.2f); } else { - view_dolly_mouseloc(ar, rv3d->ofs, mousevec, .83333f); + view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 0.83333f); } if (rv3d->viewlock & RV3D_BOXVIEW) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index a68caeb0719..eb202497260 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -451,7 +451,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) BMEditMesh *em = BMEdit_FromObject(obedit); uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select - Shift-Click for multiple modes"); uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select - Shift-Click for multiple modes"); @@ -494,7 +494,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) v3d->modeselect = OB_MODE_OBJECT; } - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene), 0, 0, 126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode")); @@ -512,7 +512,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } else { - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } @@ -521,7 +521,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) else { const char *str_menu; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* pose/object only however we want to allow in weight paint mode too @@ -531,7 +531,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* Transform widget / manipulators */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index ff896a95941..ee1ead76f7c 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -211,12 +211,12 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) for (ct = st->toolshelf.first; ct; ct = ct->next) { if (0 == strncmp(context, ct->context, OP_MAX_TYPENAME)) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0); } } } - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d32206c4335..e97df15543f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -183,11 +183,11 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) r_vec[2] = 0.0f; if (t->options & CTX_MOVIECLIP) { - ED_space_clip_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); } else if (t->options & CTX_MASK) { /* TODO - NOT WORKING, this isnt so bad since its only display aspect */ - ED_space_clip_mask_aspect(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); } r_vec[0] *= aspx; @@ -254,9 +254,9 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) copy_v2_v2(v, vec); if (t->options & CTX_MOVIECLIP) - ED_space_clip_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); else if (t->options & CTX_MASK) - ED_space_clip_mask_aspect(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); v[0] /= aspx; v[1] /= aspy; @@ -317,13 +317,13 @@ void applyAspectRatio(TransInfo *t, float vec[2]) if (t->options & CTX_MOVIECLIP) { - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); vec[0] /= aspx; vec[1] /= aspy; } else if (t->options & CTX_MASK) { - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); vec[0] /= aspx; vec[1] /= aspy; @@ -356,10 +356,10 @@ void removeAspectRatio(TransInfo *t, float vec[2]) float aspx = 1.0f, aspy = 1.0f; if (t->options & CTX_MOVIECLIP) { - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); } else if (t->options & CTX_MASK) { - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); } vec[0] *= aspx; @@ -410,16 +410,16 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) else if (t->spacetype == SPACE_CLIP) { SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first; - if (ED_space_clip_show_trackedit(sc)) { - MovieClip *clip = ED_space_clip(sc); + if (ED_space_clip_check_show_trackedit(sc)) { + MovieClip *clip = ED_space_clip_get_clip(sc); /* objects could be parented to tracking data, so send this for viewport refresh */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); } - else if (ED_space_clip_show_maskedit(sc)) { - Mask *mask = ED_space_clip_mask(sc); + else if (ED_space_clip_check_show_maskedit(sc)) { + Mask *mask = ED_space_clip_get_mask(sc); WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index fbc59f4c2cb..e924ce15286 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5046,7 +5046,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (t->spacetype == SPACE_CLIP) { if (t->options & CTX_MOVIECLIP) { SpaceClip *sc = t->sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, @@ -5057,7 +5057,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if (t->options & CTX_MASK) { SpaceClip *sc = t->sa->spacedata.first; - Mask *mask = ED_space_clip_mask(sc); + Mask *mask = ED_space_clip_get_mask(sc); if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, @@ -5653,7 +5653,7 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy) { - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr); tdt->flag = marker->flag; @@ -5702,12 +5702,12 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) TransData *td; TransData2D *td2d; SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker; TransDataTracking *tdt; - int framenr = ED_space_clip_clip_framenr(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); float aspx, aspy; /* count */ @@ -5736,7 +5736,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) if (t->total == 0) return; - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData"); td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D"); @@ -5830,7 +5830,7 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) TransData *td; TransData2D *td2d; SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker, *prev_marker; @@ -5908,7 +5908,7 @@ static void createTransTrackingData(bContext *C, TransInfo *t) { ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); int width, height; t->total = 0; @@ -5931,11 +5931,11 @@ static void cancelTransTracking(TransInfo *t) { TransDataTracking *tdt = t->customData; SpaceClip *sc = t->sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; MovieTrackingMarker *marker; - int a, framenr = ED_space_clip_clip_framenr(sc); + int a, framenr = ED_space_clip_get_clip_frame_number(sc); if (tdt->mode == transDataTracking_ModeTracks) { track = tracksbase->first; @@ -5992,7 +5992,7 @@ void flushTransTracking(TransInfo *t) int a; float aspx, aspy; - ED_space_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); if (t->state == TRANS_CANCEL) cancelTransTracking(t); @@ -6072,7 +6072,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, tdm->point = point; copy_m3_m3(tdm->vec, bezt->vec); - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); if (propmode || is_sel_point) { int i; @@ -6250,7 +6250,7 @@ void flushTransMasking(TransInfo *t) int a; float aspx, aspy, invx, invy; - ED_space_clip_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); invx = 1.0f / aspx; invy = 1.0f / aspy; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index b7857be5afb..9f335b4afe7 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -639,11 +639,11 @@ static void recalcData_spaceclip(TransInfo *t) { SpaceClip *sc = t->sa->spacedata.first; - if (ED_space_clip_show_trackedit(sc)) { - MovieClip *clip = ED_space_clip(sc); + if (ED_space_clip_check_show_trackedit(sc)) { + MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = sc->user.framenr; + int framenr = ED_space_clip_get_clip_frame_number(sc); flushTransTracking(t); @@ -675,8 +675,8 @@ static void recalcData_spaceclip(TransInfo *t) DAG_id_tag_update(&clip->id, 0); } - else if (ED_space_clip_show_maskedit(sc)) { - Mask *mask = ED_space_clip_mask(sc); + else if (ED_space_clip_check_show_maskedit(sc)) { + Mask *mask = ED_space_clip_get_mask(sc); flushTransMasking(t); @@ -1128,9 +1128,9 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->view = &ar->v2d; t->around = sclip->around; - if (ED_space_clip_show_trackedit(sclip)) + if (ED_space_clip_check_show_trackedit(sclip)) t->options |= CTX_MOVIECLIP; - else if (ED_space_clip_show_maskedit(sclip)) + else if (ED_space_clip_check_show_maskedit(sclip)) t->options |= CTX_MASK; } else { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 9ebd43cd0d1..90b67951614 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -221,7 +221,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) setlinestyle(0); cpack(0x0); fdrawline(-0.020 / w, 0, -0.1 / w, 0); - fdrawline(0.1 / w, 0, .020 / w, 0); + fdrawline(0.1 / w, 0, 0.020 / w, 0); fdrawline(0, -0.020 / h, 0, -0.1 / h); fdrawline(0, 0.1 / h, 0, 0.020 / h); diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 65d23641ab5..0c2bfff3b57 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -493,12 +493,13 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even if (totitem > 0) { uiPopupMenu *pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); uiLayout *layout = uiPupMenuLayout(pup); - uiLayout *split = uiLayoutSplit(layout, 0, 0), *column = NULL; + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = NULL; int i, c; for (c = 0, i = totitem - 1; i >= 0; i--, c++) { if ( (c % 20) == 0) - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); if (item[i].identifier) uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index a90f8253654..d52463cf406 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -467,7 +467,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* draw other uvs */ if (sima->flag & SI_DRAW_OTHER) { - Image *curimage = (activetf) ? activetf->tpage : NULL; + Image *curimage = (activetf) ? activetf->tpage : ima; draw_uvs_other(scene, obedit, curimage); } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a1bd8dcb3a3..4197e1a3edb 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -240,13 +240,14 @@ static struct GPUTextureState { /* Mipmap settings */ -void GPU_set_gpu_mipmapping(int gpu_mipmap){ +void GPU_set_gpu_mipmapping(int gpu_mipmap) +{ int old_value = GTS.gpu_mipmap; /* only actually enable if it's supported */ GTS.gpu_mipmap = gpu_mipmap && GLEW_EXT_framebuffer_object; - if(old_value != GTS.gpu_mipmap) { + if (old_value != GTS.gpu_mipmap) { GPU_free_images(); } } @@ -644,7 +645,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); } else { - if(GTS.gpu_mipmap) { + if (GTS.gpu_mipmap) { if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 2370dbeebc5..a908d4aa3b8 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -445,7 +445,7 @@ static int startffmpeg(struct anim *anim) int i, videoStream; AVCodec *pCodec; - AVFormatContext *pFormatCtx; + AVFormatContext *pFormatCtx = NULL; AVCodecContext *pCodecCtx; int frs_num; double frs_den; @@ -464,7 +464,7 @@ static int startffmpeg(struct anim *anim) do_init_ffmpeg(); - if (av_open_input_file(&pFormatCtx, anim->name, NULL, 0, NULL) != 0) { + if (avformat_open_input(&pFormatCtx, anim->name, NULL, NULL) != 0) { return -1; } @@ -551,8 +551,8 @@ static int startffmpeg(struct anim *anim) anim->pFrameDeinterlaced = avcodec_alloc_frame(); anim->pFrameRGB = avcodec_alloc_frame(); - if (avpicture_get_size(PIX_FMT_RGBA, anim->x, anim->y) - != anim->x * anim->y * 4) + if (avpicture_get_size(PIX_FMT_RGBA, anim->x, anim->y) != + anim->x * anim->y * 4) { fprintf(stderr, "ffmpeg has changed alloc scheme ... ARGHHH!\n"); diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 11da2f4af91..0ccd2680461 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -531,13 +531,6 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( rv->c->flags |= CODEC_FLAG_GLOBAL_HEADER; } - if (av_set_parameters(rv->of, NULL) < 0) { - fprintf(stderr, "Couldn't set output parameters? " - "Proxy not built!\n"); - av_free(rv->of); - return 0; - } - if (avio_open(&rv->of->pb, fname, AVIO_FLAG_WRITE) < 0) { fprintf(stderr, "Couldn't open outputfile! " "Proxy not built!\n"); @@ -574,7 +567,12 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( NULL, NULL, NULL); } - av_write_header(rv->of); + if (avformat_write_header(rv->of, NULL) < 0) { + fprintf(stderr, "Couldn't set output parameters? " + "Proxy not built!\n"); + av_free(rv->of); + return 0; + } return rv; } @@ -737,7 +735,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim memset(context->proxy_ctx, 0, sizeof(context->proxy_ctx)); memset(context->indexer, 0, sizeof(context->indexer)); - if (av_open_input_file(&context->iFormatCtx, anim->name, NULL, 0, NULL) != 0) { + if (avformat_open_input(&context->iFormatCtx, anim->name, NULL, NULL) != 0) { MEM_freeN(context); return NULL; } diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index a5826634724..053d88c8c32 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -332,7 +332,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) return(ibuf); } -//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) { +//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) /* prec can be 8, 12, 16 */ /* use inline because the float passed can be a function call that would end up being called many times */ diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index a86e2bed0e5..92c10a094d3 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -247,7 +247,7 @@ void do_init_ffmpeg(void) static int isffmpeg(const char *filename) { - AVFormatContext *pFormatCtx; + AVFormatContext *pFormatCtx = NULL; unsigned int i; int videoStream; AVCodec *pCodec; @@ -268,7 +268,7 @@ static int isffmpeg(const char *filename) return 0; } - if (av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL) != 0) { + if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) { if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_open_input_file failed\n"); return 0; } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index a10d610c6d4..bd9b0a4585e 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -347,20 +347,31 @@ typedef struct bNodeSocketValueRGBA { /* data structs, for node->storage */ - -#define CMP_NODE_MASKTYPE_ADD 0 -#define CMP_NODE_MASKTYPE_SUBTRACT 1 -#define CMP_NODE_MASKTYPE_MULTIPLY 2 -#define CMP_NODE_MASKTYPE_NOT 3 - -#define CMP_NODE_LENSFLARE_GHOST 1 -#define CMP_NODE_LENSFLARE_GLOW 2 -#define CMP_NODE_LENSFLARE_CIRCLE 4 -#define CMP_NODE_LENSFLARE_STREAKS 8 - -#define CMP_NODE_DILATEERODE_STEP 0 -#define CMP_NODE_DILATEERODE_DISTANCE_THRESH 1 -#define CMP_NODE_DILATEERODE_DISTANCE 2 +enum { + CMP_NODE_MASKTYPE_ADD = 0, + CMP_NODE_MASKTYPE_SUBTRACT = 1, + CMP_NODE_MASKTYPE_MULTIPLY = 2, + CMP_NODE_MASKTYPE_NOT = 3 +}; + +enum { + CMP_NODE_LENSFLARE_GHOST = 1, + CMP_NODE_LENSFLARE_GLOW = 2, + CMP_NODE_LENSFLARE_CIRCLE = 4, + CMP_NODE_LENSFLARE_STREAKS = 8 +}; + +enum { + CMP_NODE_DILATEERODE_STEP = 0, + CMP_NODE_DILATEERODE_DISTANCE_THRESH = 1, + CMP_NODE_DILATEERODE_DISTANCE = 2, + CMP_NODE_DILATEERODE_DISTANCE_FEATHER = 3 +}; + +enum { + CMP_NODEFLAG_MASK_AA = (1 << 0), + CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1) +}; typedef struct NodeFrame { short flag; @@ -558,6 +569,11 @@ typedef struct NodeColorspill { float uspillr, uspillg, uspillb; } NodeColorspill; +typedef struct NodeDilateErode { + char falloff; + char pad[7]; +} NodeDilateErode; + typedef struct NodeTexBase { TexMapping tex_mapping; ColorMapping color_mapping; diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 24d33b49db2..1b42d889c1d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -165,7 +165,7 @@ typedef struct Object { unsigned int lay; /* copy of Base's layer in the scene */ - int pad6; + float sf; /* sf is time-offset */ short flag; /* copy of Base */ short colbits DNA_DEPRECATED; /* deprecated */ @@ -180,8 +180,6 @@ typedef struct Object { int dupon, dupoff, dupsta, dupend; - float sf, ctime; /* sf is time-offset, ctime is the objects current time (XXX timing needs to be revised) */ - /* during realtime */ /* note that inertia is only called inertia for historical reasons @@ -260,6 +258,7 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; + int *pad; uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ unsigned int state; /* bit masks of game controllers that are active */ @@ -338,7 +337,7 @@ typedef struct DupliObject { /* check if the object type supports materials */ #define OB_TYPE_SUPPORT_MATERIAL(_type) \ - ((_type) >= OB_MESH && (_type) <= OB_MBALL) + ((_type) >= OB_MESH && (_type) <= OB_MBALL) #define OB_TYPE_SUPPORT_VGROUP(_type) \ (ELEM(_type, OB_MESH, OB_LATTICE)) #define OB_TYPE_SUPPORT_EDITMODE(_type) \ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 177db545483..f8c0f6a5910 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -800,7 +800,11 @@ static int calculate_structlens(int firststruct) } } - /* 2-4 aligned/ */ + /* 2-4-8 aligned/ */ + if (type < firststruct && typelens[type] > 4 && (len % 8)) { + printf("Align 8 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 8); + dna_error = 1; + } if (typelens[type] > 3 && (len % 4) ) { printf("Align 4 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 4); dna_error = 1; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index d4138267041..7151c260942 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -41,6 +41,7 @@ extern EnumPropertyItem object_mode_items[]; extern EnumPropertyItem metaelem_type_items[]; extern EnumPropertyItem proportional_falloff_items[]; +extern EnumPropertyItem proportional_falloff_curve_only_items[]; extern EnumPropertyItem proportional_editing_items[]; extern EnumPropertyItem snap_target_items[]; extern EnumPropertyItem snap_element_items[]; diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 1596e4573ab..315eaaac20e 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -136,6 +136,8 @@ static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float * static char *rna_ColorRamp_path(PointerRNA *ptr) { + char *path = NULL; + /* handle the cases where a single datablock may have 2 ramp types */ if (ptr->id.data) { ID *id = ptr->id.data; @@ -146,11 +148,39 @@ static char *rna_ColorRamp_path(PointerRNA *ptr) Material *ma = (Material *)id; if (ptr->data == ma->ramp_col) - return BLI_strdup("diffuse_ramp"); + path = BLI_strdup("diffuse_ramp"); else if (ptr->data == ma->ramp_spec) - return BLI_strdup("specular_ramp"); + path = BLI_strdup("specular_ramp"); + break; } - break; + + case ID_NT: + { + bNodeTree *ntree = (bNodeTree *)id; + bNode *node; + PointerRNA node_ptr; + char *node_path; + + for (node = ntree->nodes.first; node; node = node->next) { + if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) { + if (node->storage == ptr->data) { + /* all node color ramp properties called 'color_ramp' + * prepend path from ID to the node + */ + RNA_pointer_create(id, &RNA_Node, node, &node_ptr); + node_path = RNA_path_from_ID_to_struct(&node_ptr); + path = BLI_sprintfN("%s.color_ramp", node_path); + MEM_freeN(node_path); + } + } + } + break; + } + + default: + /* everything else just uses 'color_ramp' */ + path = BLI_strdup("color_ramp"); + break; case ID_LS: { @@ -161,9 +191,12 @@ static char *rna_ColorRamp_path(PointerRNA *ptr) break; } } + else { + /* everything else just uses 'color_ramp' */ + path = BLI_strdup("color_ramp"); + } - /* everything else just uses 'color_ramp' */ - return BLI_strdup("color_ramp"); + return path; } static char *rna_ColorRampElement_path(PointerRNA *ptr) @@ -213,7 +246,6 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr) } break; - /* TODO: node trees need special attention */ case ID_NT: { bNodeTree *ntree = (bNodeTree *)id; diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index dfcbbe0653b..51dfa020bea 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -50,9 +50,13 @@ #ifdef RNA_RUNTIME #include "DNA_mask_types.h" +#include "DNA_movieclip_types.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" +#include "BKE_tracking.h" + +#include "BLI_math.h" #include "RNA_access.h" @@ -66,6 +70,40 @@ static void rna_Mask_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin DAG_id_tag_update( &mask->id, 0); } +static void rna_Mask_update_parent(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + MaskParent *parent = ptr->data; + + if (parent->id) { + if (GS(parent->id->name) == ID_MC) { + MovieClip *clip = (MovieClip *) parent->id; + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, parent->parent); + + if (object) { + MovieTrackingTrack *track = BKE_tracking_track_get_named(tracking, object, parent->sub_parent); + + if (track) { + int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); + float marker_pos_ofs[2], parmask_pos[2]; + MovieClipUser user = {0}; + + BKE_movieclip_user_set_frame(&user, scene->r.cfra); + + add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); + + BKE_mask_coord_from_movieclip(clip, &user, parmask_pos, marker_pos_ofs); + + copy_v2_v2(parent->parent_orig, parmask_pos); + } + } + } + } + + rna_Mask_update_data(bmain, scene, ptr); +} + /* note: this function exists only to avoid id refcounting */ static void rna_MaskParent_id_set(PointerRNA *ptr, PointerRNA value) { @@ -357,7 +395,7 @@ static void rna_def_maskParent(BlenderRNA *brna) /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskParent_id_set", "rna_MaskParent_id_typef", NULL); RNA_def_property_ui_text(prop, "ID", "ID-block to which masking element would be parented to or to it's property"); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "id_type"); @@ -366,19 +404,19 @@ static void rna_def_maskParent(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_MaskParent_id_type_set", NULL); //RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable"); RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used"); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); /* parent */ prop = RNA_def_property(srna, "parent", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Parent", "Name of parent object in specified data block to which parenting happens"); RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); /* sub_parent */ prop = RNA_def_property(srna, "sub_parent", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Sub Parent", "Name of parent sub-object in specified data block to which parenting happens"); RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); } static void rna_def_maskSplinePointUW(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 2a12fa8b116..573e27b52c2 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -289,13 +289,15 @@ static void rna_def_movieclip(BlenderRNA *brna) /* start_frame */ prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "start_frame"); - RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing. Affects all data associated with a clip"); + RNA_def_property_ui_text(prop, "Start Frame", "Global scene frame number at which this movie starts playing " + "(affects all data associated with a clip)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update"); /* frame_offset */ prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "frame_offset"); - RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name. Affects only how footage is loaing, not changes data associated with a clip"); + RNA_def_property_ui_text(prop, "Frame Offset", "Offset of footage first frame relative to it's file name " + "(affects only how footage is loading, does not change data associated with a clip)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update"); } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 683a49a7690..baf3ccf35e1 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2049,10 +2049,11 @@ static void def_cmp_dilate_erode(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {CMP_NODE_DILATEERODE_STEP, "STEP", 0, "Step", ""}, + {CMP_NODE_DILATEERODE_STEP, "STEP", 0, "Step", ""}, {CMP_NODE_DILATEERODE_DISTANCE_THRESH, "THRESHOLD", 0, "Threshold", ""}, {CMP_NODE_DILATEERODE_DISTANCE, "DISTANCE", 0, "Distance", ""}, - {0, NULL, 0, NULL, NULL} + {CMP_NODE_DILATEERODE_DISTANCE_FEATHER,"FEATHER", 0, "Feather", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -2067,11 +2068,21 @@ static void def_cmp_dilate_erode(StructRNA *srna) RNA_def_property_ui_text(prop, "Distance", "Distance to grow/shrink (number of iterations)"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + /* CMP_NODE_DILATEERODE_DISTANCE_THRESH only */ prop = RNA_def_property(srna, "edge", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "custom3"); RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Edge", "Edge to inset"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "NodeDilateErode", "storage"); + + /* CMP_NODE_DILATEERODE_DISTANCE_FEATHER only */ + prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "falloff"); + RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items); + RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_cmp_scale(StructRNA *srna) @@ -2455,9 +2466,9 @@ static void def_cmp_id_mask(StructRNA *srna) RNA_def_property_ui_text(prop, "Index", "Pass index number to convert to alpha"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "use_smooth_mask", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom2", 0); - RNA_def_property_ui_text(prop, "Smooth Mask", "Apply an anti-aliasing filter to the mask"); + RNA_def_property_ui_text(prop, "Anti-Aliasing", "Apply an anti-aliasing filter to the mask"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -2561,15 +2572,9 @@ static void def_cmp_defocus(StructRNA *srna) prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "preview", 1); - RNA_def_property_ui_text(prop, "Preview", "Enable sampling mode, useful for preview when using low samplecounts"); + RNA_def_property_ui_text(prop, "Preview", "Enable low quality mode, useful for preview"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "samples"); - RNA_def_property_range(prop, 16, 256); - RNA_def_property_ui_text(prop, "Samples", "Number of samples (16=grainy, higher=less noise)"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - + prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "no_zbuf", 1); RNA_def_property_ui_text(prop, "Use Z-Buffer", @@ -3114,16 +3119,21 @@ static void def_cmp_mask(StructRNA *srna) { PropertyRNA *prop; - prop = RNA_def_property(srna, "smooth_mask", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0); - RNA_def_property_ui_text(prop, "Anti-Alias", "Apply an anti-aliasing filter to the mask"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Mask"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mask", ""); + + prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_AA); + RNA_def_property_ui_text(prop, "Anti-Alias", "Apply an anti-aliasing filter to the mask"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_feather", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_NO_FEATHER); + RNA_def_property_ui_text(prop, "Feather", "Use feather information from the mask"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void dev_cmd_transform(StructRNA *srna) @@ -3601,7 +3611,7 @@ static void def_cmp_keying(StructRNA *srna) prop = RNA_def_property(srna, "edge_kernel_radius", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "edge_kernel_radius"); - RNA_def_property_range(prop, -100, 100); + RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Edge Kernel Radius", "Radius of kernel used to detect whether pixel belongs to edge"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 62c3051727d..20f58f4d16e 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -161,11 +161,11 @@ DefNode( CompositorNode, CMP_NODE_MOVIECLIP, def_cmp_movieclip, "MOVIE DefNode( CompositorNode, CMP_NODE_TRANSFORM, dev_cmd_transform, "TRANSFORM", Transform, "Transform", "" ) DefNode( CompositorNode, CMP_NODE_STABILIZE2D, def_cmp_stabilize2d, "STABILIZE2D", Stabilize, "Stabilize 2D", "" ) DefNode( CompositorNode, CMP_NODE_MOVIEDISTORTION,def_cmp_moviedistortion,"MOVIEDISTORTION",MovieDistortion, "Movie Distortion", "" ) -DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK" ,BoxMask, "Box mask", "" ) -DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK" ,EllipseMask, "Ellipse mask", "" ) -DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE" ,BokehImage, "Bokeh image", "" ) -DefNode( CompositorNode, CMP_NODE_BOKEHBLUR, def_cmp_bokehblur, "BOKEHBLUR" ,BokehBlur, "Bokeh Blur", "" ) -DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH" ,Switch, "Switch", "" ) +DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK", BoxMask, "Box mask", "" ) +DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK", EllipseMask, "Ellipse mask", "" ) +DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE", BokehImage, "Bokeh image", "" ) +DefNode( CompositorNode, CMP_NODE_BOKEHBLUR, def_cmp_bokehblur, "BOKEHBLUR", BokehBlur, "Bokeh Blur", "" ) +DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH", Switch, "Switch", "" ) DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLORCORRECTION",ColorCorrection, "ColorCorrection", "" ) DefNode( CompositorNode, CMP_NODE_MASK, def_cmp_mask, "MASK", Mask, "Mask", "" ) DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "KeyingScreen", "" ) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3769b8d6c42..f3454285682 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -102,6 +102,16 @@ EnumPropertyItem proportional_falloff_items[] = { {0, NULL, 0, NULL, NULL} }; +/* subset of the enum - only curves, missing random and const */ +EnumPropertyItem proportional_falloff_curve_only_items[] = { + {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"}, + {0, NULL, 0, NULL, NULL} +}; + EnumPropertyItem proportional_editing_items[] = { {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"}, diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 76366efe0d1..13b60498900 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -39,6 +39,7 @@ #include "DNA_scene_types.h" #include "BKE_utildefines.h" + #ifdef RNA_RUNTIME #include "BKE_animsys.h" @@ -88,17 +89,27 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name static void rna_Scene_collada_export( Scene *scene, const char *filepath, - int selected, int apply_modifiers, - int include_armatures, + int export_mesh_type, + + int selected, int include_children, + int include_armatures, + int deform_bones_only, + + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + int use_object_instantiation, - int sort_by_name, + int sort_by_name, int second_life) { - collada_export(scene, filepath, selected, apply_modifiers, - include_armatures, include_children, - use_object_instantiation, sort_by_name, second_life); + collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected, + include_children, include_armatures, deform_bones_only, + active_uv_only, include_uv_textures, include_material_textures, + use_texture_copies, use_object_instantiation, sort_by_name, second_life); } #endif @@ -126,11 +137,20 @@ void RNA_api_scene(StructRNA *srna) parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file"); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ + parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers"); + parm = RNA_def_int(func, "export_mesh_type", 0, INT_MIN, INT_MAX, + "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements"); - parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)"); - parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Include armature(s) used by the exported objects"); - parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Include all children even if not selected"); - parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instantiation", "Instantiate multiple Objects from same Data"); + parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Export all children of selected objects (even if not selected)"); + parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)"); + parm = RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only", "Only export deforming bones with armatures"); + + parm = RNA_def_boolean(func, "active_uv_only", 0, "Active UV Layer only", "Export only the active UV Layer"); + parm = RNA_def_boolean(func, "include_uv_textures", 0, "Include UV Textures", "Export textures assigned to the object UV maps"); + parm = RNA_def_boolean(func, "include_material_textures", 0, "Include Material Textures", "Export textures assigned to the object Materials"); + parm = RNA_def_boolean(func, "use_texture_copies", 0, "copy", "Copy textures to same folder where the .dae file is exported"); + + parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instances", "Instantiate multiple Objects from same Data"); parm = RNA_def_boolean(func, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name"); parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); RNA_def_function_ui_description(func, "Export to collada file"); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 71133634a96..6e5aa78b8bd 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -193,6 +193,16 @@ static void rna_def_area(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_Area_type_update"); + prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "totrct.xmin"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "X Position", "The window relative vertical location of the area"); + + prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "totrct.ymin"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Y Position", "The window relative horizontal location of the area"); + prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "winx"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -230,6 +240,16 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Region Type", "Type of this region"); + prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "winrct.xmin"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "X Position", "The window relative vertical location of the region"); + + prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "winrct.ymin"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Y Position", "The window relative horizontal location of the region"); + prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "winx"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index c0efff2d179..4224b3936c6 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -117,18 +117,18 @@ static int rna_SmokeModifier_density_get_length(PointerRNA *ptr, int length[RNA_ { SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; - if (settings->fluid) - { + if (settings->fluid) { float *density = smoke_get_density(settings->fluid); unsigned int size = settings->res[0] * settings->res[1] * settings->res[2]; - if(density) + if (density) length[0] = size; else length[0] = 0; } - else - length[0] = 0; // No smoke domain created yet + else { + length[0] = 0; /* No smoke domain created yet */ + } return length[0]; } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 30b06017568..661c7ba878c 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1036,7 +1036,7 @@ static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value) SpaceClip *sc = (SpaceClip *)(ptr->data); bScreen *screen = (bScreen *)ptr->id.data; - ED_space_clip_set(NULL, screen, sc, (MovieClip *)value.data); + ED_space_clip_set_clip(NULL, screen, sc, (MovieClip *)value.data); } static void rna_SpaceClipEditor_mask_set(PointerRNA *ptr, PointerRNA value) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 85dee2617d8..801bec30ecf 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -780,21 +780,21 @@ static void rna_def_trackingCamera(BlenderRNA *brna) prop = RNA_def_property(srna, "k1", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k1"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_range(prop, -10, 10, .1, 3); + RNA_def_property_ui_range(prop, -10, 10, 0.1, 3); RNA_def_property_ui_text(prop, "K1", "First coefficient of third order polynomial radial distortion"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); prop = RNA_def_property(srna, "k2", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k2"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_range(prop, -10, 10, .1, 3); + RNA_def_property_ui_range(prop, -10, 10, 0.1, 3); RNA_def_property_ui_text(prop, "K2", "Second coefficient of third order polynomial radial distortion"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); prop = RNA_def_property(srna, "k3", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "k3"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_range(prop, -10, 10, .1, 3); + RNA_def_property_ui_range(prop, -10, 10, 0.1, 3); RNA_def_property_ui_text(prop, "K3", "Third coefficient of third order polynomial radial distortion"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_flushUpdate"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 26e241a0311..99d5d5ca462 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -144,7 +144,8 @@ static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA rna_userdef_update(bmain, scene, ptr); } -static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) { +static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) +{ GPU_set_gpu_mipmapping(U.use_gpu_mipmap); rna_userdef_update(bmain, scene, ptr); } diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index ce95f9bec6e..aed8a70a805 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -282,10 +282,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, step_tot--; if (step_tot < 3) step_tot = 3; - maxVerts = totvert * step_tot; /* -1 because we're joining back up */ - maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ - (totedge * step_tot); /* -1 because vert edges join */ - maxPolys = totedge * step_tot; + maxVerts = totvert * step_tot; /* -1 because we're joining back up */ + maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ + (totedge * step_tot); /* -1 because vert edges join */ + maxPolys = totedge * step_tot; screw_ofs = 0.0f; } diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 5813f4d479f..b716f19a697 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -683,7 +683,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int if (G.rt == 200) ntreeCompositExecTreeOld(ntree, rd, do_preview); else - COM_execute(ntree, rendering); + COM_execute(rd, ntree, rendering); } /* *********************************************** */ diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index afd10d96e99..f6011843b8a 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -32,6 +32,8 @@ #include "node_composite_util.h" +#include <limits.h> + CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc) { CompBuf *cbuf= MEM_callocN(sizeof(CompBuf), "compbuf"); @@ -205,7 +207,7 @@ void typecheck_compbuf_color(float *out, float *in, int outtype, int intype) *out= 0.333333f*(in[0]+in[1]+in[2]); } else if (intype==CB_RGBA) { - *out= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f; + *out = rgb_to_bw(in); } } else if (outtype==CB_VEC2) { @@ -298,7 +300,7 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) } else if (inbuf->type==CB_RGBA) { for (; x>0; x--, outrf+= 1, inrf+= 4) - *outrf= inrf[0]*0.35f + inrf[1]*0.45f + inrf[2]*0.2f; + *outrf = rgb_to_bw(inrf); } } else if (type==CB_VEC2) { @@ -1300,33 +1302,35 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) { double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3]; double *X, *Y, *W; - int i, x, y, sz; + const unsigned int src_width = src->x; + const unsigned int src_height = src->y; + unsigned int i, x, y, sz; // <0.5 not valid, though can have a possibly useful sort of sharpening effect if (sigma < 0.5f) return; - + if ((xy < 1) || (xy > 3)) xy = 3; - + // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels, // so just skiping blur along faulty direction if src's def is below that limit! - if (src->x < 3) xy &= ~(int) 1; - if (src->y < 3) xy &= ~(int) 2; + if (src_width < 3) xy &= ~(int) 1; + if (src_height < 3) xy &= ~(int) 2; if (xy < 1) return; // see "Recursive Gabor Filtering" by Young/VanVliet // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200 if (sigma >= 3.556f) - q = 0.9804f*(sigma - 3.556f) + 2.5091f; - else // sigma >= 0.5 - q = (0.0561f*sigma + 0.5784f)*sigma - 0.2568f; - q2 = q*q; - sc = (1.1668 + q)*(3.203729649 + (2.21566 + q)*q); + q = 0.9804f * (sigma - 3.556f) + 2.5091f; + else // sigma >= 0.5 + q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f; + q2 = q * q; + sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q); // no gabor filtering here, so no complex multiplies, just the regular coefs. // all negated here, so as not to have to recalc Triggs/Sdika matrix - cf[1] = q*(5.788961737 + (6.76492 + 3.0*q)*q)/ sc; - cf[2] = -q2*(3.38246 + 3.0*q)/sc; + cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc; + cf[2] = -q2 * (3.38246 + 3.0 * q) / sc; // 0 & 3 unchanged - cf[3] = q2*q/sc; + cf[3] = q2 * q / sc; cf[0] = 1.0 - cf[1] - cf[2] - cf[3]; // Triggs/Sdika border corrections, @@ -1336,59 +1340,62 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy) // but neither seem to be quite the same, result seems to be ok so far anyway. // Extra scale factor here to not have to do it in filter, // though maybe this had something to with the precision errors - sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3])); - tsM[0] = sc*(-cf[3]*cf[1] + 1.0 - cf[3]*cf[3] - cf[2]); - tsM[1] = sc*((cf[3] + cf[1])*(cf[2] + cf[3]*cf[1])); - tsM[2] = sc*(cf[3]*(cf[1] + cf[3]*cf[2])); - tsM[3] = sc*(cf[1] + cf[3]*cf[2]); - tsM[4] = sc*(-(cf[2] - 1.0)*(cf[2] + cf[3]*cf[1])); - tsM[5] = sc*(-(cf[3]*cf[1] + cf[3]*cf[3] + cf[2] - 1.0)*cf[3]); - tsM[6] = sc*(cf[3]*cf[1] + cf[2] + cf[1]*cf[1] - cf[2]*cf[2]); - tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]); - tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2])); - -#define YVV(L) \ -{ \ - W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0]; \ - W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0]; \ - W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0]; \ - for (i=3; i<L; i++) \ - W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3]; \ - tsu[0] = W[L-1] - X[L-1]; \ - tsu[1] = W[L-2] - X[L-1]; \ - tsu[2] = W[L-3] - X[L-1]; \ - tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1]; \ - tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1]; \ - tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1]; \ - Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2]; \ - Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1]; \ - Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0]; \ - for (i=L-4; i>=0; i--) \ - Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3]; \ + sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3])); + tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]); + tsM[1] = sc * ((cf[3] + cf[1]) * (cf[2] + cf[3] * cf[1])); + tsM[2] = sc * (cf[3] * (cf[1] + cf[3] * cf[2])); + tsM[3] = sc * (cf[1] + cf[3] * cf[2]); + tsM[4] = sc * (-(cf[2] - 1.0) * (cf[2] + cf[3] * cf[1])); + tsM[5] = sc * (-(cf[3] * cf[1] + cf[3] * cf[3] + cf[2] - 1.0) * cf[3]); + tsM[6] = sc * (cf[3] * cf[1] + cf[2] + cf[1] * cf[1] - cf[2] * cf[2]); + tsM[7] = sc * (cf[1] * cf[2] + cf[3] * cf[2] * cf[2] - cf[1] * cf[3] * cf[3] - cf[3] * cf[3] * cf[3] - cf[3] * cf[2] + cf[3]); + tsM[8] = sc * (cf[3] * (cf[1] + cf[3] * cf[2])); + +#define YVV(L) \ +{ \ + W[0] = cf[0] * X[0] + cf[1] * X[0] + cf[2] * X[0] + cf[3] * X[0]; \ + W[1] = cf[0] * X[1] + cf[1] * W[0] + cf[2] * X[0] + cf[3] * X[0]; \ + W[2] = cf[0] * X[2] + cf[1] * W[1] + cf[2] * W[0] + cf[3] * X[0]; \ + for (i = 3; i < L; i++) { \ + W[i] = cf[0] * X[i] + cf[1] * W[i - 1] + cf[2] * W[i - 2] + cf[3] * W[i - 3]; \ + } \ + tsu[0] = W[L - 1] - X[L - 1]; \ + tsu[1] = W[L - 2] - X[L - 1]; \ + tsu[2] = W[L - 3] - X[L - 1]; \ + tsv[0] = tsM[0] * tsu[0] + tsM[1] * tsu[1] + tsM[2] * tsu[2] + X[L - 1]; \ + tsv[1] = tsM[3] * tsu[0] + tsM[4] * tsu[1] + tsM[5] * tsu[2] + X[L - 1]; \ + tsv[2] = tsM[6] * tsu[0] + tsM[7] * tsu[1] + tsM[8] * tsu[2] + X[L - 1]; \ + Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \ + Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \ + Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \ + /* 'i != UINT_MAX' is really 'i >= 0', but necessary for unsigned int wrapping */ \ + for (i = L - 4; i != UINT_MAX; i--) { \ + Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \ + } \ } (void)0 // intermediate buffers - sz = MAX2(src->x, src->y); - X = MEM_callocN(sz*sizeof(double), "IIR_gauss X buf"); - Y = MEM_callocN(sz*sizeof(double), "IIR_gauss Y buf"); - W = MEM_callocN(sz*sizeof(double), "IIR_gauss W buf"); - if (xy & 1) { // H - for (y=0; y<src->y; ++y) { - const int yx = y*src->x; - for (x=0; x<src->x; ++x) - X[x] = src->rect[(x + yx)*src->type + chan]; - YVV(src->x); - for (x=0; x<src->x; ++x) - src->rect[(x + yx)*src->type + chan] = Y[x]; + sz = MAX2(src_width, src_height); + X = MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); + Y = MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); + W = MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); + if (xy & 1) { // H + for (y = 0; y < src_height; ++y) { + const int yx = y * src_width; + for (x = 0; x < src_width; ++x) + X[x] = src->rect[(x + yx) * src->type + chan]; + YVV(src_width); + for (x = 0; x < src_width; ++x) + src->rect[(x + yx) * src->type + chan] = Y[x]; } } - if (xy & 2) { // V - for (x=0; x<src->x; ++x) { - for (y=0; y<src->y; ++y) - X[y] = src->rect[(x + y*src->x)*src->type + chan]; - YVV(src->y); - for (y=0; y<src->y; ++y) - src->rect[(x + y*src->x)*src->type + chan] = Y[y]; + if (xy & 2) { // V + for (x = 0; x < src_width; ++x) { + for (y = 0; y < src_height; ++y) + X[y] = src->rect[(x + y * src_width) * src->type + chan]; + YVV(src_height); + for (y = 0; y < src_height; ++y) + src->rect[(x + y * src_width) * src->type + chan] = Y[y]; } } diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index 1b82da372ec..2ae3cd6ba56 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -29,9 +29,10 @@ * \ingroup cmpnodes */ - #include "node_composite_util.h" +#include <limits.h> + /* ************ qdn: Defocus node ****************** */ static bNodeSocketTemplate cmp_node_defocus_in[]= { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, @@ -148,11 +149,13 @@ static float RI_vdC(unsigned int bits, unsigned int r) // much faster than anything else, constant time independent of width // should extend to multichannel and make this a node, could be useful // note: this is an almost exact copy of 'IIR_gauss' -static void IIR_gauss_single(CompBuf* buf, float sigma) +static void IIR_gauss_single(CompBuf *buf, float sigma) { double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3]; float *X, *Y, *W; - int i, x, y, sz; + const unsigned int src_width = buf->x; + const unsigned int src_height = buf->y; + unsigned int i, x, y, sz; // single channel only for now if (buf->type != CB_VAL) return; @@ -180,58 +183,61 @@ static void IIR_gauss_single(CompBuf* buf, float sigma) // it seems to work, not entirely sure if it is actually totally correct, // Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark), // found one other implementation by Cristoph Lampert, - // but neither seem to be quite the same, result seems to be ok sofar anyway. + // but neither seem to be quite the same, result seems to be ok so far anyway. // Extra scale factor here to not have to do it in filter, // though maybe this had something to with the precision errors - sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3])); - tsM[0] = sc*(-cf[3]*cf[1] + 1.0 - cf[3]*cf[3] - cf[2]); - tsM[1] = sc*((cf[3] + cf[1])*(cf[2] + cf[3]*cf[1])); - tsM[2] = sc*(cf[3]*(cf[1] + cf[3]*cf[2])); - tsM[3] = sc*(cf[1] + cf[3]*cf[2]); - tsM[4] = sc*(-(cf[2] - 1.0)*(cf[2] + cf[3]*cf[1])); - tsM[5] = sc*(-(cf[3]*cf[1] + cf[3]*cf[3] + cf[2] - 1.0)*cf[3]); - tsM[6] = sc*(cf[3]*cf[1] + cf[2] + cf[1]*cf[1] - cf[2]*cf[2]); - tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]); - tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2])); - -#define YVV(L)\ -{\ - W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0];\ - W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0];\ - W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0];\ - for (i=3; i<L; i++)\ - W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3];\ - tsu[0] = W[L-1] - X[L-1];\ - tsu[1] = W[L-2] - X[L-1];\ - tsu[2] = W[L-3] - X[L-1];\ - tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1];\ - tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1];\ - tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1];\ - Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2];\ - Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1];\ - Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0];\ - for (i=L-4; i>=0; i--)\ - Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3];\ -} + sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3])); + tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]); + tsM[1] = sc * ((cf[3] + cf[1]) * (cf[2] + cf[3] * cf[1])); + tsM[2] = sc * (cf[3] * (cf[1] + cf[3] * cf[2])); + tsM[3] = sc * (cf[1] + cf[3] * cf[2]); + tsM[4] = sc * (-(cf[2] - 1.0) * (cf[2] + cf[3] * cf[1])); + tsM[5] = sc * (-(cf[3] * cf[1] + cf[3] * cf[3] + cf[2] - 1.0) * cf[3]); + tsM[6] = sc * (cf[3] * cf[1] + cf[2] + cf[1] * cf[1] - cf[2] * cf[2]); + tsM[7] = sc * (cf[1] * cf[2] + cf[3] * cf[2] * cf[2] - cf[1] * cf[3] * cf[3] - cf[3] * cf[3] * cf[3] - cf[3] * cf[2] + cf[3]); + tsM[8] = sc * (cf[3] * (cf[1] + cf[3] * cf[2])); + +#define YVV(L) \ +{ \ + W[0] = cf[0] * X[0] + cf[1] * X[0] + cf[2] * X[0] + cf[3] * X[0]; \ + W[1] = cf[0] * X[1] + cf[1] * W[0] + cf[2] * X[0] + cf[3] * X[0]; \ + W[2] = cf[0] * X[2] + cf[1] * W[1] + cf[2] * W[0] + cf[3] * X[0]; \ + for (i = 3; i < L; i++) { \ + W[i] = cf[0] * X[i] + cf[1] * W[i - 1] + cf[2] * W[i - 2] + cf[3] * W[i - 3]; \ + } \ + tsu[0] = W[L - 1] - X[L - 1]; \ + tsu[1] = W[L - 2] - X[L - 1]; \ + tsu[2] = W[L - 3] - X[L - 1]; \ + tsv[0] = tsM[0] * tsu[0] + tsM[1] * tsu[1] + tsM[2] * tsu[2] + X[L - 1]; \ + tsv[1] = tsM[3] * tsu[0] + tsM[4] * tsu[1] + tsM[5] * tsu[2] + X[L - 1]; \ + tsv[2] = tsM[6] * tsu[0] + tsM[7] * tsu[1] + tsM[8] * tsu[2] + X[L - 1]; \ + Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \ + Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \ + Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \ + /* 'i != UINT_MAX' is really 'i >= 0', but necessary for unsigned int wrapping */ \ + for (i = L - 4; i != UINT_MAX; i--) { \ + Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \ + } \ +} (void)0 // intermediate buffers - sz = MAX2(buf->x, buf->y); - Y = MEM_callocN(sz*sizeof(float), "IIR_gauss Y buf"); - W = MEM_callocN(sz*sizeof(float), "IIR_gauss W buf"); + sz = MAX2(src_width, src_height); + Y = MEM_callocN(sz * sizeof(float), "IIR_gauss Y buf"); + W = MEM_callocN(sz * sizeof(float), "IIR_gauss W buf"); // H - for (y=0; y<buf->y; y++) { - X = &buf->rect[y*buf->x]; - YVV(buf->x); - memcpy(X, Y, sizeof(float)*buf->x); + for (y = 0; y < src_height; y++) { + X = &buf->rect[y * src_width]; + YVV(src_width); + memcpy(X, Y, sizeof(float) * src_width); } // V - X = MEM_callocN(buf->y*sizeof(float), "IIR_gauss X buf"); - for (x=0; x<buf->x; x++) { - for (y=0; y<buf->y; y++) - X[y] = buf->rect[x + y*buf->x]; - YVV(buf->y); - for (y=0; y<buf->y; y++) - buf->rect[x + y*buf->x] = Y[y]; + X = MEM_callocN(src_height * sizeof(float), "IIR_gauss X buf"); + for (x = 0; x < src_width; x++) { + for (y = 0; y < src_height; y++) + X[y] = buf->rect[x + y * src_width]; + YVV(src_height); + for (y = 0; y < src_height; y++) + buf->rect[x + y * src_width] = Y[y]; } MEM_freeN(X); diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index 2f139831cc9..5977d291388 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -146,6 +146,13 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod } } +static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +{ + NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), "NodeDilateErode"); + data->falloff = PROP_SMOOTH; + node->storage = data; +} + void register_node_type_cmp_dilateerode(bNodeTreeType *ttype) { static bNodeType ntype; @@ -153,7 +160,10 @@ void register_node_type_cmp_dilateerode(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out); node_type_size(&ntype, 130, 100, 320); + node_type_init(&ntype, node_composit_init_dilateerode); node_type_exec(&ntype, node_composit_exec_dilateerode); + node_type_storage(&ntype, "NodeDilateErode", node_free_standard_storage, node_copy_standard_storage); + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index 9b19ca6f5cf..7635a391441 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -98,19 +98,20 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; fRGB c1, tc = {0, 0, 0, 0}; const float u = sc*((x + 0.5f) - cx)/cx; + const float uv_dot = u * u + v * v; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr*(u*u + v*v)) >= 0.f) { + if ((t = 1.f - kr*uv_dot) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[0] = (u*d + 0.5f)*dst->x - 0.5f, ln[1] = (v*d + 0.5f)*dst->y - 0.5f; sta = 1; } - if ((t = 1.f - kg*(u*u + v*v)) >= 0.f) { + if ((t = 1.f - kg*uv_dot) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[2] = (u*d + 0.5f)*dst->x - 0.5f, ln[3] = (v*d + 0.5f)*dst->y - 0.5f; mid = 1; } - if ((t = 1.f - kb*(u*u + v*v)) >= 0.f) { + if ((t = 1.f - kb*uv_dot) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[4] = (u*d + 0.5f)*dst->x - 0.5f, ln[5] = (v*d + 0.5f)*dst->y - 0.5f; end = 1; @@ -125,7 +126,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb for (z=0; z<ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; - t = 1.f - (kr + tz*drg)*(u*u + v*v); + t = 1.f - (kr + tz*drg)*uv_dot; d = 1.f / (1.f + sqrtf(t)); qd_getPixelLerp(src, (u*d + 0.5f)*dst->x - 0.5f, (v*d + 0.5f)*dst->y - 0.5f, c1); if (src->type == CB_VAL) c1[1] = c1[2] = c1[0]; @@ -141,7 +142,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb for (z=0; z<ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; - t = 1.f - (kg + tz*dgb)*(u*u + v*v); + t = 1.f - (kg + tz*dgb)*uv_dot; d = 1.f / (1.f + sqrtf(t)); qd_getPixelLerp(src, (u*d + 0.5f)*dst->x - 0.5f, (v*d + 0.5f)*dst->y - 0.5f, c1); if (src->type == CB_VAL) c1[1] = c1[2] = c1[0]; diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 5594c20a9df..0aeeb69210d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -45,11 +45,6 @@ static bNodeSocketTemplate cmp_node_view_levels_out[]={ {-1, 0, ""} }; -static void rgb_tobw(float r, float g, float b, float* out) -{ - *out= r*0.35f + g*0.45f + b*0.2f; -} - static void fill_bins(bNode* node, CompBuf* in, int* bins) { float value[4]; @@ -66,7 +61,7 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins) if (value[3] > 0.0f) { /* don't count transparent pixels */ switch (node->custom1) { case 1: { /* all colors */ - rgb_tobw(value[0], value[1], value[2], &value[0]); + value[0] = rgb_to_bw(value); value[0]=value[0]*255; /* scale to 0-255 range */ ivalue=(int)value[0]; break; @@ -125,7 +120,7 @@ static float brightness_mean(bNode* node, CompBuf* in) switch (node->custom1) { case 1: { - rgb_tobw(value[0], value[1], value[2], &value[0]); + value[0] = rgb_to_bw(value); sum+=value[0]; break; } @@ -176,7 +171,7 @@ static float brightness_standard_deviation(bNode* node, CompBuf* in, float mean) switch (node->custom1) { case 1: { - rgb_tobw(value[0], value[1], value[2], &value[0]); + value[0] = rgb_to_bw(value); sum+=(value[0]-mean)*(value[0]-mean); break; } diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index d323839e690..3cd3a732829 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -70,9 +70,11 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** stackbuf = alloc_compbuf(sx, sy, CB_VAL, TRUE); res = stackbuf->rect; - BKE_mask_rasterize(mask, sx, sy, res, TRUE, node->custom1); + BKE_mask_rasterize(mask, sx, sy, res, TRUE, + (node->custom1 & CMP_NODEFLAG_MASK_AA) != 0, + (node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); - if(node->custom1){ + if (node->custom1) { PLX_antialias_buffer(res,sx,sy); } /* pass on output and free */ diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index bdf6b4f1635..429ba262164 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -111,7 +111,7 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[]= { static void do_rgbtobw(bNode *UNUSED(node), float *out, float *in) { - out[0]= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f; + out[0] = rgb_to_bw(in); } static void node_composit_exec_rgbtobw(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c index 6456742e22b..beefc0b6eae 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c @@ -36,13 +36,13 @@ static bNodeSocketTemplate outputs[] = { /* node type definition */ void register_node_type_sh_particle_info(bNodeTreeType *ttype) { - static bNodeType ntype; + static bNodeType ntype; - node_type_base(ttype, &ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, NULL, outputs); - node_type_size(&ntype, 150, 60, 200); + node_type_base(ttype, &ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, NULL, outputs); + node_type_size(&ntype, 150, 60, 200); - nodeRegisterType(ttype, &ntype); + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index 1738606082f..fb3316c2036 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -104,7 +104,7 @@ static void node_shader_exec_rgbtobw(void *UNUSED(data), bNode *UNUSED(node), bN /* stack order out: bw */ /* stack order in: col */ - out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f; + out[0]->vec[0] = rgb_to_bw(in[0]->vec); } static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 255ed9e51fc..28d03db1687 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -88,9 +88,9 @@ void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread) } if (in->hasoutput && in->sockettype == SOCK_VECTOR) { - out[0] = out[0] * .5f + .5f; - out[1] = out[1] * .5f + .5f; - out[2] = out[2] * .5f + .5f; + out[0] = out[0] * 0.5f + 0.5f; + out[1] = out[1] * 0.5f + 0.5f; + out[2] = out[2] * 0.5f + 0.5f; out[3] = 1; } } diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c index ded3afe4c6b..2add5c820eb 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.c +++ b/source/blender/nodes/texture/nodes/node_texture_coord.c @@ -40,9 +40,7 @@ static bNodeSocketTemplate outputs[]= { static void vectorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread)) { - out[0] = p->co[0]; - out[1] = p->co[1]; - out[2] = p->co[2]; + copy_v3_v3(out, p->co); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index 52455e024b4..6863eab9150 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -80,7 +80,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor float col[4]; tex_input_rgba(col, in[4], p, thread); - hue += 0.5f; /* [-.5, .5] -> [0, 1] */ + hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */ do_hue_sat_fac(node, out, hue, sat, val, col, fac); diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 0d985273eda..98382e24290 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -65,7 +65,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor if (node->custom2 || node->need_exec==0) { /* this node refers to its own texture tree! */ - copy_v4_v4(out, (fabs(co[0] - co[1]) < .01) ? white : red); + copy_v4_v4(out, (fabs(co[0] - co[1]) < 0.01) ? white : red); } else if (nodetex) { TexResult texres; diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index d1a02210038..10db0debd5b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -91,8 +91,7 @@ static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNode { float cin[4]; tex_input_rgba(cin, in[0], p, thread); - - *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f; + *out = rgb_to_bw(cin); } static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index 374a01c51f8..bb4e0c61c2b 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -370,7 +370,7 @@ static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args PyDoc_STRVAR(bpy_bm_utils_face_split_doc, ".. method:: face_split(face, vert_a, vert_b, coords=(), use_exist=True, example=None)\n" "\n" -" Split an edge, return the newly created data.\n" +" Face split with optional intermediate points.\n" "\n" " :arg face: The face to cut.\n" " :type face: :class:`bmesh.types.BMFace`\n" diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 5999040a2ab..3a46c6971cf 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -52,6 +52,7 @@ #include "BKE_main.h" static Main *bpy_import_main = NULL; +static ListBase bpy_import_main_list; /* 'builtins' is most likely PyEval_GetBuiltins() */ void bpy_import_init(PyObject *builtins) @@ -92,6 +93,16 @@ void bpy_import_main_set(struct Main *maggie) bpy_import_main = maggie; } +void bpy_import_main_extra_add(struct Main *maggie) +{ + BLI_addhead(&bpy_import_main_list, maggie); +} + +void bpy_import_main_extra_remove(struct Main *maggie) +{ + BLI_remlink_safe(&bpy_import_main_list, maggie); +} + /* returns a dummy filename for a textblock so we can tell what file a text block comes from */ void bpy_text_filename_get(char *fn, size_t fn_len, Text *text) { @@ -150,6 +161,18 @@ PyObject *bpy_text_import_name(const char *name, int *found) text = BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2); + if (text) { + *found = 1; + return bpy_text_import(text); + } + + /* If we still haven't found the module try additional modules form bpy_import_main_list */ + maggie = bpy_import_main_list.first; + while (maggie && !text) { + text = BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2); + maggie = maggie->next; + } + if (!text) return NULL; else diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 8b41a575d96..980e6edca03 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -62,4 +62,8 @@ extern PyMethodDef bpy_reload_meth; struct Main *bpy_import_main_get(void); void bpy_import_main_set(struct Main *maggie); +/* This is used for importing text from dynamically loaded libraries in the game engine */ +void bpy_import_main_extra_add(struct Main *maggie); +void bpy_import_main_extra_remove(struct Main *maggie); + #endif /* __BPY_INTERNAL_IMPORT_H__ */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 54044b62e04..8fb3a3f74d6 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1874,7 +1874,7 @@ static PyObject *Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa { VectorObject *vecA = NULL, *vecB = NULL; int result = 0; - double epsilon = .000001f; + double epsilon = 0.000001f; double lenA, lenB; if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)) { diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 46399844569..9c7511c0c60 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -154,6 +154,7 @@ typedef struct RenderStats { /* calling a new render with same name, frees automatic existing render */ struct Render *RE_NewRender (const char *name); struct Render *RE_GetRender(const char *name); +struct Render *RE_GetRender_FromData(const struct RenderData *rd); /* returns 1 while render is working (or renders called from within render) */ int RE_RenderInProgress(struct Render *re); diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index c23a93a52fe..5bb3e4605a2 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -64,15 +64,17 @@ static RenderEngineType internal_render_type = { NULL, NULL, "BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL, NULL, NULL, NULL, NULL, - {NULL, NULL, NULL}}; + {NULL, NULL, NULL} +}; #ifdef WITH_GAMEENGINE static RenderEngineType internal_game_type = { NULL, NULL, - "BLENDER_GAME", N_("Blender Game"), RE_INTERNAL|RE_GAME, + "BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME, NULL, NULL, NULL, NULL, - {NULL, NULL, NULL}}; + {NULL, NULL, NULL} +}; #endif @@ -90,8 +92,8 @@ void RE_engines_exit(void) { RenderEngineType *type, *next; - for (type=R_engines.first; type; type=next) { - next= type->next; + for (type = R_engines.first; type; type = next) { + next = type->next; BLI_remlink(&R_engines, type); @@ -108,16 +110,16 @@ RenderEngineType *RE_engines_find(const char *idname) { RenderEngineType *type; - type= BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname)); + type = BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname)); if (!type) - type= &internal_render_type; + type = &internal_render_type; return type; } int RE_engine_is_external(Render *re) { - RenderEngineType *type= RE_engines_find(re->r.engine); + RenderEngineType *type = RE_engines_find(re->r.engine); return (type && type->render); } @@ -126,7 +128,7 @@ int RE_engine_is_external(Render *re) RenderEngine *RE_engine_create(RenderEngineType *type) { RenderEngine *engine = MEM_callocN(sizeof(RenderEngine), "RenderEngine"); - engine->type= type; + engine->type = type; return engine; } @@ -149,7 +151,7 @@ void RE_engine_free(RenderEngine *engine) RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h) { - Render *re= engine->re; + Render *re = engine->re; RenderResult *result; rcti disprect; @@ -160,17 +162,17 @@ RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, CLAMP(h, 0, re->result->recty); if (x + w > re->result->rectx) - w= re->result->rectx - x; + w = re->result->rectx - x; if (y + h > re->result->recty) - h= re->result->recty - y; + h = re->result->recty - y; /* allocate a render result */ disprect.xmin = x; - disprect.xmax = x+w; + disprect.xmax = x + w; disprect.ymin = y; - disprect.ymax = y+h; + disprect.ymax = y + h; - result= render_result_new(re, &disprect, 0, RR_USE_MEM); + result = render_result_new(re, &disprect, 0, RR_USE_MEM); BLI_addtail(&engine->fullresult, result); result->tilerect.xmin += re->disprect.xmin; @@ -183,17 +185,17 @@ RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, void RE_engine_update_result(RenderEngine *engine, RenderResult *result) { - Render *re= engine->re; + Render *re = engine->re; if (result) { - result->renlay= result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; // weak, draws first layer always re->display_draw(re->ddh, result, NULL); } } void RE_engine_end_result(RenderEngine *engine, RenderResult *result) { - Render *re= engine->re; + Render *re = engine->re; if (!result) return; @@ -204,7 +206,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result) /* draw */ if (!re->test_break(re->tbh)) { - result->renlay= result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; // weak, draws first layer always re->display_draw(re->ddh, result, NULL); } @@ -216,7 +218,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result) int RE_engine_test_break(RenderEngine *engine) { - Render *re= engine->re; + Render *re = engine->re; if (re) return re->test_break(re->tbh); @@ -228,34 +230,34 @@ int RE_engine_test_break(RenderEngine *engine) void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info) { - Render *re= engine->re; + Render *re = engine->re; /* stats draw callback */ if (re) { - re->i.statstr= stats; - re->i.infostr= info; + re->i.statstr = stats; + re->i.infostr = info; re->stats_draw(re->sdh, &re->i); - re->i.infostr= NULL; - re->i.statstr= NULL; + re->i.infostr = NULL; + re->i.statstr = NULL; } /* set engine text */ if (engine->text) { MEM_freeN(engine->text); - engine->text= NULL; + engine->text = NULL; } if (stats && stats[0] && info && info[0]) - engine->text= BLI_sprintfN("%s | %s", stats, info); + engine->text = BLI_sprintfN("%s | %s", stats, info); else if (info && info[0]) - engine->text= BLI_strdup(info); + engine->text = BLI_strdup(info); else if (stats && stats[0]) - engine->text= BLI_strdup(stats); + engine->text = BLI_strdup(stats); } void RE_engine_update_progress(RenderEngine *engine, float progress) { - Render *re= engine->re; + Render *re = engine->re; if (re) { CLAMP(progress, 0.0f, 1.0f); @@ -272,7 +274,7 @@ void RE_engine_report(RenderEngine *engine, int type, const char *msg) int RE_engine_render(Render *re, int do_all) { - RenderEngineType *type= RE_engines_find(re->r.engine); + RenderEngineType *type = RE_engines_find(re->r.engine); RenderEngine *engine; /* verify if we can render */ @@ -287,24 +289,24 @@ int RE_engine_render(Render *re, int do_all) /* create render result */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if (re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { + if (re->result == NULL || !(re->r.scemode & R_PREVIEWBUTS)) { if (re->result) render_result_free(re->result); - re->result= render_result_new(re, &re->disprect, 0, 0); + re->result = render_result_new(re, &re->disprect, 0, 0); } BLI_rw_mutex_unlock(&re->resultmutex); - if (re->result==NULL) + if (re->result == NULL) return 1; /* set render info */ - re->i.cfra= re->scene->r.cfra; - BLI_strncpy(re->i.scenename, re->scene->id.name+2, sizeof(re->i.scenename)); - re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0; + re->i.cfra = re->scene->r.cfra; + BLI_strncpy(re->i.scenename, re->scene->id.name + 2, sizeof(re->i.scenename)); + re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0; /* render */ engine = RE_engine_create(type); - engine->re= re; + engine->re = re; if (re->flag & R_ANIMATION) engine->flag |= RE_ENGINE_ANIMATION; @@ -312,7 +314,7 @@ int RE_engine_render(Render *re, int do_all) engine->flag |= RE_ENGINE_PREVIEW; engine->camera_override = re->camera_override; - if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) + if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_PREVIEWBUTS)) == 0) BKE_scene_update_for_newframe(re->main, re->scene, re->lay); if (type->update) diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index c0382834987..33a777381aa 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -87,12 +87,12 @@ static void init_render_jit(Render *re) { - static float jit[32][2]; /* simple caching */ - static float mblur_jit[32][2]; /* simple caching */ - static int lastjit= 0; - static int last_mblur_jit= 0; + static float jit[32][2]; /* simple caching */ + static float mblur_jit[32][2]; /* simple caching */ + static int lastjit = 0; + static int last_mblur_jit = 0; - if (lastjit!=re->r.osa || last_mblur_jit != re->r.mblur_samples) { + if (lastjit != re->r.osa || last_mblur_jit != re->r.mblur_samples) { memset(jit, 0, sizeof(jit)); BLI_jitter_init(jit[0], re->r.osa); @@ -100,10 +100,10 @@ static void init_render_jit(Render *re) BLI_jitter_init(mblur_jit[0], re->r.mblur_samples); } - lastjit= re->r.osa; + lastjit = re->r.osa; memcpy(re->jit, jit, sizeof(jit)); - last_mblur_jit= re->r.mblur_samples; + last_mblur_jit = re->r.mblur_samples; memcpy(re->mblur_jit, mblur_jit, sizeof(mblur_jit)); } @@ -113,135 +113,135 @@ static void init_render_jit(Render *re) static float filt_quadratic(float x) { if (x < 0.0f) x = -x; - if (x < 0.5f) return 0.75f-(x*x); - if (x < 1.5f) return 0.50f*(x-1.5f)*(x-1.5f); + if (x < 0.5f) return 0.75f - (x * x); + if (x < 1.5f) return 0.50f * (x - 1.5f) * (x - 1.5f); return 0.0f; } static float filt_cubic(float x) { - float x2= x*x; + float x2 = x * x; if (x < 0.0f) x = -x; - if (x < 1.0f) return 0.5f*x*x2 - x2 + 2.0f/3.0f; - if (x < 2.0f) return (2.0f-x)*(2.0f-x)*(2.0f-x)/6.0f; + if (x < 1.0f) return 0.5f * x * x2 - x2 + 2.0f / 3.0f; + if (x < 2.0f) return (2.0f - x) * (2.0f - x) * (2.0f - x) / 6.0f; return 0.0f; } static float filt_catrom(float x) { - float x2= x*x; + float x2 = x * x; if (x < 0.0f) x = -x; - if (x < 1.0f) return 1.5f*x2*x - 2.5f*x2 + 1.0f; - if (x < 2.0f) return -0.5f*x2*x + 2.5f*x2 - 4.0f*x + 2.0f; + if (x < 1.0f) return 1.5f * x2 * x - 2.5f * x2 + 1.0f; + if (x < 2.0f) return -0.5f * x2 * x + 2.5f * x2 - 4.0f * x + 2.0f; return 0.0f; } -static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */ +static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */ { - float b = 1.0f/3.0f, c = 1.0f/3.0f; - float p0 = ( 6.0f - 2.0f*b ) / 6.0f; - float p2 = (-18.0f + 12.0f*b + 6.0f*c) / 6.0f; - float p3 = ( 12.0f - 9.0f*b - 6.0f*c) / 6.0f; - float q0 = ( 8.0f*b + 24.0f*c) / 6.0f; - float q1 = ( - 12.0f *b - 48.0f*c) / 6.0f; - float q2 = ( 6.0f *b + 30.0f*c) / 6.0f; - float q3 = ( - b - 6.0f*c) / 6.0f; - - if (x<-2.0f) return 0.0f; - if (x<-1.0f) return (q0-x*(q1-x*(q2-x*q3))); - if (x< 0.0f) return (p0+x*x*(p2-x*p3)); - if (x< 1.0f) return (p0+x*x*(p2+x*p3)); - if (x< 2.0f) return (q0+x*(q1+x*(q2+x*q3))); + float b = 1.0f / 3.0f, c = 1.0f / 3.0f; + float p0 = ( 6.0f - 2.0f * b) / 6.0f; + float p2 = (-18.0f + 12.0f * b + 6.0f * c) / 6.0f; + float p3 = ( 12.0f - 9.0f * b - 6.0f * c) / 6.0f; + float q0 = ( 8.0f * b + 24.0f * c) / 6.0f; + float q1 = ( -12.0f * b - 48.0f * c) / 6.0f; + float q2 = ( 6.0f * b + 30.0f * c) / 6.0f; + float q3 = ( -b - 6.0f * c) / 6.0f; + + if (x < -2.0f) return 0.0f; + if (x < -1.0f) return (q0 - x * (q1 - x * (q2 - x * q3))); + if (x < 0.0f) return (p0 + x * x * (p2 - x * p3)); + if (x < 1.0f) return (p0 + x * x * (p2 + x * p3)); + if (x < 2.0f) return (q0 + x * (q1 + x * (q2 + x * q3))); return 0.0f; } /* x ranges from -1 to 1 */ float RE_filter_value(int type, float x) { - float gaussfac= 1.6f; + float gaussfac = 1.6f; - x= ABS(x); + x = ABS(x); switch (type) { case R_FILTER_BOX: - if (x>1.0f) return 0.0f; + if (x > 1.0f) return 0.0f; return 1.0f; case R_FILTER_TENT: - if (x>1.0f) return 0.0f; - return 1.0f-x; + if (x > 1.0f) return 0.0f; + return 1.0f - x; case R_FILTER_GAUSS: - x*= gaussfac; - return (1.0f/expf(x*x) - 1.0f/expf(gaussfac*gaussfac*2.25f)); + x *= gaussfac; + return (1.0f / expf(x * x) - 1.0f / expf(gaussfac * gaussfac * 2.25f)); case R_FILTER_MITCH: - return filt_mitchell(x*gaussfac); + return filt_mitchell(x * gaussfac); case R_FILTER_QUAD: - return filt_quadratic(x*gaussfac); + return filt_quadratic(x * gaussfac); case R_FILTER_CUBIC: - return filt_cubic(x*gaussfac); + return filt_cubic(x * gaussfac); case R_FILTER_CATROM: - return filt_catrom(x*gaussfac); + return filt_catrom(x * gaussfac); } return 0.0f; } static float calc_weight(Render *re, float *weight, int i, int j) { - float x, y, dist, totw= 0.0; + float x, y, dist, totw = 0.0; int a; - for (a=0; a<re->osa; a++) { - x= re->jit[a][0] + i; - y= re->jit[a][1] + j; - dist= sqrt(x*x+y*y); + for (a = 0; a < re->osa; a++) { + x = re->jit[a][0] + i; + y = re->jit[a][1] + j; + dist = sqrt(x * x + y * y); - weight[a]= 0.0; + weight[a] = 0.0; /* Weighting choices */ switch (re->r.filtertype) { - case R_FILTER_BOX: - if (i==0 && j==0) weight[a]= 1.0; - break; + case R_FILTER_BOX: + if (i == 0 && j == 0) weight[a] = 1.0; + break; - case R_FILTER_TENT: - if (dist < re->r.gauss) - weight[a]= re->r.gauss - dist; - break; + case R_FILTER_TENT: + if (dist < re->r.gauss) + weight[a] = re->r.gauss - dist; + break; - case R_FILTER_GAUSS: - x = dist*re->r.gauss; - weight[a]= (1.0f/expf(x*x) - 1.0f/expf(re->r.gauss*re->r.gauss*2.25f)); - break; + case R_FILTER_GAUSS: + x = dist * re->r.gauss; + weight[a] = (1.0f / expf(x * x) - 1.0f / expf(re->r.gauss * re->r.gauss * 2.25f)); + break; - case R_FILTER_MITCH: - weight[a]= filt_mitchell(dist*re->r.gauss); - break; + case R_FILTER_MITCH: + weight[a] = filt_mitchell(dist * re->r.gauss); + break; - case R_FILTER_QUAD: - weight[a]= filt_quadratic(dist*re->r.gauss); - break; + case R_FILTER_QUAD: + weight[a] = filt_quadratic(dist * re->r.gauss); + break; - case R_FILTER_CUBIC: - weight[a]= filt_cubic(dist*re->r.gauss); - break; + case R_FILTER_CUBIC: + weight[a] = filt_cubic(dist * re->r.gauss); + break; - case R_FILTER_CATROM: - weight[a]= filt_catrom(dist*re->r.gauss); - break; + case R_FILTER_CATROM: + weight[a] = filt_catrom(dist * re->r.gauss); + break; } - totw+= weight[a]; + totw += weight[a]; } return totw; @@ -252,21 +252,21 @@ void free_sample_tables(Render *re) int a; if (re->samples) { - for (a=0; a<9; a++) { + for (a = 0; a < 9; a++) { MEM_freeN(re->samples->fmask1[a]); MEM_freeN(re->samples->fmask2[a]); } MEM_freeN(re->samples->centmask); MEM_freeN(re->samples); - re->samples= NULL; + re->samples = NULL; } } /* based on settings in render, it makes the lookup tables */ void make_sample_tables(Render *re) { - static int firsttime= 1; + static int firsttime = 1; SampleTables *st; float flweight[32]; float weight[32], totw, val, *fpx1, *fpx2, *fpy1, *fpy2, *m3, *m4; @@ -274,27 +274,27 @@ void make_sample_tables(Render *re) /* optimization tables, only once */ if (firsttime) { - firsttime= 0; + firsttime = 0; } free_sample_tables(re); - init_render_jit(re); /* needed for mblur too */ + init_render_jit(re); /* needed for mblur too */ - if (re->osa==0) { + if (re->osa == 0) { /* just prevents cpu cycles for larger render and copying */ - re->r.filtertype= 0; + re->r.filtertype = 0; return; } - st= re->samples= MEM_callocN(sizeof(SampleTables), "sample tables"); + st = re->samples = MEM_callocN(sizeof(SampleTables), "sample tables"); - for (a=0; a<9;a++) { - st->fmask1[a]= MEM_callocN(256*sizeof(float), "initfilt"); - st->fmask2[a]= MEM_callocN(256*sizeof(float), "initfilt"); + for (a = 0; a < 9; a++) { + st->fmask1[a] = MEM_callocN(256 * sizeof(float), "initfilt"); + st->fmask2[a] = MEM_callocN(256 * sizeof(float), "initfilt"); } - for (a=0; a<256; a++) { - st->cmask[a]= 0; + for (a = 0; a < 256; a++) { + st->cmask[a] = 0; if (a & 1) st->cmask[a]++; if (a & 2) st->cmask[a]++; if (a & 4) st->cmask[a]++; @@ -305,64 +305,64 @@ void make_sample_tables(Render *re) if (a & 128) st->cmask[a]++; } - st->centmask= MEM_mallocN((1<<re->osa), "Initfilt3"); + st->centmask = MEM_mallocN((1 << re->osa), "Initfilt3"); - for (a=0; a<16; a++) { - st->centLut[a]= -0.45f+((float)a)/16.0f; + for (a = 0; a < 16; a++) { + st->centLut[a] = -0.45f + ((float)a) / 16.0f; } /* calculate totw */ - totw= 0.0; - for (j= -1; j<2; j++) { - for (i= -1; i<2; i++) { - totw+= calc_weight(re, weight, i, j); + totw = 0.0; + for (j = -1; j < 2; j++) { + for (i = -1; i < 2; i++) { + totw += calc_weight(re, weight, i, j); } } - for (j= -1; j<2; j++) { - for (i= -1; i<2; i++) { + for (j = -1; j < 2; j++) { + for (i = -1; i < 2; i++) { /* calculate using jit, with offset the weights */ memset(weight, 0, sizeof(weight)); calc_weight(re, weight, i, j); - for (a=0; a<16; a++) flweight[a]= weight[a]*(1.0f/totw); + for (a = 0; a < 16; a++) flweight[a] = weight[a] * (1.0f / totw); - m3= st->fmask1[ 3*(j+1)+i+1 ]; - m4= st->fmask2[ 3*(j+1)+i+1 ]; + m3 = st->fmask1[3 * (j + 1) + i + 1]; + m4 = st->fmask2[3 * (j + 1) + i + 1]; - for (a=0; a<256; a++) { + for (a = 0; a < 256; a++) { if (a & 1) { - m3[a]+= flweight[0]; - m4[a]+= flweight[8]; + m3[a] += flweight[0]; + m4[a] += flweight[8]; } if (a & 2) { - m3[a]+= flweight[1]; - m4[a]+= flweight[9]; + m3[a] += flweight[1]; + m4[a] += flweight[9]; } if (a & 4) { - m3[a]+= flweight[2]; - m4[a]+= flweight[10]; + m3[a] += flweight[2]; + m4[a] += flweight[10]; } if (a & 8) { - m3[a]+= flweight[3]; - m4[a]+= flweight[11]; + m3[a] += flweight[3]; + m4[a] += flweight[11]; } if (a & 16) { - m3[a]+= flweight[4]; - m4[a]+= flweight[12]; + m3[a] += flweight[4]; + m4[a] += flweight[12]; } if (a & 32) { - m3[a]+= flweight[5]; - m4[a]+= flweight[13]; + m3[a] += flweight[5]; + m4[a] += flweight[13]; } if (a & 64) { - m3[a]+= flweight[6]; - m4[a]+= flweight[14]; + m3[a] += flweight[6]; + m4[a] += flweight[14]; } if (a & 128) { - m3[a]+= flweight[7]; - m4[a]+= flweight[15]; + m3[a] += flweight[7]; + m4[a] += flweight[15]; } } } @@ -370,71 +370,71 @@ void make_sample_tables(Render *re) /* centmask: the correct subpixel offset per mask */ - fpx1= MEM_mallocN(256*sizeof(float), "initgauss4"); - fpx2= MEM_mallocN(256*sizeof(float), "initgauss4"); - fpy1= MEM_mallocN(256*sizeof(float), "initgauss4"); - fpy2= MEM_mallocN(256*sizeof(float), "initgauss4"); - for (a=0; a<256; a++) { - fpx1[a]= fpx2[a]= 0.0; - fpy1[a]= fpy2[a]= 0.0; + fpx1 = MEM_mallocN(256 * sizeof(float), "initgauss4"); + fpx2 = MEM_mallocN(256 * sizeof(float), "initgauss4"); + fpy1 = MEM_mallocN(256 * sizeof(float), "initgauss4"); + fpy2 = MEM_mallocN(256 * sizeof(float), "initgauss4"); + for (a = 0; a < 256; a++) { + fpx1[a] = fpx2[a] = 0.0; + fpy1[a] = fpy2[a] = 0.0; if (a & 1) { - fpx1[a]+= re->jit[0][0]; - fpy1[a]+= re->jit[0][1]; - fpx2[a]+= re->jit[8][0]; - fpy2[a]+= re->jit[8][1]; + fpx1[a] += re->jit[0][0]; + fpy1[a] += re->jit[0][1]; + fpx2[a] += re->jit[8][0]; + fpy2[a] += re->jit[8][1]; } if (a & 2) { - fpx1[a]+= re->jit[1][0]; - fpy1[a]+= re->jit[1][1]; - fpx2[a]+= re->jit[9][0]; - fpy2[a]+= re->jit[9][1]; + fpx1[a] += re->jit[1][0]; + fpy1[a] += re->jit[1][1]; + fpx2[a] += re->jit[9][0]; + fpy2[a] += re->jit[9][1]; } if (a & 4) { - fpx1[a]+= re->jit[2][0]; - fpy1[a]+= re->jit[2][1]; - fpx2[a]+= re->jit[10][0]; - fpy2[a]+= re->jit[10][1]; + fpx1[a] += re->jit[2][0]; + fpy1[a] += re->jit[2][1]; + fpx2[a] += re->jit[10][0]; + fpy2[a] += re->jit[10][1]; } if (a & 8) { - fpx1[a]+= re->jit[3][0]; - fpy1[a]+= re->jit[3][1]; - fpx2[a]+= re->jit[11][0]; - fpy2[a]+= re->jit[11][1]; + fpx1[a] += re->jit[3][0]; + fpy1[a] += re->jit[3][1]; + fpx2[a] += re->jit[11][0]; + fpy2[a] += re->jit[11][1]; } if (a & 16) { - fpx1[a]+= re->jit[4][0]; - fpy1[a]+= re->jit[4][1]; - fpx2[a]+= re->jit[12][0]; - fpy2[a]+= re->jit[12][1]; + fpx1[a] += re->jit[4][0]; + fpy1[a] += re->jit[4][1]; + fpx2[a] += re->jit[12][0]; + fpy2[a] += re->jit[12][1]; } if (a & 32) { - fpx1[a]+= re->jit[5][0]; - fpy1[a]+= re->jit[5][1]; - fpx2[a]+= re->jit[13][0]; - fpy2[a]+= re->jit[13][1]; + fpx1[a] += re->jit[5][0]; + fpy1[a] += re->jit[5][1]; + fpx2[a] += re->jit[13][0]; + fpy2[a] += re->jit[13][1]; } if (a & 64) { - fpx1[a]+= re->jit[6][0]; - fpy1[a]+= re->jit[6][1]; - fpx2[a]+= re->jit[14][0]; - fpy2[a]+= re->jit[14][1]; + fpx1[a] += re->jit[6][0]; + fpy1[a] += re->jit[6][1]; + fpx2[a] += re->jit[14][0]; + fpy2[a] += re->jit[14][1]; } if (a & 128) { - fpx1[a]+= re->jit[7][0]; - fpy1[a]+= re->jit[7][1]; - fpx2[a]+= re->jit[15][0]; - fpy2[a]+= re->jit[15][1]; + fpx1[a] += re->jit[7][0]; + fpy1[a] += re->jit[7][1]; + fpx2[a] += re->jit[15][0]; + fpy2[a] += re->jit[15][1]; } } - for (a= (1<<re->osa)-1; a>0; a--) { - val= st->cmask[a & 255] + st->cmask[a>>8]; - i= 8+(15.9f*(fpy1[a & 255]+fpy2[a>>8])/val); + for (a = (1 << re->osa) - 1; a > 0; a--) { + val = st->cmask[a & 255] + st->cmask[a >> 8]; + i = 8 + (15.9f * (fpy1[a & 255] + fpy2[a >> 8]) / val); CLAMP(i, 0, 15); - j= 8+(15.9f*(fpx1[a & 255]+fpx2[a>>8])/val); + j = 8 + (15.9f * (fpx1[a & 255] + fpx2[a >> 8]) / val); CLAMP(j, 0, 15); - i= j + (i<<4); - st->centmask[a]= i; + i = j + (i << 4); + st->centmask[a] = i; } MEM_freeN(fpx1); @@ -455,13 +455,13 @@ static void re_camera_params_get(Render *re, CameraParams *params, Object *cam_o { copy_m4_m4(re->winmat, params->winmat); - re->clipsta= params->clipsta; - re->clipend= params->clipend; + re->clipsta = params->clipsta; + re->clipend = params->clipend; - re->ycor= params->ycor; - re->viewdx= params->viewdx; - re->viewdy= params->viewdy; - re->viewplane= params->viewplane; + re->ycor = params->ycor; + re->viewdx = params->viewdx; + re->viewdy = params->viewdy; + re->viewplane = params->viewplane; BKE_camera_object_mode(&re->r, cam_ob); } @@ -474,12 +474,12 @@ void RE_SetEnvmapCamera(Render *re, Object *cam_ob, float viewscale, float clips BKE_camera_params_init(¶ms); BKE_camera_params_from_object(¶ms, cam_ob); - params.lens= 16.0f*viewscale; - params.sensor_x= 32.0f; - params.sensor_y= 32.0f; + params.lens = 16.0f * viewscale; + params.sensor_x = 32.0f; + params.sensor_y = 32.0f; params.sensor_fit = CAMERA_SENSOR_FIT_AUTO; - params.clipsta= clipsta; - params.clipend= clipend; + params.clipsta = clipsta; + params.clipend = clipend; /* compute matrix, viewplane, .. */ BKE_camera_params_compute_viewplane(¶ms, re->winx, re->winy, 1.0f, 1.0f); @@ -499,9 +499,9 @@ void RE_SetCamera(Render *re, Object *cam_ob) BKE_camera_params_init(¶ms); BKE_camera_params_from_object(¶ms, cam_ob); - params.use_fields= (re->r.mode & R_FIELDS); - params.field_second= (re->flag & R_SEC_FIELD); - params.field_odd= (re->r.mode & R_ODDFIELD); + params.use_fields = (re->r.mode & R_FIELDS); + params.field_second = (re->flag & R_SEC_FIELD); + params.field_odd = (re->r.mode & R_ODDFIELD); /* compute matrix, viewplane, .. */ BKE_camera_params_compute_viewplane(¶ms, re->winx, re->winy, re->r.xasp, re->r.yasp); @@ -513,13 +513,13 @@ void RE_SetCamera(Render *re, Object *cam_ob) void RE_SetPixelSize(Render *re, float pixsize) { - re->viewdx= pixsize; - re->viewdy= re->ycor*pixsize; + re->viewdx = pixsize; + re->viewdy = re->ycor * pixsize; } void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4]) { - re->r.cfra= frame; + re->r.cfra = frame; RE_SetCamera(re, camera); copy_m4_m4(mat, re->winmat); } @@ -529,12 +529,12 @@ void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, flo void freeparts(Render *re) { - RenderPart *part= re->parts.first; + RenderPart *part = re->parts.first; while (part) { if (part->rectp) MEM_freeN(part->rectp); if (part->rectz) MEM_freeN(part->rectz); - part= part->next; + part = part->next; } BLI_freelistN(&re->parts); } @@ -547,91 +547,91 @@ void initparts(Render *re) freeparts(re); /* this is render info for caller, is not reset when parts are freed! */ - re->i.totpart= 0; - re->i.curpart= 0; + re->i.totpart = 0; + re->i.curpart = 0; re->i.partsdone = FALSE; /* just for readable code.. */ - xminb= re->disprect.xmin; - yminb= re->disprect.ymin; - xmaxb= re->disprect.xmax; - ymaxb= re->disprect.ymax; + xminb = re->disprect.xmin; + yminb = re->disprect.ymin; + xmaxb = re->disprect.xmax; + ymaxb = re->disprect.ymax; - xparts= re->r.xparts; - yparts= re->r.yparts; + xparts = re->r.xparts; + yparts = re->r.yparts; /* mininum part size, but for exr tile saving it was checked already */ - if (!(re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE))) { + if (!(re->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE))) { if (re->r.mode & R_PANORAMA) { - if (ceil(re->rectx/(float)xparts) < 8) - xparts= 1 + re->rectx/8; + if (ceil(re->rectx / (float)xparts) < 8) + xparts = 1 + re->rectx / 8; } else - if (ceil(re->rectx/(float)xparts) < 64) - xparts= 1 + re->rectx/64; + if (ceil(re->rectx / (float)xparts) < 64) + xparts = 1 + re->rectx / 64; - if (ceil(re->recty/(float)yparts) < 64) - yparts= 1 + re->recty/64; + if (ceil(re->recty / (float)yparts) < 64) + yparts = 1 + re->recty / 64; } /* part size */ - partx= ceil(re->rectx/(float)xparts); - party= ceil(re->recty/(float)yparts); + partx = ceil(re->rectx / (float)xparts); + party = ceil(re->recty / (float)yparts); - re->xparts= xparts; - re->yparts= yparts; - re->partx= partx; - re->party= party; + re->xparts = xparts; + re->yparts = yparts; + re->partx = partx; + re->party = party; /* calculate rotation factor of 1 pixel */ if (re->r.mode & R_PANORAMA) - re->panophi= panorama_pixel_rot(re); + re->panophi = panorama_pixel_rot(re); - for (nr=0; nr<xparts*yparts; nr++) { + for (nr = 0; nr < xparts * yparts; nr++) { rcti disprect; int rectx, recty; - xd= (nr % xparts); - yd= (nr-xd)/xparts; + xd = (nr % xparts); + yd = (nr - xd) / xparts; - disprect.xmin = xminb+ xd*partx; - disprect.ymin = yminb+ yd*party; + disprect.xmin = xminb + xd * partx; + disprect.ymin = yminb + yd * party; /* ensure we cover the entire picture, so last parts go to end */ - if (xd<xparts-1) { + if (xd < xparts - 1) { disprect.xmax = disprect.xmin + partx; if (disprect.xmax > xmaxb) disprect.xmax = xmaxb; } else disprect.xmax = xmaxb; - if (yd<yparts-1) { + if (yd < yparts - 1) { disprect.ymax = disprect.ymin + party; if (disprect.ymax > ymaxb) disprect.ymax = ymaxb; } else disprect.ymax = ymaxb; - rectx= disprect.xmax - disprect.xmin; - recty= disprect.ymax - disprect.ymin; + rectx = disprect.xmax - disprect.xmin; + recty = disprect.ymax - disprect.ymin; /* so, now can we add this part? */ - if (rectx>0 && recty>0) { - RenderPart *pa= MEM_callocN(sizeof(RenderPart), "new part"); + if (rectx > 0 && recty > 0) { + RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part"); /* Non-box filters need 2 pixels extra to work */ if ((re->r.filtertype || (re->r.mode & R_EDGE))) { - pa->crop= 2; + pa->crop = 2; disprect.xmin -= pa->crop; disprect.ymin -= pa->crop; disprect.xmax += pa->crop; disprect.ymax += pa->crop; - rectx+= 2*pa->crop; - recty+= 2*pa->crop; + rectx += 2 * pa->crop; + recty += 2 * pa->crop; } - pa->disprect= disprect; - pa->rectx= rectx; - pa->recty= recty; + pa->disprect = disprect; + pa->rectx = rectx; + pa->recty = recty; BLI_addtail(&re->parts, pa); re->i.totpart++; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index a730868dadd..e3ecfc49a4b 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -248,6 +248,18 @@ Render *RE_GetRender(const char *name) return re; } +Render *RE_GetRender_FromData(const RenderData *rd) +{ + Render *re; + + /* search for existing renders */ + for (re = RenderGlobal.renderlist.first; re; re = re->next) + if (&re->r == rd) + break; + + return re; +} + /* if you want to know exactly what has been done */ RenderResult *RE_AcquireResultRead(Render *re) { diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index b282cc8459f..2acf3a4bc77 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -78,12 +78,12 @@ void addAlphaOverFloat(float dest[4], const float source[4]) /* d = s + (1-alpha_s)d*/ float mul; - mul= 1.0f - source[3]; + mul = 1.0f - source[3]; - dest[0]= (mul*dest[0]) + source[0]; - dest[1]= (mul*dest[1]) + source[1]; - dest[2]= (mul*dest[2]) + source[2]; - dest[3]= (mul*dest[3]) + source[3]; + dest[0] = (mul * dest[0]) + source[0]; + dest[1] = (mul * dest[1]) + source[1]; + dest[2] = (mul * dest[2]) + source[2]; + dest[3] = (mul * dest[3]) + source[3]; } @@ -94,12 +94,12 @@ void addAlphaUnderFloat(float dest[4], const float source[4]) { float mul; - mul= 1.0f - dest[3]; + mul = 1.0f - dest[3]; - dest[0]+= (mul*source[0]); - dest[1]+= (mul*source[1]); - dest[2]+= (mul*source[2]); - dest[3]+= (mul*source[3]); + dest[0] += (mul * source[0]); + dest[1] += (mul * source[1]); + dest[2] += (mul * source[2]); + dest[3] += (mul * source[3]); } @@ -111,36 +111,36 @@ void addalphaAddfacFloat(float dest[4], const float source[4], char addfac) /* Addfac is a number between 0 and 1: rescale */ /* final target is to diminish the influence of dest when addfac rises */ - m = 1.0f - ( source[3] * ((255 - addfac) / 255.0f)); + m = 1.0f - (source[3] * ((255 - addfac) / 255.0f)); /* blend colors*/ - c= (m * dest[0]) + source[0]; + c = (m * dest[0]) + source[0]; #ifdef RE_FLOAT_COLOR_CLIPPING if (c >= RE_FULL_COLOR_FLOAT) dest[0] = RE_FULL_COLOR_FLOAT; else #endif - dest[0]= c; + dest[0] = c; - c= (m * dest[1]) + source[1]; + c = (m * dest[1]) + source[1]; #ifdef RE_FLOAT_COLOR_CLIPPING if (c >= RE_FULL_COLOR_FLOAT) dest[1] = RE_FULL_COLOR_FLOAT; else #endif - dest[1]= c; + dest[1] = c; - c= (m * dest[2]) + source[2]; + c = (m * dest[2]) + source[2]; #ifdef RE_FLOAT_COLOR_CLIPPING if (c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT; else #endif - dest[2]= c; + dest[2] = c; - c= (m * dest[3]) + source[3]; + c = (m * dest[3]) + source[3]; #ifdef RE_ALPHA_CLIPPING if (c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT; else #endif - dest[3]= c; + dest[3] = c; } @@ -151,81 +151,81 @@ void addalphaAddfacFloat(float dest[4], const float source[4], char addfac) void add_filt_fmask(unsigned int mask, const float col[4], float *rowbuf, int row_w) { /* calc the value of mask */ - float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2; + float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2; float *rb1, *rb2, *rb3; float val, r, g, b, al; unsigned int a, maskand, maskshift; int j; - r= col[0]; - g= col[1]; - b= col[2]; - al= col[3]; - - rb2= rowbuf-4; - rb3= rb2-4*row_w; - rb1= rb2+4*row_w; - - maskand= (mask & 255); - maskshift= (mask >>8); - - for (j=2; j>=0; j--) { - - a= j; - - val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if (val!=0.0f) { - rb1[0]+= val*r; - rb1[1]+= val*g; - rb1[2]+= val*b; - rb1[3]+= val*al; + r = col[0]; + g = col[1]; + b = col[2]; + al = col[3]; + + rb2 = rowbuf - 4; + rb3 = rb2 - 4 * row_w; + rb1 = rb2 + 4 * row_w; + + maskand = (mask & 255); + maskshift = (mask >> 8); + + for (j = 2; j >= 0; j--) { + + a = j; + + val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); + if (val != 0.0f) { + rb1[0] += val * r; + rb1[1] += val * g; + rb1[2] += val * b; + rb1[3] += val * al; } - a+=3; + a += 3; - val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if (val!=0.0f) { - rb2[0]+= val*r; - rb2[1]+= val*g; - rb2[2]+= val*b; - rb2[3]+= val*al; + val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); + if (val != 0.0f) { + rb2[0] += val * r; + rb2[1] += val * g; + rb2[2] += val * b; + rb2[3] += val * al; } - a+=3; + a += 3; - val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if (val!=0.0f) { - rb3[0]+= val*r; - rb3[1]+= val*g; - rb3[2]+= val*b; - rb3[3]+= val*al; + val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); + if (val != 0.0f) { + rb3[0] += val * r; + rb3[1] += val * g; + rb3[2] += val * b; + rb3[3] += val * al; } - rb1+= 4; - rb2+= 4; - rb3+= 4; + rb1 += 4; + rb2 += 4; + rb3 += 4; } } void mask_array(unsigned int mask, float filt[][3]) { - float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2; - unsigned int maskand= (mask & 255); - unsigned int maskshift= (mask >>8); + float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2; + unsigned int maskand = (mask & 255); + unsigned int maskshift = (mask >> 8); int a, j; - for (j=2; j>=0; j--) { + for (j = 2; j >= 0; j--) { - a= j; + a = j; - filt[2][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); + filt[2][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); - a+=3; + a += 3; - filt[1][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); + filt[1][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); - a+=3; + a += 3; - filt[0][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); + filt[0][2 - j] = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); } } @@ -247,61 +247,61 @@ void add_filt_fmask_coord(float filt[][3], const float col[4], float *rowbuf, in float *fpoin[3][3]; float val, r, g, b, al, lfilt[3][3]; - r= col[0]; - g= col[1]; - b= col[2]; - al= col[3]; + r = col[0]; + g = col[1]; + b = col[2]; + al = col[3]; memcpy(lfilt, filt, sizeof(lfilt)); - fpoin[0][1]= rowbuf-4*row_w; - fpoin[1][1]= rowbuf; - fpoin[2][1]= rowbuf+4*row_w; - - fpoin[0][0]= fpoin[0][1] - 4; - fpoin[1][0]= fpoin[1][1] - 4; - fpoin[2][0]= fpoin[2][1] - 4; - - fpoin[0][2]= fpoin[0][1] + 4; - fpoin[1][2]= fpoin[1][1] + 4; - fpoin[2][2]= fpoin[2][1] + 4; - - if (y==0) { - fpoin[0][0]= fpoin[1][0]; - fpoin[0][1]= fpoin[1][1]; - fpoin[0][2]= fpoin[1][2]; + fpoin[0][1] = rowbuf - 4 * row_w; + fpoin[1][1] = rowbuf; + fpoin[2][1] = rowbuf + 4 * row_w; + + fpoin[0][0] = fpoin[0][1] - 4; + fpoin[1][0] = fpoin[1][1] - 4; + fpoin[2][0] = fpoin[2][1] - 4; + + fpoin[0][2] = fpoin[0][1] + 4; + fpoin[1][2] = fpoin[1][1] + 4; + fpoin[2][2] = fpoin[2][1] + 4; + + if (y == 0) { + fpoin[0][0] = fpoin[1][0]; + fpoin[0][1] = fpoin[1][1]; + fpoin[0][2] = fpoin[1][2]; /* filter needs the opposite value yes! */ - lfilt[0][0]= filt[2][0]; - lfilt[0][1]= filt[2][1]; - lfilt[0][2]= filt[2][2]; + lfilt[0][0] = filt[2][0]; + lfilt[0][1] = filt[2][1]; + lfilt[0][2] = filt[2][2]; } - else if (y==col_h-1) { - fpoin[2][0]= fpoin[1][0]; - fpoin[2][1]= fpoin[1][1]; - fpoin[2][2]= fpoin[1][2]; - - lfilt[2][0]= filt[0][0]; - lfilt[2][1]= filt[0][1]; - lfilt[2][2]= filt[0][2]; + else if (y == col_h - 1) { + fpoin[2][0] = fpoin[1][0]; + fpoin[2][1] = fpoin[1][1]; + fpoin[2][2] = fpoin[1][2]; + + lfilt[2][0] = filt[0][0]; + lfilt[2][1] = filt[0][1]; + lfilt[2][2] = filt[0][2]; } - if (x==0) { - fpoin[2][0]= fpoin[2][1]; - fpoin[1][0]= fpoin[1][1]; - fpoin[0][0]= fpoin[0][1]; - - lfilt[2][0]= filt[2][2]; - lfilt[1][0]= filt[1][2]; - lfilt[0][0]= filt[0][2]; + if (x == 0) { + fpoin[2][0] = fpoin[2][1]; + fpoin[1][0] = fpoin[1][1]; + fpoin[0][0] = fpoin[0][1]; + + lfilt[2][0] = filt[2][2]; + lfilt[1][0] = filt[1][2]; + lfilt[0][0] = filt[0][2]; } - else if (x==row_w-1) { - fpoin[2][2]= fpoin[2][1]; - fpoin[1][2]= fpoin[1][1]; - fpoin[0][2]= fpoin[0][1]; - - lfilt[2][2]= filt[2][0]; - lfilt[1][2]= filt[1][0]; - lfilt[0][2]= filt[0][0]; + else if (x == row_w - 1) { + fpoin[2][2] = fpoin[2][1]; + fpoin[1][2] = fpoin[1][1]; + fpoin[0][2] = fpoin[0][1]; + + lfilt[2][2] = filt[2][0]; + lfilt[1][2] = filt[1][0]; + lfilt[0][2] = filt[0][0]; } @@ -332,46 +332,46 @@ void add_filt_fmask_coord(float filt[][3], const float col[4], float *rowbuf, in void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize) { /* calc the value of mask */ - float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2; + float **fmask1 = R.samples->fmask1, **fmask2 = R.samples->fmask2; float *rb1, *rb2, *rb3; float val; unsigned int a, maskand, maskshift; int i, j; - rb2= rowbuf-pixsize; - rb3= rb2-pixsize*row_w; - rb1= rb2+pixsize*row_w; + rb2 = rowbuf - pixsize; + rb3 = rb2 - pixsize * row_w; + rb1 = rb2 + pixsize * row_w; - maskand= (mask & 255); - maskshift= (mask >>8); + maskand = (mask & 255); + maskshift = (mask >> 8); - for (j=2; j>=0; j--) { + for (j = 2; j >= 0; j--) { - a= j; + a = j; - val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if (val!=0.0f) { - for (i= 0; i<pixsize; i++) - rb1[i]+= val*in[i]; + val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); + if (val != 0.0f) { + for (i = 0; i < pixsize; i++) + rb1[i] += val * in[i]; } - a+=3; + a += 3; - val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if (val!=0.0f) { - for (i= 0; i<pixsize; i++) - rb2[i]+= val*in[i]; + val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); + if (val != 0.0f) { + for (i = 0; i < pixsize; i++) + rb2[i] += val * in[i]; } - a+=3; + a += 3; - val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if (val!=0.0f) { - for (i= 0; i<pixsize; i++) - rb3[i]+= val*in[i]; + val = *(fmask1[a] + maskand) + *(fmask2[a] + maskshift); + if (val != 0.0f) { + for (i = 0; i < pixsize; i++) + rb3[i] += val * in[i]; } - rb1+= pixsize; - rb2+= pixsize; - rb3+= pixsize; + rb1 += pixsize; + rb2 += pixsize; + rb3 += pixsize; } } @@ -380,7 +380,7 @@ void addalphaAddFloat(float dest[4], const float source[4]) { /* Makes me wonder whether this is required... */ - if ( dest[3] < RE_EMPTY_COLOR_FLOAT) { + if (dest[3] < RE_EMPTY_COLOR_FLOAT) { dest[0] = source[0]; dest[1] = source[1]; dest[2] = source[2]; @@ -389,15 +389,12 @@ void addalphaAddFloat(float dest[4], const float source[4]) } /* no clipping! */ - dest[0] = dest[0]+source[0]; - dest[1] = dest[1]+source[1]; - dest[2] = dest[2]+source[2]; - dest[3] = dest[3]+source[3]; + dest[0] = dest[0] + source[0]; + dest[1] = dest[1] + source[1]; + dest[2] = dest[2] + source[2]; + dest[3] = dest[3] + source[3]; } /* ---------------------------------------------------------------------------- */ - - -/* eof pixelblending.c */ diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index f6fe8e8974d..e2a4ef1dca8 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2852,7 +2852,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_bw(&texres.tr); rgb= 0; } if (mtex->texflag & MTEX_NEGATIVE) { @@ -2919,7 +2919,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) if (mtex->mapto & MAP_ALPHA) { if (rgb) { if (texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + else texres.tin = rgb_to_bw(&texres.tr); } col_r[3]*= texres.tin; @@ -3051,7 +3051,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_bw(&texres.tr); rgb= 0; } if (mtex->texflag & MTEX_NEGATIVE) { @@ -3124,7 +3124,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h } } if (mtex->mapto & WOMAP_BLEND) { - if (rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + if (rgb) texres.tin = rgb_to_bw(&texres.tr); *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype); } @@ -3264,7 +3264,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_bw(&texres.tr); rgb= 0; } if (mtex->texflag & MTEX_NEGATIVE) { @@ -3358,7 +3358,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output); if (rgb) { - texr.tin= (0.35f*texr.tr+0.45f*texr.tg+0.2f*texr.tb); + texr.tin = rgb_to_bw(&texr.tr); } else { texr.tr= mtex->r; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 931a81f2543..03bea0122cf 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1866,7 +1866,7 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) alfa= har->alfa; visifac= R.ycor*(har->pixels); - /* all radials added / r^3 == 1.0f! */ + /* all radials added / r^3 == 1.0f! */ visifac /= (har->rad*har->rad*har->rad); visifac*= visifac; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index e4c4e905aa6..c1f85914479 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -376,7 +376,7 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 return normalize * 1.f; } else { /* schlick */ - const float k = 1.55f * g - .55f * g * g * g; + const float k = 1.55f * g - 0.55f * g * g * g; const float kcostheta = k * dot_v3v3(w, wp); return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); } @@ -394,7 +394,7 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 return normalize * (1.f - g * g) / powf(1.f + g * g - 2.f * g * costheta, 1.5f); case MA_VOL_PH_SCHLICK: { - const float k = 1.55f * g - .55f * g * g * g; + const float k = 1.55f * g - 0.55f * g * g * g; const float kcostheta = k * costheta; return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index ecde9bb2de8..c88858c44da 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -2858,7 +2858,7 @@ static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata) p1[0]= v1[0]; p1[1]= v1[1]; - /* official formula 2*p2 - .5*p1 - .5*p3 */ + /* official formula 2*p2 - 0.5*p1 - 0.5*p3 */ p2[0]= -0.5f*p1[0] - 0.5f*p3[0]; p2[1]= -0.5f*p1[1] - 0.5f*p3[1]; diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 4a46568c98c..a1dd999a921 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../blenlib ../blenloader ../editors/include + ../editors/io ../gpu ../freestyle ../imbuf diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index a8c94865aa5..ff1f47cbbaa 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -475,7 +475,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // The current color is ignored if the GL_REPLACE texture environment is used. + /* The current color is ignored if the GL_REPLACE texture environment is used. */ // glTexEnvi(triple->target, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBindTexture(triple->target, 0); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index c46c382c37f..e55f7404798 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -582,7 +582,10 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat) wm->op_undo_depth--; } - if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) && repeat == 0) + /* XXX Disabled the repeat check to address part 2 of #31840. + * Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason + * why this was needed, but worth to note it in case something turns bad. (mont29) */ + if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)/* && repeat == 0 */) wm_operator_reports(C, op, retval, FALSE); if (retval & OPERATOR_FINISHED) { @@ -867,7 +870,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P } else { /* debug, important to leave a while, should never happen */ - printf("invalid operator call '%s'\n", ot->idname); + printf("%s: invalid operator call '%s'\n", __func__, ot->idname); } /* Note, if the report is given as an argument then assume the caller will deal with displaying them @@ -1436,8 +1439,9 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand } } - else - printf("wm_handler_operator_call error\n"); + else { + printf("%s: error - missing modal\n", __func__); + } } else { wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0); @@ -2260,7 +2264,7 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap wmEventHandler *handler; if (!keymap) { - printf("WM_event_add_keymap_handler called with NULL keymap\n"); + printf("%s: called with NULL keymap\n", __func__); return NULL; } @@ -2703,7 +2707,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.y = evt->y = (win->sizey - 1) - cy; } - // Use prevx/prevy so we can calculate the delta later + /* Use prevx/prevy so we can calculate the delta later */ event.prevx = event.x - pd->deltaX; event.prevy = event.y - (-pd->deltaY); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index f39b8f267a5..4acc9191aef 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -157,7 +157,7 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType *)) ot->name = N_("Dummy Name"); } - // XXX All ops should have a description but for now allow them not to. + /* XXX All ops should have a description but for now allow them not to. */ RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : N_("(undocumented operator)")); RNA_def_struct_identifier(ot->srna, ot->idname); @@ -1328,8 +1328,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlockSetEmboss(block, UI_EMBOSSP); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); @@ -1346,7 +1346,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemStringO(col, IFACE_("Python API Reference"), ICON_URL, "WM_OT_url_open", "url", url); uiItemL(col, "", ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); if (wm_resource_check_prev()) { uiItemO(col, NULL, ICON_NEW, "WM_OT_copy_prev_settings"); @@ -1646,8 +1646,8 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op) else G.f &= ~G_SCRIPT_AUTOEXEC; - // XXX wm in context is not set correctly after WM_read_file -> crash - // do it before for now, but is this correct with multiple windows? + /* XXX wm in context is not set correctly after WM_read_file -> crash */ + /* do it before for now, but is this correct with multiple windows? */ WM_event_add_notifier(C, NC_WINDOW, NULL); WM_read_file(C, path, op->reports); @@ -1877,8 +1877,8 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op) G.fileflags |= G_FILE_RECOVER; - // XXX wm in context is not set correctly after WM_read_file -> crash - // do it before for now, but is this correct with multiple windows? + /* XXX wm in context is not set correctly after WM_read_file -> crash */ + /* do it before for now, but is this correct with multiple windows? */ WM_event_add_notifier(C, NC_WINDOW, NULL); /* load file */ @@ -1909,8 +1909,8 @@ static int wm_recover_auto_save_exec(bContext *C, wmOperator *op) G.fileflags |= G_FILE_RECOVER; - // XXX wm in context is not set correctly after WM_read_file -> crash - // do it before for now, but is this correct with multiple windows? + /* XXX wm in context is not set correctly after WM_read_file -> crash */ + /* do it before for now, but is this correct with multiple windows? */ WM_event_add_notifier(C, NC_WINDOW, NULL); /* load file */ @@ -2134,203 +2134,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); } -/* XXX: move these collada operators to a more appropriate place */ -#ifdef WITH_COLLADA - -#include "../../collada/collada.h" - -static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - char filepath[FILE_MAX]; - - if (G.main->name[0] == 0) - BLI_strncpy(filepath, "untitled", sizeof(filepath)); - else - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); - - BLI_replace_extension(filepath, sizeof(filepath), ".dae"); - RNA_string_set(op->ptr, "filepath", filepath); - } - - WM_event_add_fileselect(C, op); - - return OPERATOR_RUNNING_MODAL; -} - -/* function used for WM_OT_save_mainfile too */ -static int wm_collada_export_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - int selected, second_life; - int include_armatures; - int apply_modifiers; - int include_children; - int use_object_instantiation; - int sort_by_name; - - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - BKE_report(op->reports, RPT_ERROR, "No filename given"); - return OPERATOR_CANCELLED; - } - - RNA_string_get(op->ptr, "filepath", filepath); - BLI_ensure_extension(filepath, sizeof(filepath), ".dae"); - - /* Options panel */ - selected = RNA_boolean_get(op->ptr, "selected"); - apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); - include_armatures = RNA_boolean_get(op->ptr, "include_armatures"); - include_children = RNA_boolean_get(op->ptr, "include_children"); - use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); - sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); - second_life = RNA_boolean_get(op->ptr, "second_life"); - - /* get editmode results */ - ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - - if (collada_export( - CTX_data_scene(C), - filepath, - selected, - apply_modifiers, - include_armatures, - include_children, - use_object_instantiation, - sort_by_name, - second_life)) { - return OPERATOR_FINISHED; - } - else { - return OPERATOR_CANCELLED; - } -} - - -void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) -{ - ID *id = imfptr->id.data; - - uiLayout *box, *row; - - // Export Options: - box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); - uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); - uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE); - uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - - - // Collada options: - box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); - uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); - -} - -static void wm_collada_export_draw(bContext *C, wmOperator *op) -{ - PointerRNA ptr; - - RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); - uiCollada_exportSettings(op->layout, &ptr); -} - -static void WM_OT_collada_export(wmOperatorType *ot) -{ - ot->name = "Export COLLADA"; - ot->description = "Save a Collada file"; - ot->idname = "WM_OT_collada_export"; - - ot->invoke = wm_collada_export_invoke; - ot->exec = wm_collada_export_exec; - ot->poll = WM_operator_winactive; - - ot->flag |= OPTYPE_PRESET; - - ot->ui = wm_collada_export_draw; - - WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - - - RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", - "Export only selected elements"); - - RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures", - "Include armature(s) even if not selected"); - - RNA_def_boolean(ot->srna, "include_children", 0, "Include Children", - "Include all children even if not selected"); - - RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", - "Apply modifiers (Preview Resolution)"); - - RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances", - "Instantiate multiple Objects from same Data"); - - RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name", - "Sort exported data by Object name"); - - RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", - "Compatibility mode for Second Life"); -} - - -/* function used for WM_OT_save_mainfile too */ -static int wm_collada_import_exec(bContext *C, wmOperator *op) -{ - char filename[FILE_MAX]; - - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - BKE_report(op->reports, RPT_ERROR, "No filename given"); - return OPERATOR_CANCELLED; - } - - RNA_string_get(op->ptr, "filepath", filename); - if (collada_import(C, filename)) return OPERATOR_FINISHED; - - BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); - - return OPERATOR_FINISHED; -} - -static void WM_OT_collada_import(wmOperatorType *ot) -{ - ot->name = "Import COLLADA"; - ot->description = "Load a Collada file"; - ot->idname = "WM_OT_collada_import"; - - ot->invoke = WM_operator_filesel; - ot->exec = wm_collada_import_exec; - ot->poll = WM_operator_winactive; - - WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -#endif - - -/* *********************** */ - static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot) { ot->name = "Toggle Fullscreen"; @@ -2539,7 +2342,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) } } -// // Allow view navigation??? +// /* Allow view navigation??? */ // else { // return OPERATOR_PASS_THROUGH; // } @@ -2558,7 +2361,7 @@ int WM_border_select_cancel(bContext *C, wmOperator *op) /* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */ #ifdef GESTURE_MEMORY -int circle_select_size = 25; // XXX - need some operator memory thing\! +int circle_select_size = 25; /* XXX - need some operator memory thing! */ #endif int WM_gesture_circle_invoke(bContext *C, wmOperator *op, wmEvent *event) @@ -2641,7 +2444,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; /* use finish or we don't get an undo */ } } -// // Allow view navigation??? +// /* Allow view navigation??? */ // else { // return OPERATOR_PASS_THROUGH; // } @@ -3771,14 +3574,14 @@ static void WM_OT_dependency_relations(wmOperatorType *ot) static int wm_ndof_sensitivity_exec(bContext *UNUSED(C), wmOperator *op) { - const float min = 0.25f, max = 4.f; // TODO: get these from RNA property + const float min = 0.25f, max = 4.0f; /* TODO: get these from RNA property */ float change; float sensitivity = U.ndof_sensitivity; if (RNA_boolean_get(op->ptr, "fast")) - change = 0.5f; // 50% change + change = 0.5f; /* 50% change */ else - change = 0.1f; // 10% + change = 0.1f; /* 10% */ if (RNA_boolean_get(op->ptr, "decrease")) { sensitivity -= sensitivity * change; @@ -3864,12 +3667,6 @@ void wm_operatortype_init(void) #if defined(WIN32) WM_operatortype_append(WM_OT_console_toggle); #endif - -#ifdef WITH_COLLADA - /* XXX: move these */ - WM_operatortype_append(WM_OT_collada_export); - WM_operatortype_append(WM_OT_collada_import); -#endif } /* circleselect-like modal operators */ @@ -3904,7 +3701,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_SELECT); -#if 0 // Durien guys like this :S +#if 0 /* Durien guys like this :S */ WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_DESELECT); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_SHIFT, 0, GESTURE_MODAL_NOP); #else @@ -3983,7 +3780,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); -#if 0 // Durian guys like this +#if 0 /* Durian guys like this */ WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_BEGIN); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_SHIFT, 0, GESTURE_MODAL_DESELECT); #else diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index cf983f7795f..d599b9504e8 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -194,9 +194,8 @@ void wm_subwindow_close(wmWindow *win, int swinid) MEM_freeN(swin); } else { - printf("wm_subwindow_close: Internal error, bad winid: %d\n", swinid); + printf("%s: Internal error, bad winid: %d\n", __func__, swinid); } - } /* pixels go from 0-99 for a 100 pixel window */ @@ -233,7 +232,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); } else { - printf("wm_subwindow_position: Internal error, bad winid: %d\n", swinid); + printf("%s: Internal error, bad winid: %d\n", __func__, swinid); } } @@ -250,7 +249,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) _curswin = swin_from_swinid(win, swinid); if (_curswin == NULL) { - printf("wmSubWindowSet %d: doesn't exist\n", swinid); + printf("%s %d: doesn't exist\n", __func__, swinid); return; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 265a3c11377..dd501e6d880 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -369,7 +369,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* until screens get drawn, make it nice grey */ - glClearColor(.55, .55, .55, 0.0); + glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); @@ -402,7 +402,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) wm_get_screensize(&wm_init_state.size_x, &wm_init_state.size_y); #if defined(__APPLE__) && !defined(GHOST_COCOA) -//Cocoa provides functions to get correct max window size + /* Cocoa provides functions to get correct max window size */ { extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */ @@ -632,9 +632,9 @@ void wm_window_make_drawable(bContext *C, wmWindow *win) } /* called by ghost, here we handle events for windows themselves or send to event system */ -static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) +static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr) { - bContext *C = private; + bContext *C = C_void_ptr; wmWindowManager *wm = CTX_wm_manager(C); GHOST_TEventType type = GHOST_GetEventType(evt); int time = GHOST_GetEventTime(evt); @@ -648,14 +648,14 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) wmWindow *win; if (!ghostwin) { - // XXX - should be checked, why are we getting an event here, and - // what is it? + /* XXX - should be checked, why are we getting an event here, and */ + /* what is it? */ puts("<!> event has no window"); return 1; } else if (!GHOST_ValidWindow(g_system, ghostwin)) { - // XXX - should be checked, why are we getting an event here, and - // what is it? + /* XXX - should be checked, why are we getting an event here, and */ + /* what is it? */ puts("<!> event has invalid window"); return 1; } @@ -859,7 +859,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) event = *(win->eventstate); /* copy last state, like mouse coords */ - // activate region + /* activate region */ event.type = MOUSEMOVE; event.prevx = event.x; event.prevy = event.y; @@ -894,7 +894,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0); /* void poin should point to string, it makes a copy */ - break; // only one drop element supported now + break; /* only one drop element supported now */ } } @@ -987,7 +987,7 @@ void wm_window_testbreak(void) /* only check for breaks every 50 milliseconds * if we get called more often. */ - if ((curtime - ltime) > .05) { + if ((curtime - ltime) > 0.05) { int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ if (hasevent) diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 99db5576fa0..720d68ef00d 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -153,7 +153,7 @@ endif() list(APPEND BLENDER_SORTED_LIBS extern_eltopo) endif() - if(WITH_BUILTIN_GLEW) + if(NOT WITH_SYSTEM_GLEW) list(APPEND BLENDER_SORTED_LIBS extern_glew) endif() diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 324f0f3cada..c7523502b81 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -230,8 +230,8 @@ struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima) {return (struct ImB void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings) {} void ED_screen_set_scene(struct bContext *C, struct Scene *scene) {} -void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {} -void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask){} +void ED_space_clip_set_clip(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {} +void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask) {} void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype) {} void ED_render_engine_changed(struct Main *bmain) {} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index c4f7400fa50..a71929351b1 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -825,6 +825,7 @@ endif() bf_editor_animation bf_editor_datafiles bf_editor_mask + bf_editor_io bf_render bf_intern_opennl @@ -909,7 +910,7 @@ endif() list(APPEND BLENDER_SORTED_LIBS extern_eltopo) endif() - if(WITH_BUILTIN_GLEW) + if(NOT WITH_SYSTEM_GLEW) list(APPEND BLENDER_SORTED_LIBS extern_glew) endif() diff --git a/source/creator/creator.c b/source/creator/creator.c index abfd735c124..b2b2b908d7b 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -155,8 +155,8 @@ static int print_version(int argc, const char **argv, void *data); /* for the callbacks: */ #define BLEND_VERSION_STRING_FMT \ - "Blender %d.%02d (sub %d)\n", \ - BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION \ + "Blender %d.%02d (sub %d)\n", \ + BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION \ /* Initialize callbacks for the modules that need them */ static void setCallbacks(void); @@ -389,6 +389,19 @@ static int debug_mode_libmv(int UNUSED(argc), const char **UNUSED(argv), void *U } #endif +static int set_debug_value(int argc, const char **argv, void *UNUSED(data)) +{ + if (argc > 1) { + G.rt = atoi(argv[1]); + + return 1; + } + else { + printf("\nError: you must specify debug value to set.\n"); + return 0; + } +} + static int set_fpe(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { #if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE) @@ -1117,6 +1130,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL); BLI_argsAdd(ba, 1, "-d", "--debug", debug_doc, debug_mode, ba); + #ifdef WITH_FFMPEG BLI_argsAdd(ba, 1, NULL, "--debug-ffmpeg", "\n\tEnable debug messages from FFmpeg library", debug_mode_generic, (void *)G_DEBUG_FFMPEG); #endif @@ -1131,6 +1145,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, NULL, "--debug-libmv", "\n\tEnable debug messages from libmv library", debug_mode_libmv, NULL); #endif + BLI_argsAdd(ba, 1, NULL, "--debug-value", "<value>\n\tSet debug value of <value> on startup\n", set_debug_value, NULL); + BLI_argsAdd(ba, 1, NULL, "--verbose", "<verbose>\n\tSet logging verbosity level.", set_verbosity, NULL); BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY (BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 927a0535870..3c9ca77b37e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -446,8 +446,8 @@ static void GetRGB(short type, c2 = KX_Mcol2uint_new(mmcol[2]); if (mface->v4) c3 = KX_Mcol2uint_new(mmcol[3]); - }else // backup white - { + } + else { // backup white c0 = KX_rgbaint2uint_new(color); c1 = KX_rgbaint2uint_new(color); c2 = KX_rgbaint2uint_new(color); diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 78e5d7b32c2..3961e6554a7 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -42,6 +42,7 @@ #include "KX_PhysicsEngineEnums.h" #include "PHY_IPhysicsEnvironment.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import #include "KX_IPhysicsController.h" #include "BL_Material.h" #include "BL_ActionActuator.h" @@ -173,9 +174,9 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() #endif /* free any data that was dynamically loaded */ - for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) { - Main *main= *it; - free_main(main); + while (m_DynamicMaggie.size() != 0) + { + FreeBlendFile(m_DynamicMaggie[0]); } m_DynamicMaggie.clear(); @@ -987,6 +988,11 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha load_datablocks(main_newlib, bpy_openlib, path, idcode); + if (idcode==ID_SCE) { + /* assume we want text blocks too */ + load_datablocks(main_newlib, bpy_openlib, path, ID_TXT); + } + /* now do another round of linking for Scenes so all actions are properly loaded */ if (idcode==ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) { load_datablocks(main_newlib, bpy_openlib, path, ID_AC); @@ -1038,6 +1044,10 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha delete other; } + /* Handle any text datablocks */ + + addImportMain(main_newlib); + /* Now handle all the actions */ if (options & LIB_LOAD_LOAD_ACTIONS) { ID *action; @@ -1330,6 +1340,9 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) } } + /* make sure this maggie is removed from the import list if it's there (this operation is safe if it isn't in the list) */ + removeImportMain(maggie); + free_main(maggie); return true; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 07680297b7d..28e34769ab8 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -860,7 +860,7 @@ void BL_ConvertActuators(const char* maggiename, float paraArg1 = 0.0; float paraArg2 = 0.0; - switch (randAct->distribution) { + switch (randAct->distribution) { case ACT_RANDOM_BOOL_CONST: modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST; paraArg1 = (float) randAct->int_arg_1; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index c50e42446a5..124a8e28f57 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -588,7 +588,7 @@ public: /* These static functions are referenced by ALL PyObjectPlus_Proxy types * they take the C++ reference from the PyObjectPlus_Proxy and call - * its own virtual py_repr, py_base_dealloc ,etc. functions. + * its own virtual py_repr, py_base_dealloc, etc. functions. */ static PyObject* py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */ diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 9a23244fa96..b505353c7cd 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -94,7 +94,7 @@ public: void InsertActiveQList(SG_QList& head) { SG_QList::iterator<SCA_ILogicBrick> it(head); - for(it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); + for (it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); it.add_back(this); } @@ -119,9 +119,8 @@ public: // this element comes before the first *current = this; } - else - { - for(++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); + else { + for (++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); } it.add_back(this); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index c82e015919d..2c6beb79fd3 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -191,7 +191,8 @@ bool SCA_JoystickSensor::Evaluate() if (( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { m_istrig = 1; result = true; - }else { + } + else { if (m_istrig) { m_istrig = 0; result = true; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 9c8e6fe99b4..94a8628ca79 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -209,7 +209,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) else if (PyObject_TypeCheck(value, &SCA_IActuator::Type)) { PyObjectPlus *value_plus= BGE_PROXY_REF(value); for (it = lacts.begin(); it!= lacts.end(); ++it) { - if ( static_cast<SCA_IActuator*>(value_plus) == (*it) ) { + if (static_cast<SCA_IActuator*>(value_plus) == (*it)) { return *it; } } diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index b0fc1431482..c727eebd015 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -34,13 +34,13 @@ #include <stddef.h> +#include <math.h> #include "BoolValue.h" #include "IntValue.h" #include "FloatValue.h" #include "SCA_IActuator.h" #include "SCA_RandomActuator.h" -#include "math.h" #include "MT_Transform.h" /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 15be4c46894..fbeb34b70b4 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -141,6 +141,16 @@ bool BL_Action::Play(const char* name, return false; } + // If we have the same settings, don't play again + // This is to resolve potential issues with pulses on sensors such as the ones + // reported in bug #29412. The fix is here so it works for both logic bricks and Python. + // However, this may eventually lead to issues where a user wants to override an already + // playing action with the same action and settings. If this becomes an issue, + // then this fix may have to be re-evaluated. + if (!IsDone() && m_action == prev_action && m_startframe == start && m_endframe == end + && m_priority == priority && m_speed == playback_speed) + return false; + if (prev_action != m_action) { // First get rid of any old controllers diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 98854115d0a..c0fca88c426 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -835,12 +835,12 @@ KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" ) return PyLong_FromSsize_t( ( mShader !=0 && mOk ) ); } -KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg ,"getVertexProg( )" ) +KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg, "getVertexProg( )" ) { return PyUnicode_FromString(vertProg?vertProg:""); } -KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" ) +KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg, "getFragmentProg( )" ) { return PyUnicode_FromString(fragProg?fragProg:""); } @@ -941,7 +941,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) } -KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)") +KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f, "setUniform2f(name, fx, fy)") { if (mError) { Py_RETURN_NONE; @@ -1038,7 +1038,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" ) } -KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)") +KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i, "setUniform2i(name, ix, iy)") { if (mError) { Py_RETURN_NONE; @@ -1109,7 +1109,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) " return NULL; } -KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )") +KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list3 or list4) )") { if (mError) { Py_RETURN_NONE; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 939f0693161..79e6c35e6a2 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -176,7 +176,8 @@ void KX_BlenderMaterial::OnConstruction(int layer) mMaterial->matname<< ", image will not be available"); } // If we're using glsl materials, the textures are handled by bf_gpu, so don't load them twice! - else if (!mMaterial->glslmat) { + // However, if we're using a custom shader, then we still need to load the textures ourselves. + else if (!mMaterial->glslmat || mBlenderShader) { if ( mMaterial->img[i] ) { if ( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) spit("unable to initialize image("<<i<<") in "<< @@ -898,8 +899,8 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") mMaterial->SetSharedMaterial(true); mScene->GetBucketManager()->ReleaseDisplayLists(this); return mShader->GetProxy(); - }else - { + } + else { // decref all references to the object // then delete it! // We will then go back to fixed functionality diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 3b3a1f5cbfb..5fcd591d822 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -12,7 +12,7 @@ #include "CcdPhysicsController.h" #endif -class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysicsController +class KX_BulletPhysicsController : public KX_IPhysicsController, public CcdPhysicsController { private: int m_savedCollisionFlags; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 6d57b6950f1..f149b676aa5 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -105,7 +105,8 @@ KX_Dome::KX_Dome ( CreateMeshDome180(); m_numfaces = 4; - }else if (m_angle > 180) { + } + else if (m_angle > 180) { cubetop.resize(2); cubebottom.resize(2); cubeleft.resize(2); @@ -140,7 +141,8 @@ KX_Dome::KX_Dome ( CreateMeshDome180(); m_numfaces = 4; - }else if (m_angle > 180) { + } + else if (m_angle > 180) { cubetop.resize(2); cubebottom.resize(2); cubeleft.resize(2); @@ -595,7 +597,7 @@ void KX_Dome::CreateMeshDome180(void) /* Left face - two triangles */ cubeleft[0].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[0][1] = .0; + cubeleft[0].verts[0][1] = 0.0; cubeleft[0].verts[0][2] = -0.5; cubeleft[0].u[0] = 0.0; cubeleft[0].v[0] = 0.0; @@ -1547,7 +1549,7 @@ void KX_Dome::CalculateCameraOrientation() m_locRot[1] = MT_Matrix3x3( // Bottom c, s, 0.0, - 0.0 ,0.0, 1.0, + 0.0, 0.0, 1.0, s, -c, 0.0); m_locRot[2] = MT_Matrix3x3( // 45deg - Left diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 836005cf25e..04113607531 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1472,18 +1472,18 @@ void KX_KetsjiEngine::RenderDebugProperties() for (int j = tc_first; j < tc_numCategories; j++) { debugtxt.Format(m_profileLabels[j]); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord,ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord,ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); double time = m_logger->GetAverage((KX_TimeCategory)j); debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord + 60 ,ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord + 60, ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); ycoord += 14; } } diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index b0000405893..8924567acde 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -104,19 +104,20 @@ bool PyMatTo(PyObject* pymat, T& mat) if (!PyErr_Occurred() && PySequence_Check(pyrow)) { unsigned int cols = PySequence_Size(pyrow); - if (cols != Size(mat)) + if (cols != Size(mat)) { noerror = false; - else - { - for(unsigned int col = 0; col < cols; col++) - { + } + else { + for (unsigned int col = 0; col < cols; col++) { PyObject *item = PySequence_GetItem(pyrow, col); /* new ref */ mat[row][col] = PyFloat_AsDouble(item); Py_DECREF(item); } } - } else + } + else { noerror = false; + } Py_DECREF(pyrow); } } else diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 28c4630c43e..2a648303c52 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1821,6 +1821,16 @@ static void restorePySysObjects(void) // PyObject_Print(sys_path, stderr, 0); } +void addImportMain(struct Main *maggie) +{ + bpy_import_main_extra_add(maggie); +} + +void removeImportMain(struct Main *maggie) +{ + bpy_import_main_extra_remove(maggie); +} + // Copied from bpy_interface.c static struct _inittab bge_internal_modules[]= { {(char *)"mathutils", PyInit_mathutils}, diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index d8346018b55..866681b9da7 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -61,6 +61,9 @@ int saveGamePythonConfig( char **marshal_buffer); int loadGamePythonConfig(char *marshal_buffer, int marshal_length); #endif +void addImportMain(struct Main *maggie); +void removeImportMain(struct Main *maggie); + class KX_KetsjiEngine; class KX_Scene; diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 978944c20e8..74009f51078 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -104,42 +104,42 @@ void KX_RadarSensor::SynchronizeTransform() { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_Y_AXIS: // +Y Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_Z_AXIS: // +Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_X_AXIS: // -X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_Y_AXIS: // -Y Axis { //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); //trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_Z_AXIS: // -Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; default: @@ -154,7 +154,7 @@ void KX_RadarSensor::SynchronizeTransform() m_cone_origin[1] = temp[1]; m_cone_origin[2] = temp[2]; - temp = trans(MT_Point3(0, -m_coneheight/2.0 ,0)); + temp = trans(MT_Point3(0, -m_coneheight/2.0, 0)); m_cone_target[0] = temp[0]; m_cone_target[1] = temp[1]; m_cone_target[2] = temp[2]; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index cd6bb5a1cbc..39b7c44eda9 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -258,7 +258,7 @@ void KX_SCA_AddObjectActuator::InstantAddObject() // Now it needs to be added to the current scene. SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp ); KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica); - game_obj->setLinearVelocity(m_linear_velocity ,m_localLinvFlag); + game_obj->setLinearVelocity(m_linear_velocity, m_localLinvFlag); game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag); game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 343cb549337..47cd4ff8da5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1811,8 +1811,8 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user // occlusion culling, the direction of the view is taken from the first plan which MUST be the near plane btDbvt::collideOCL(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); btDbvt::collideOCL(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); - }else - { + } + else { btDbvt::collideKDOP(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,nplanes,dispatcher); btDbvt::collideKDOP(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,nplanes,dispatcher); } diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index dc63a867e30..8609cd73875 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -27,7 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <sstream> #include <fstream> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "Exception.h" diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp index 6fa249ff00a..90ea8436ffe 100644 --- a/source/gameengine/VideoTexture/FilterBase.cpp +++ b/source/gameengine/VideoTexture/FilterBase.cpp @@ -27,7 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "FilterBase.h" -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index cd25a7ea313..63561c25ffa 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -29,7 +29,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "PyTypeList.h" diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index fb5a83c7043..02a6a8f0344 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterBlueScreen.h" diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index f3931c7e047..ed75b4f8da8 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterColor.h" diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index aacbc87a414..dda1a493291 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterNormal.h" diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp index c5c164822a5..e5fe4711cff 100644 --- a/source/gameengine/VideoTexture/FilterSource.cpp +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterSource.h" diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index ac92bcc6d41..090b4f6ff4a 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -33,7 +33,7 @@ extern "C" { #include <vector> #include <string.h> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterBase.h" diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index 91c7dce9637..6c38b107a4d 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -30,7 +30,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" #include <vector> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "PyTypeList.h" diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index d28babfcc90..9854da0ea86 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "ImageBuff.h" diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index e2409920230..cd8c6683a7f 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -27,7 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "ImageMix.h" diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 98a3dc8f96a..97e52e3af3d 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include <float.h> #include <math.h> diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h index 0062175e0af..df6337e1c24 100644 --- a/source/gameengine/VideoTexture/ImageRender.h +++ b/source/gameengine/VideoTexture/ImageRender.h @@ -30,12 +30,12 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" -#include <KX_Scene.h> -#include <KX_Camera.h> -#include <DNA_screen_types.h> -#include <RAS_ICanvas.h> -#include <RAS_IRasterizer.h> -#include <RAS_IRenderTools.h> +#include "KX_Scene.h" +#include "KX_Camera.h" +#include "DNA_screen_types.h" +#include "RAS_ICanvas.h" +#include "RAS_IRasterizer.h" +#include "RAS_IRenderTools.h" #include "ImageViewport.h" diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 12f1fa0e20c..a780fdcc38c 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "GL/glew.h" diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index 508ce233def..ed53e8bd1f1 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -29,7 +29,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <memory> #include <vector> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" /// destructor PyTypeList::~PyTypeList() diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h index e0f7480438d..aa1df0ce54b 100644 --- a/source/gameengine/VideoTexture/PyTypeList.h +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -32,7 +32,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <memory> #include <vector> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" // forward declaration class PyTypeListItem; diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 382d3d0bc32..f08a5a4a0b3 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -26,22 +26,22 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> -#include <KX_GameObject.h> -#include <KX_Light.h> -#include <RAS_MeshObject.h> -#include <DNA_mesh_types.h> -#include <DNA_meshdata_types.h> -#include <DNA_image_types.h> -#include <IMB_imbuf_types.h> -#include <KX_PolygonMaterial.h> +#include "KX_GameObject.h" +#include "KX_Light.h" +#include "RAS_MeshObject.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_image_types.h" +#include "IMB_imbuf_types.h" +#include "KX_PolygonMaterial.h" -#include <MEM_guardedalloc.h> +#include "MEM_guardedalloc.h" -#include <KX_BlenderMaterial.h> -#include <BL_Texture.h> +#include "KX_BlenderMaterial.h" +#include "BL_Texture.h" #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index d6e2ba0174f..ad5b7b9fb44 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -27,12 +27,12 @@ http://www.gnu.org/copyleft/lesser.txt. #ifndef __TEXTURE_H__ #define __TEXTURE_H__ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> -#include <DNA_image_types.h> -#include <BL_Texture.h> -#include <KX_BlenderMaterial.h> +#include "DNA_image_types.h" +#include "BL_Texture.h" +#include "KX_BlenderMaterial.h" #include "ImageBase.h" #include "BlendType.h" diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index 7ad3c6a9c77..3657a20b841 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -28,7 +28,7 @@ http://www.gnu.org/copyleft/lesser.txt. #define __VIDEOBASE_H__ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "ImageBase.h" diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index f4d3fb75223..4586a50e6a9 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -162,14 +162,14 @@ void VideoFFmpeg::initParams (short width, short height, float rate, bool image) } -int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams) +int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams) { - AVFormatContext *formatCtx; + AVFormatContext *formatCtx = NULL; int i, videoStream; AVCodec *codec; AVCodecContext *codecCtx; - if (av_open_input_file(&formatCtx, filename, inputFormat, 0, formatParams)!=0) + if (avformat_open_input(&formatCtx, filename, inputFormat, formatParams)!=0) return -1; if (av_find_stream_info(formatCtx)<0) @@ -545,11 +545,7 @@ void VideoFFmpeg::openFile (char * filename) // but it is really not desirable to seek on http file, so force streaming. // It would be good to find this information from the context but there are no simple indication !strncmp(filename, "http://", 7) || -#ifdef FFMPEG_PB_IS_POINTER - (m_formatCtx->pb && m_formatCtx->pb->is_streamed) -#else - m_formatCtx->pb.is_streamed -#endif + (m_formatCtx->pb && !m_formatCtx->pb->seekable) ) { // the file is in fact a streaming source, treat as cam to prevent seeking @@ -586,14 +582,12 @@ void VideoFFmpeg::openCam (char * file, short camIdx) { // open camera source AVInputFormat *inputFormat; - AVFormatParameters formatParams; - AVRational frameRate; + AVDictionary *formatParams = NULL; char filename[28], rateStr[20]; char *p; do_init_ffmpeg(); - memset(&formatParams, 0, sizeof(formatParams)); #ifdef WIN32 // video capture on windows only through Video For Windows driver inputFormat = av_find_input_format("vfwcap"); @@ -623,7 +617,13 @@ void VideoFFmpeg::openCam (char * file, short camIdx) sprintf(filename, "/dev/dv1394/%d", camIdx); } else { - inputFormat = av_find_input_format("video4linux"); + const char *formats[] = {"video4linux2,v4l2", "video4linux2", "video4linux"}; + int i, formatsCount = sizeof(formats) / sizeof(char*); + for (i = 0; i < formatsCount; i++) { + inputFormat = av_find_input_format(formats[i]); + if (inputFormat) + break; + } sprintf(filename, "/dev/video%d", camIdx); } if (!inputFormat) @@ -637,20 +637,22 @@ void VideoFFmpeg::openCam (char * file, short camIdx) if ((p = strchr(filename, ':')) != 0) *p = 0; } - if (file && (p = strchr(file, ':')) != NULL) - formatParams.standard = p+1; + if (file && (p = strchr(file, ':')) != NULL) { + av_dict_set(&formatParams, "standard", p+1, 0); + } #endif //frame rate if (m_captRate <= 0.f) m_captRate = defFrameRate; sprintf(rateStr, "%f", m_captRate); - av_parse_video_rate(&frameRate, rateStr); - // populate format parameters - // need to specify the time base = inverse of rate - formatParams.time_base.num = frameRate.den; - formatParams.time_base.den = frameRate.num; - formatParams.width = m_captWidth; - formatParams.height = m_captHeight; + + av_dict_set(&formatParams, "framerate", rateStr, 0); + + if (m_captWidth > 0 && m_captHeight > 0) { + char video_size[64]; + BLI_snprintf(video_size, sizeof(video_size), "%dx%d", m_captWidth, m_captHeight); + av_dict_set(&formatParams, "video_size", video_size, 0); + } if (openStream(filename, inputFormat, &formatParams) != 0) return; @@ -665,6 +667,8 @@ void VideoFFmpeg::openCam (char * file, short camIdx) // no need to thread if the system has a single core m_isThreaded = true; } + + av_dict_free(&formatParams); } // play video diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index d3458211949..e63032e0c66 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -46,10 +46,6 @@ extern "C" { # define FFMPEG_CODEC_IS_POINTER 1 #endif -#if LIBAVFORMAT_VERSION_INT >= (52 << 16) -# define FFMPEG_PB_IS_POINTER 1 -#endif - #ifdef FFMPEG_CODEC_IS_POINTER static inline AVCodecContext* get_codec_from_stream(AVStream* stream) { @@ -172,7 +168,7 @@ protected: double actFrameRate (void) { return m_frameRate * m_baseFrameRate; } /// common function to video file and capture - int openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams); + int openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams); /// check if a frame is available and load it in pFrame, return true if a frame could be retrieved AVFrame* grabFrame(long frame); diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index a82935c30bf..627da57baac 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <RAS_GLExtensionManager.h> |