diff --git a/CMakeLists.txt b/CMakeLists.txt index e9a72cf6e51..f767b2c3e3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,9 +223,6 @@ if(WITH_PYTHON_MODULE) set(WITH_HEADLESS ON) endif() -# remove old vars -unset(WITH_INSTALL CACHE) - TEST_SSE_SUPPORT() #----------------------------------------------------------------------------- @@ -234,6 +231,9 @@ TEST_SSE_SUPPORT() # linux only, not cached set(WITH_BINRELOC OFF) +# MAXOSX only, set to avoid uninitialized +set(EXETYPE "") + # these are added to later on. set(C_WARNINGS "") set(CXX_WARNINGS "") @@ -342,23 +342,8 @@ if(UNIX AND NOT APPLE) endif() if(WITH_IMAGE_OPENEXR) - set(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory") - mark_as_advanced(OPENEXR) - find_path(OPENEXR_INC - ImfXdr.h - PATHS - ${OPENEXR}/include/OpenEXR - /usr/local/include/OpenEXR - /sw/include/OpenEXR - /opt/local/include/OpenEXR - /opt/csw/include/OpenEXR - /opt/include/OpenEXR - ) - mark_as_advanced(OPENEXR_INC) - - set(OPENEXR_LIB Half IlmImf Iex Imath) - - if(NOT OPENEXR_INC) + find_package(OpenEXR) # our own module + if(NOT OPENEXR_FOUND) set(WITH_IMAGE_OPENEXR OFF) endif() endif() @@ -643,10 +628,7 @@ elseif(WIN32) endif() if(WITH_IMAGE_OPENEXR) - if(MSVC80) - set(MSVC_LIB _vs2005) - set(MSVC_INC) - elseif(MSVC90) + if(MSVC90) set(MSVC_LIB _vs2008) set(MSVC_INC) elseif(MSVC10) @@ -656,11 +638,24 @@ elseif(WIN32) set(MSVC_LIB msvc) set(MSVC_INC) endif() - set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread) + set(OPENEXR ${LIBDIR}/openexr) set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB}) + set(OPENEXR_LIBRARIES + ${OPENEXR_LIBPATH}/Iex.lib + ${OPENEXR_LIBPATH}/Half.lib + ${OPENEXR_LIBPATH}/IlmImf.lib + ${OPENEXR_LIBPATH}/Imath.lib + ${OPENEXR_LIBPATH}/IlmThread.lib + ) set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC}) - set(OPENEXR_INC ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath) + set(OPENEXR_INCLUDE_DIRS + ${OPENEXR_INCUDE} + ${OPENEXR_INCUDE}/IlmImf + ${OPENEXR_INCUDE}/Iex + ${OPENEXR_INCUDE}/Imath + ) + unset(OPENEXR_INCUDE) + unset(OPENEXR_LIBPATH) endif() if(WITH_IMAGE_TIFF) @@ -759,8 +754,8 @@ elseif(WIN32) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/gcc/openexr) - set(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR) - set(OPENEXR_LIB Half IlmImf Imath IlmThread) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) + set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib) # TODO, gives linking errors, force off @@ -892,8 +887,8 @@ elseif(APPLE) if(WITH_IMAGE_OPENEXR) set(OPENEXR ${LIBDIR}/openexr) - set(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include) - set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR) + set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread) set(OPENEXR_LIBPATH ${OPENEXR}/lib) endif() diff --git a/build_files/cmake/FindPythonLibsUnix.cmake b/build_files/cmake/FindPythonLibsUnix.cmake index 0752de4ce3c..90bd79a924a 100644 --- a/build_files/cmake/FindPythonLibsUnix.cmake +++ b/build_files/cmake/FindPythonLibsUnix.cmake @@ -18,10 +18,18 @@ set(_Python_ABI_FLAGS "m;mu;u; ") string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) -set(_Python_PATHS - "$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}" "/opt/py${_PYTHON_VERSION_NO_DOTS}" "/usr" "/usr/local") -if(NOT DEFINED PYTHON_INCLUDE_DIRS) +set(_Python_PATHS + "$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}" + "/opt/py${_PYTHON_VERSION_NO_DOTS}" + "/usr" + "/usr/local" +) + +if(NOT DEFINED PYTHON_INCLUDE_DIRS OR + NOT DEFINED PYTHON_LIBRARY OR + NOT DEFINED PYTHON_LIBPATH) + message(STATUS "Looking for include Python.h") set(_Found_PYTHON_H OFF) @@ -53,20 +61,29 @@ if(NOT DEFINED PYTHON_INCLUDE_DIRS) if(NOT _Found_PYTHON_H) message(FATAL_ERROR "Python.h not found") endif() + + unset(_Found_PYTHON_H) + unset(_Python_HEADER) + unset(_CURRENT_ABI_FLAGS) + unset(_CURRENT_PATH) + + + set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}${PYTHON_ABI_FLAGS}" CACHE STRING "") + mark_as_advanced(PYTHON_INCLUDE_DIRS) + set(PYTHON_LIBRARY "python${PYTHON_VERSION}${PYTHON_ABI_FLAGS}" CACHE STRING "") + mark_as_advanced(PYTHON_LIBRARY) + set(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "") + mark_as_advanced(PYTHON_LIBPATH) + # set(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "") endif() +unset(_Python_ABI_FLAGS) +unset(_Python_PATHS) + #============================================================================= # now the python versions are found -set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}${PYTHON_ABI_FLAGS}" CACHE STRING "") -mark_as_advanced(PYTHON_INCLUDE_DIRS) -set(PYTHON_LIBRARY "python${PYTHON_VERSION}${PYTHON_ABI_FLAGS}" CACHE STRING "") -mark_as_advanced(PYTHON_LIBRARY) -set(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "") -mark_as_advanced(PYTHON_LIBPATH) -# set(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "") - if(NOT EXISTS "${PYTHON_INCLUDE_DIRS}/Python.h") message(FATAL_ERROR " Missing python header: ${PYTHON_INCLUDE_DIRS}/Python.h") endif() diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake new file mode 100644 index 00000000000..9a116973348 --- /dev/null +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -0,0 +1,88 @@ +# - Find OpenEXR library +# Find the native OpenEXR includes and library +# This module defines +# OPENEXR_INCLUDE_DIRS, where to find ImfXdr.h, etc. Set when +# OPENEXR_INCLUDE_DIR is found. +# OPENEXR_LIBRARIES, libraries to link against to use OpenEXR. +# OPENEXR_ROOT_DIR, The base directory to search for OpenEXR. +# This can also be an environment variable. +# OPENEXR_FOUND, If false, do not try to use OpenEXR. +# +# For indervidual library access these advanced settings are available +# OPENEXR_HALF_LIBRARY, Path to Half library +# OPENEXR_IEX_LIBRARY, Path to Half library +# OPENEXR_ILMIMF_LIBRARY, Path to Ilmimf library +# OPENEXR_ILMTHREAD_LIBRARY, Path to IlmThread library +# OPENEXR_IMATH_LIBRARY, Path to Imath library +# +# also defined, but not for general use are +# OPENEXR_LIBRARY, where to find the OpenEXR library. + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# If OPENEXR_ROOT_DIR was defined in the environment, use it. +IF(NOT OPENEXR_ROOT_DIR AND NOT $ENV{OPENEXR_ROOT_DIR} STREQUAL "") + SET(OPENEXR_ROOT_DIR $ENV{OPENEXR_ROOT_DIR}) +ENDIF() + +SET(_openexr_FIND_COMPONENTS + Half + Iex + IlmImf + IlmThread + Imath +) + +SET(_openexr_SEARCH_DIRS + ${OPENEXR_ROOT_DIR} + /usr/local + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave +) + +FIND_PATH(OPENEXR_INCLUDE_DIR ImfXdr.h + HINTS + ${_openexr_SEARCH_DIRS} + PATH_SUFFIXES + include/OpenEXR +) + +SET(_openexr_LIBRARIES) +FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) + STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) + + FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY NAMES ${COMPONENT} + HINTS ${_openexr_SEARCH_DIRS} + PATH_SUFFIXES lib64 lib + ) + LIST(APPEND _openexr_LIBRARIES "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}") +ENDFOREACH() + +# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG + _openexr_LIBRARIES OPENEXR_INCLUDE_DIR) + +IF(OPENEXR_FOUND) + SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES}) + SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR}) +ENDIF(OPENEXR_FOUND) + +MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIR) +FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS}) + STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) + MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY) +ENDFOREACH() diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py index f55b2e95d5e..8dbfadb1187 100755 --- a/build_files/cmake/cmake_consistency_check.py +++ b/build_files/cmake/cmake_consistency_check.py @@ -23,15 +23,16 @@ # -IGNORE = \ - "/test/",\ - "/decimate_glut_test/",\ - "/BSP_GhostTest/",\ - "/release/",\ - "/xembed/",\ - "/decimation/intern/future/",\ - "/TerraplayNetwork/",\ - "/ik_glut_test/" +IGNORE = ( + "/test/", + "/decimate_glut_test/", + "/BSP_GhostTest/", + "/release/", + "/xembed/", + "/decimation/intern/future/", + "/TerraplayNetwork/", + "/ik_glut_test/", + ) import os from os.path import join, dirname, normpath, abspath, splitext @@ -104,7 +105,7 @@ def cmake_get_src(f): found = True break - if "list(APPEND SRC" in l: + if "list(APPEND SRC" in l or ('list(APPEND ' in l and l.endswith("SRC")): if l.endswith(")"): raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i)) found = True @@ -136,7 +137,9 @@ def cmake_get_src(f): if not l: pass elif l.startswith("$"): - print("Cant use var '%s' %s:%d" % (l, f, i)) + # assume if it ends with SRC we know about it + if not l.split("}")[0].endswith("SRC"): + print("Can't use var '%s' %s:%d" % (l, f, i)) elif len(l.split()) > 1: raise Exception("Multi-line define '%s' %s:%d" % (l, f, i)) else: diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 265d5072205..7a8158227a9 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -5,22 +5,28 @@ # use it instead of include_directories() macro(blender_include_dirs includes) - - foreach(inc ${ARGV}) - get_filename_component(abs_inc ${inc} ABSOLUTE) - list(APPEND all_incs ${abs_inc}) + set(_ALL_INCS "") + foreach(_INC ${ARGV}) + get_filename_component(_ABS_INC ${_INC} ABSOLUTE) + list(APPEND _ALL_INCS ${_ABS_INC}) endforeach() - include_directories(${all_incs}) + include_directories(${_ALL_INCS}) + unset(_INC) + unset(_ABS_INC) + unset(_ALL_INCS) endmacro() macro(blender_include_dirs_sys includes) - - foreach(inc ${ARGV}) - get_filename_component(abs_inc ${inc} ABSOLUTE) - list(APPEND all_incs ${abs_inc}) + set(_ALL_INCS "") + foreach(_INC ${ARGV}) + get_filename_component(_ABS_INC ${_INC} ABSOLUTE) + list(APPEND _ALL_INCS ${_ABS_INC}) endforeach() - include_directories(SYSTEM ${all_incs}) + include_directories(SYSTEM ${_ALL_INCS}) + unset(_INC) + unset(_ABS_INC) + unset(_ALL_INCS) endmacro() macro(blender_source_group @@ -29,14 +35,17 @@ macro(blender_source_group # Group by location on disk source_group("Source Files" FILES CMakeLists.txt) - foreach(SRC ${sources}) - get_filename_component(SRC_EXT ${SRC} EXT) - if(${SRC_EXT} MATCHES ".h" OR ${SRC_EXT} MATCHES ".hpp") - source_group("Header Files" FILES ${SRC}) + foreach(_SRC ${sources}) + get_filename_component(_SRC_EXT ${_SRC} EXT) + if(${_SRC_EXT} MATCHES ".h" OR ${_SRC_EXT} MATCHES ".hpp") + source_group("Header Files" FILES ${_SRC}) else() - source_group("Source Files" FILES ${SRC}) + source_group("Source Files" FILES ${_SRC}) endif() endforeach() + + unset(_SRC) + unset(_SRC_EXT) endmacro() @@ -141,15 +150,22 @@ macro(setup_liblinks target) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ") - target_link_libraries(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${LLIBS}) + target_link_libraries(${target} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} + ${JPEG_LIBRARIES} + ${PNG_LIBRARIES} + ${ZLIB_LIBRARIES} + ${LLIBS}) # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs target_link_libraries(${target} ${PYTHON_LINKFLAGS}) if(WIN32 AND NOT UNIX) - target_link_libraries(${target} debug ${PYTHON_LIBRARY}_d) - target_link_libraries(${target} optimized ${PYTHON_LIBRARY}) + target_link_libraries(${target} + debug ${PYTHON_LIBRARY}_d + optimized ${PYTHON_LIBRARY}) else() target_link_libraries(${target} ${PYTHON_LIBRARY}) endif() @@ -159,8 +175,12 @@ macro(setup_liblinks target_link_libraries(${target} ${GLEW_LIBRARY}) endif() - target_link_libraries(${target} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) - target_link_libraries(${target} ${FREETYPE_LIBRARY}) + target_link_libraries(${target} + ${OPENGL_glu_LIBRARY} + ${JPEG_LIBRARIES} + ${PNG_LIBRARIES} + ${ZLIB_LIBRARIES} + ${FREETYPE_LIBRARY}) if(WITH_INTERNATIONAL) target_link_libraries(${target} ${GETTEXT_LIB}) @@ -196,12 +216,16 @@ macro(setup_liblinks endif() if(WITH_IMAGE_OPENEXR) if(WIN32 AND NOT UNIX) - foreach(loop_var ${OPENEXR_LIB}) - target_link_libraries(${target} debug ${loop_var}_d) - target_link_libraries(${target} optimized ${loop_var}) + foreach(_LOOP_VAR ${OPENEXR_LIBRARIES}) + string(REGEX REPLACE ".lib$" "_d.lib" _LOOP_VAR_DEBUG ${_LOOP_VAR}) + target_link_libraries(${target} + debug ${_LOOP_VAR_DEBUG} + optimized ${_LOOP_VAR}) endforeach() + unset(_LOOP_VAR) + unset(_LOOP_VAR_DEBUG) else() - target_link_libraries(${target} ${OPENEXR_LIB}) + target_link_libraries(${target} ${OPENEXR_LIBRARIES}) endif() endif() if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) @@ -212,20 +236,25 @@ macro(setup_liblinks endif() if(WITH_OPENCOLLADA) if(WIN32 AND NOT UNIX) - foreach(loop_var ${OPENCOLLADA_LIB}) - target_link_libraries(${target} debug ${loop_var}_d) - target_link_libraries(${target} optimized ${loop_var}) + foreach(_LOOP_VAR ${OPENCOLLADA_LIB}) + target_link_libraries(${target} + debug ${_LOOP_VAR}_d + optimized ${_LOOP_VAR}) endforeach() - target_link_libraries(${target} debug ${PCRE_LIB}_d) - target_link_libraries(${target} optimized ${PCRE_LIB}) + unset(_LOOP_VAR) + target_link_libraries(${target} + debug ${PCRE_LIB}_d + optimized ${PCRE_LIB}) if(EXPAT_LIB) - target_link_libraries(${target} debug ${EXPAT_LIB}_d) - target_link_libraries(${target} optimized ${EXPAT_LIB}) + target_link_libraries(${target} + debug ${EXPAT_LIB}_d + optimized ${EXPAT_LIB}) endif() else() - target_link_libraries(${target} ${OPENCOLLADA_LIB}) - target_link_libraries(${target} ${PCRE_LIB}) - target_link_libraries(${target} ${EXPAT_LIB}) + target_link_libraries(${target} + ${OPENCOLLADA_LIB} + ${PCRE_LIB} + ${EXPAT_LIB}) endif() endif() if(WITH_MEM_JEMALLOC) @@ -472,4 +501,13 @@ macro(blender_project_hack_post) unset(_reset_standard_cflags_rel) unset(_reset_standard_cxxflags_rel) + + # ------------------------------------------------------------------ + # workaround for omission in cmake 2.8.4's GNU.cmake, fixed in 2.8.5 + if(CMAKE_COMPILER_IS_GNUCC) + if(NOT DARWIN) + set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ") + endif() + endif() + endmacro() diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index a0dade8bdf6..b5d44db8a92 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -118,7 +118,7 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype2ST' BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' -WITH_BF_QUICKTIME = True # -DWITH_QUICKTIME +WITH_BF_QUICKTIME = False # -DWITH_QUICKTIME BF_QUICKTIME = LIBDIR + '/QTDevWin' BF_QUICKTIME_INC = '${BF_QUICKTIME}/CIncludes' BF_QUICKTIME_LIB = 'qtmlClient' diff --git a/doc/python_api/rst/bge.logic.rst b/doc/python_api/rst/bge.logic.rst index 20a3a68b387..0af4a1184d6 100644 --- a/doc/python_api/rst/bge.logic.rst +++ b/doc/python_api/rst/bge.logic.rst @@ -345,9 +345,9 @@ Utility functions .. function:: getAverageFrameRate() - Gets the estimated average framerate - - :return: The estimed average framerate in frames per second + Gets the estimated/average framerate for all the active scenes, not only the current scene. + + :return: The estimated average framerate in frames per second :rtype: float .. function:: getBlendFileList(path = "//") diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index b54eca07e55..e42b362c771 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -710,6 +710,12 @@ Game Engine bge.types Module Applies changes to a camera. + .. attribute:: damping + + strength of of the camera following movement. + + :type: float + .. attribute:: min minimum distance to the target object maintained by the actuator. diff --git a/intern/elbeem/extern/elbeem.h b/intern/elbeem/extern/elbeem.h index f5538df8805..6df08ccebd2 100644 --- a/intern/elbeem/extern/elbeem.h +++ b/intern/elbeem/extern/elbeem.h @@ -77,6 +77,10 @@ typedef struct elbeemSimulationSettings { /* boundary types and settings for domain walls */ short domainobsType; float domainobsPartslip; + + /* what surfaces to generate */ + int mFsSurfGenSetting; + /* generate speed vectors for vertices (e.g. for image based motion blur)*/ short generateVertexVectors; /* strength of surface smoothing */ @@ -108,10 +112,12 @@ typedef struct elbeemSimulationSettings { #define OB_FLUIDSIM_PARTICLE 64 #define OB_FLUIDSIM_CONTROL 128 -// defines for elbeemMesh->obstacleType below +// defines for elbeemMesh->obstacleType below (low bits) high bits (>=64) are reserved for mFsSurfGenSetting flags which are defined in solver_class.h #define FLUIDSIM_OBSTACLE_NOSLIP 1 #define FLUIDSIM_OBSTACLE_PARTSLIP 2 #define FLUIDSIM_OBSTACLE_FREESLIP 3 +#define FLUIDSIM_FSSG_NOOBS 64 + #define OB_VOLUMEINIT_VOLUME 1 #define OB_VOLUMEINIT_SHELL 2 diff --git a/intern/elbeem/intern/simulation_object.cpp b/intern/elbeem/intern/simulation_object.cpp index 2544b8fe29c..87828b26088 100644 --- a/intern/elbeem/intern/simulation_object.cpp +++ b/intern/elbeem/intern/simulation_object.cpp @@ -181,6 +181,9 @@ int SimulationObject::initializeLbmSimulation(ntlRenderGlobals *glob) mpLbm->setGenerateParticles(mpElbeemSettings->generateParticles); // set initial particles mpParts->setNumInitialParticles(mpElbeemSettings->numTracerParticles); + + // surface generation flag + mpLbm->setSurfGenSettings(mpElbeemSettings->mFsSurfGenSetting); string dinitType = string("no"); if (mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_PARTSLIP) dinitType = string("part"); diff --git a/intern/elbeem/intern/solver_class.h b/intern/elbeem/intern/solver_class.h index 8662ac3f12a..1548aaa19bc 100644 --- a/intern/elbeem/intern/solver_class.h +++ b/intern/elbeem/intern/solver_class.h @@ -308,6 +308,9 @@ class LbmFsgrSolver : //! for raytracing, preprocess void prepareVisualization( void ); + /* surface generation settings */ + virtual void setSurfGenSettings(short value); + protected: //! internal quick print function (for debugging) diff --git a/intern/elbeem/intern/solver_init.cpp b/intern/elbeem/intern/solver_init.cpp index 899b1e0ecbc..7e9f5e7f420 100644 --- a/intern/elbeem/intern/solver_init.cpp +++ b/intern/elbeem/intern/solver_init.cpp @@ -538,6 +538,15 @@ void LbmFsgrSolver::parseAttrList() } +/****************************************************************************** + * (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM") + *****************************************************************************/ +void LbmFsgrSolver::setSurfGenSettings(short value) +{ + mFsSurfGenSetting = value; +} + + /****************************************************************************** * Initialize omegas and forces on all levels (for init/timestep change) *****************************************************************************/ diff --git a/intern/elbeem/intern/solver_interface.h b/intern/elbeem/intern/solver_interface.h index 71b347d683d..8f3181a307d 100644 --- a/intern/elbeem/intern/solver_interface.h +++ b/intern/elbeem/intern/solver_interface.h @@ -271,6 +271,9 @@ class LbmSolverInterface /*! debug object display */ virtual vector getDebugObjects() { vector empty(0); return empty; } + /* surface generation settings */ + virtual void setSurfGenSettings(short value) = 0; + #if LBM_USE_GUI==1 /*! show simulation info */ virtual void debugDisplay(int) = 0; diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py index 45f537ebd2f..f2f2e53240b 100644 --- a/release/scripts/modules/bpy_extras/view3d_utils.py +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -114,6 +114,8 @@ def location_3d_to_region_2d(region, rv3d, coord): :return: 2d location :rtype: :class:`Vector` """ + from mathutils import Vector + prj = Vector((coord[0], coord[1], coord[2], 1.0)) * rv3d.perspective_matrix if prj.w > 0.0: width_half = region.width / 2.0 diff --git a/release/scripts/modules/console/intellisense.py b/release/scripts/modules/console/intellisense.py index 00f7dbd3657..072d467ff86 100644 --- a/release/scripts/modules/console/intellisense.py +++ b/release/scripts/modules/console/intellisense.py @@ -120,22 +120,25 @@ def expand(line, cursor, namespace, private=True): from . import complete_calltip matches, word, scrollback = complete_calltip.complete(line, cursor, namespace) + prefix = os.path.commonprefix(matches)[len(word):] no_calltip = False else: matches, word = complete(line, cursor, namespace, private) + prefix = os.path.commonprefix(matches)[len(word):] if len(matches) == 1: scrollback = '' else: # causes blender bug [#27495] since string keys may contain '.' # scrollback = ' '.join([m.split('.')[-1] for m in matches]) + word_prefix = word + prefix scrollback = ' '.join( - [m[len(word):] - if (word and m.startswith(word)) + [m[len(word_prefix):] + if (word_prefix and m.startswith(word_prefix)) else m.split('.')[-1] for m in matches]) no_calltip = True - prefix = os.path.commonprefix(matches)[len(word):] + if prefix: line = line[:cursor] + prefix + line[cursor:] cursor += len(prefix) diff --git a/release/scripts/startup/bl_operators/nla.py b/release/scripts/startup/bl_operators/nla.py index 923ca92a162..6b324111903 100644 --- a/release/scripts/startup/bl_operators/nla.py +++ b/release/scripts/startup/bl_operators/nla.py @@ -16,17 +16,16 @@ # # ##### END GPL LICENSE BLOCK ##### -# +# import bpy -def pose_info(): +def pose_frame_info(obj): from mathutils import Matrix info = {} - obj = bpy.context.object pose = obj.pose pose_items = pose.bones.items() @@ -51,7 +50,6 @@ def pose_info(): except: binfo["matrix_pose_inv"] = Matrix() - print(binfo["matrix_pose"]) info[name] = binfo for name, pbone in pose_items: @@ -67,45 +65,84 @@ def pose_info(): matrix = binfo_parent["matrix_pose_inv"] * matrix rest_matrix = binfo_parent["matrix_local_inv"] * rest_matrix - matrix = rest_matrix.inverted() * matrix - - binfo["matrix_key"] = matrix.copy() + binfo["matrix_key"] = rest_matrix.inverted() * matrix return info -def bake(frame_start, frame_end, step=1, only_selected=False): +def obj_frame_info(obj): + info = {} + # parent = obj.parent + info["matrix_key"] = obj.matrix_local.copy() + return info + + +def bake(frame_start, + frame_end, step=1, + only_selected=False, + do_pose=True, + do_object=True, + do_constraint_clear=False, + ): + scene = bpy.context.scene obj = bpy.context.object pose = obj.pose + frame_back = scene.frame_current - info_ls = [] + if pose is None: + do_pose = False + + if do_pose is None and do_object is None: + return None + + pose_info = [] + obj_info = [] frame_range = range(frame_start, frame_end + 1, step) - # could spped this up by applying steps here too... + # ------------------------------------------------------------------------- + # Collect transformations + + # could speed this up by applying steps here too... for f in frame_range: scene.frame_set(f) - info = pose_info() - info_ls.append(info) + if do_pose: + pose_info.append(pose_frame_info(obj)) + if do_object: + obj_info.append(obj_frame_info(obj)) + f += 1 + # ------------------------------------------------------------------------- + # Create action + action = bpy.data.actions.new("Action") + obj.animation_data.action = action - bpy.context.object.animation_data.action = action + if do_pose: + pose_items = pose.bones.items() + else: + pose_items = [] # skip - pose_items = pose.bones.items() + # ------------------------------------------------------------------------- + # Apply transformations to action - for name, pbone in pose_items: + # pose + for name, pbone in (pose_items if do_pose else ()): if only_selected and not pbone.bone.select: continue - for f in frame_range: - matrix = info_ls[int((f - frame_start) / step)][name]["matrix_key"] + if do_constraint_clear: + while pbone.constraints: + pbone.constraints.remove(pbone.constraints[0]) - #pbone.location = matrix.to_translation() - #pbone.rotation_quaternion = matrix.to_quaternion() + for f in frame_range: + matrix = pose_info[(f - frame_start) // step][name]["matrix_key"] + + # pbone.location = matrix.to_translation() + # pbone.rotation_quaternion = matrix.to_quaternion() pbone.matrix_basis = matrix pbone.keyframe_insert("location", -1, f, name) @@ -121,10 +158,35 @@ def bake(frame_start, frame_end, step=1, only_selected=False): pbone.keyframe_insert("scale", -1, f, name) + # object. TODO. multiple objects + if do_object: + if do_constraint_clear: + while obj.constraints: + obj.constraints.remove(obj.constraints[0]) + + for f in frame_range: + matrix = obj_info[(f - frame_start) // step]["matrix_key"] + obj.matrix_local = matrix + + obj.keyframe_insert("location", -1, f) + + rotation_mode = obj.rotation_mode + + if rotation_mode == 'QUATERNION': + obj.keyframe_insert("rotation_quaternion", -1, f) + elif rotation_mode == 'AXIS_ANGLE': + obj.keyframe_insert("rotation_axis_angle", -1, f) + else: # euler, XYZ, ZXY etc + obj.keyframe_insert("rotation_euler", -1, f) + + obj.keyframe_insert("scale", -1, f) + + scene.frame_set(frame_back) + return action -from bpy.props import IntProperty, BoolProperty +from bpy.props import IntProperty, BoolProperty, EnumProperty class BakeAction(bpy.types.Operator): @@ -144,10 +206,31 @@ class BakeAction(bpy.types.Operator): default=1, min=1, max=120) only_selected = BoolProperty(name="Only Selected", default=True) + clear_consraints = BoolProperty(name="Clear Constraints", + default=False) + bake_types = EnumProperty( + name="Bake Data", + options={'ENUM_FLAG'}, + items=(('POSE', "Pose", ""), + ('OBJECT', "Object", ""), + ), + default={'POSE'}, + ) def execute(self, context): - action = bake(self.frame_start, self.frame_end, self.step, self.only_selected) + action = bake(self.frame_start, + self.frame_end, + self.step, + self.only_selected, + 'POSE' in self.bake_types, + 'OBJECT' in self.bake_types, + self.clear_consraints, + ) + + if action is None: + self.report({'INFO'}, "Nothing to bake") + return {'CANCELLED'} # basic cleanup, could move elsewhere for fcu in action.fcurves: diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 21640fa3ee6..2ecca8ab168 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -23,9 +23,26 @@ import bpy from bpy.props import BoolProperty, EnumProperty, IntProperty, FloatProperty, FloatVectorProperty -class MakeFur(bpy.types.Operator): - bl_idname = "object.make_fur" - bl_label = "Make Fur" +def object_ensure_material(obj, mat_name): + """ Use an existing material or add a new one. + """ + mat = mat_slot = None + for mat_slot in obj.material_slots: + mat = mat_slot.material + if mat: + break + if mat is None: + mat = bpy.data.materials.new(mat_name) + if mat_slot: + mat_slot.material = mat + else: + obj.data.materials.append(mat) + return mat + + +class QuickFur(bpy.types.Operator): + bl_idname = "object.quick_fur" + bl_label = "Quick Fur" bl_options = {'REGISTER', 'UNDO'} density = EnumProperty(items=( @@ -80,9 +97,156 @@ class MakeFur(bpy.types.Operator): return {'FINISHED'} +class QuickExplode(bpy.types.Operator): + bl_idname = "object.quick_explode" + bl_label = "Quick Explode" + bl_options = {'REGISTER', 'UNDO'} + + style = EnumProperty(items=( + ('EXPLODE', "Explode", ""), + ('BLEND', "Blend", "")), + name="Explode Style", + description="", + default='EXPLODE') + + amount = IntProperty(name="Amount of pieces", + default=100, min=2, max=10000, soft_min=2, soft_max=10000) + + frame_duration = IntProperty(name="Duration", + default=50, min=1, max=300000, soft_min=1, soft_max=10000) + + frame_start = IntProperty(name="Start Frame", + default=1, min=1, max=300000, soft_min=1, soft_max=10000) + + frame_end = IntProperty(name="End Frame", + default=10, min=1, max=300000, soft_min=1, soft_max=10000) + + velocity = FloatProperty(name="Outwards Velocity", + default=1, min=0, max=300000, soft_min=0, soft_max=10) + + fade = BoolProperty(name="Fade", + description="Fade the pieces over time.", + default=True) + + def execute(self, context): + fake_context = bpy.context.copy() + obj_act = context.active_object + + if obj_act.type != 'MESH': + self.report({'ERROR'}, "Active object is not a mesh") + return {'CANCELLED'} + + mesh_objects = [obj for obj in context.selected_objects + if obj.type == 'MESH' and obj != obj_act] + mesh_objects.insert(0, obj_act) + + if self.style == 'BLEND' and len(mesh_objects) != 2: + self.report({'ERROR'}, "Select two mesh objects") + return {'CANCELLED'} + elif not mesh_objects: + self.report({'ERROR'}, "Select at least one mesh object") + return {'CANCELLED'} + + for obj in mesh_objects: + if obj.particle_systems: + self.report({'ERROR'}, "Object %r already has a particle system" % obj.name) + return {'CANCELLED'} + + if self.fade: + tex = bpy.data.textures.new("Explode fade", 'BLEND') + tex.use_color_ramp = True + + if self.style == 'BLEND': + tex.color_ramp.elements[0].position = 0.333 + tex.color_ramp.elements[1].position = 0.666 + + tex.color_ramp.elements[0].color[3] = 1.0 + tex.color_ramp.elements[1].color[3] = 0.0 + + if self.style == 'BLEND': + from_obj = mesh_objects[1] + to_obj = mesh_objects[0] + + for obj in mesh_objects: + fake_context["object"] = obj + bpy.ops.object.particle_system_add(fake_context) + + settings = obj.particle_systems[-1].settings + settings.count = self.amount + settings.frame_start = self.frame_start + settings.frame_end = self.frame_end - self.frame_duration + settings.lifetime = self.frame_duration + settings.normal_factor = self.velocity + settings.render_type = 'NONE' + + explode = obj.modifiers.new(name='Explode', type='EXPLODE') + explode.use_edge_cut = True + + if self.fade: + explode.show_dead = False + bpy.ops.mesh.uv_texture_add(fake_context) + uv = obj.data.uv_textures[-1] + uv.name = "Explode fade" + explode.particle_uv = uv.name + + mat = object_ensure_material(obj, "Explode Fade") + + mat.use_transparency = True + mat.use_transparent_shadows = True + mat.alpha = 0.0 + mat.specular_alpha = 0.0 + + tex_slot = mat.texture_slots.add() + + tex_slot.texture = tex + tex_slot.texture_coords = 'UV' + tex_slot.uv_layer = uv.name + + tex_slot.use_map_alpha = True + + if self.style == 'BLEND': + 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 + else: + tex_slot.use_map_color_diffuse = False + + if self.style == 'BLEND': + settings.physics_type = 'KEYED' + settings.use_emit_random = False + settings.rotation_mode = 'NOR' + + psys = obj.particle_systems[-1] + + fake_context["particle_system"] = obj.particle_systems[-1] + bpy.ops.particle.new_target(fake_context) + bpy.ops.particle.new_target(fake_context) + + if obj == from_obj: + psys.targets[1].object = to_obj + else: + psys.targets[0].object = from_obj + settings.normal_factor = -self.velocity + explode.show_unborn = False + explode.show_dead = True + else: + settings.factor_random = self.velocity + settings.angular_velocity_factor = self.velocity / 10.0 + + return {'FINISHED'} + + def invoke(self, context, event): + self.frame_start = context.scene.frame_current + self.frame_end = self.frame_start + self.frame_duration + return self.execute(context) + def obj_bb_minmax(obj, min_co, max_co): for i in range(0, 8): - bb_vec = Vector((obj.bound_box[i][0], obj.bound_box[i][1], obj.bound_box[i][2])) * obj.matrix_world + bb_vec = Vector(obj.bound_box[i]) * obj.matrix_world min_co[0] = min(bb_vec[0], min_co[0]) min_co[1] = min(bb_vec[1], min_co[1]) @@ -92,9 +256,9 @@ def obj_bb_minmax(obj, min_co, max_co): max_co[2] = max(bb_vec[2], max_co[2]) -class MakeSmoke(bpy.types.Operator): - bl_idname = "object.make_smoke" - bl_label = "Make Smoke" +class QuickSmoke(bpy.types.Operator): + bl_idname = "object.quick_smoke" + bl_label = "Quick Smoke" bl_options = {'REGISTER', 'UNDO'} style = EnumProperty(items=( @@ -112,8 +276,8 @@ class MakeSmoke(bpy.types.Operator): def execute(self, context): fake_context = bpy.context.copy() mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] - min_co = Vector((100000, 100000, 100000)) - max_co = Vector((-100000, -100000, -100000)) + min_co = Vector((100000.0, 100000.0, 100000.0)) + max_co = -min_co if not mesh_objects: self.report({'ERROR'}, "Select at least one mesh object.") @@ -201,9 +365,9 @@ class MakeSmoke(bpy.types.Operator): return {'FINISHED'} -class MakeFluid(bpy.types.Operator): - bl_idname = "object.make_fluid" - bl_label = "Make Fluid" +class QuickFluid(bpy.types.Operator): + bl_idname = "object.quick_fluid" + bl_label = "Quick Fluid" bl_options = {'REGISTER', 'UNDO'} style = EnumProperty(items=( diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 5da89d0090a..c7e3a9e7220 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -257,6 +257,7 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel): col.prop(fluid, "slip_type", text="") if fluid.slip_type == 'PARTIALSLIP': col.prop(fluid, "partial_slip_factor", slider=True, text="Amount") + col.prop(fluid, "surface_noobs") col = split.column() col.label(text="Surface:") diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 17abc4de342..413b19db405 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -911,29 +911,29 @@ class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel): multires_bake = rd.use_bake_multires if not multires_bake: - if rd.bake_type == 'NORMALS': - layout.prop(rd, "bake_normal_space") - elif rd.bake_type in {'DISPLACEMENT', 'AO'}: - layout.prop(rd, "use_bake_normalize") + if rd.bake_type == 'NORMALS': + layout.prop(rd, "bake_normal_space") + elif rd.bake_type in {'DISPLACEMENT', 'AO'}: + layout.prop(rd, "use_bake_normalize") - # col.prop(rd, "bake_aa_mode") - # col.prop(rd, "use_bake_antialiasing") + # col.prop(rd, "bake_aa_mode") + # col.prop(rd, "use_bake_antialiasing") - layout.separator() + layout.separator() - split = layout.split() + split = layout.split() - col = split.column() - col.prop(rd, "use_bake_clear") - col.prop(rd, "bake_margin") - col.prop(rd, "bake_quad_split", text="Split") + col = split.column() + col.prop(rd, "use_bake_clear") + col.prop(rd, "bake_margin") + col.prop(rd, "bake_quad_split", text="Split") - col = split.column() - col.prop(rd, "use_bake_selected_to_active") - sub = col.column() - sub.active = rd.use_bake_selected_to_active - sub.prop(rd, "bake_distance") - sub.prop(rd, "bake_bias") + col = split.column() + col.prop(rd, "use_bake_selected_to_active") + sub = col.column() + sub.active = rd.use_bake_selected_to_active + sub.prop(rd, "bake_distance") + sub.prop(rd, "bake_bias") else: if rd.bake_type == 'DISPLACEMENT': layout.prop(rd, "use_bake_lores_mesh") diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 858c619d3c1..c477a2ff62b 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -42,7 +42,7 @@ class SEQUENCER_HT_header(bpy.types.Header): sub = row.row(align=True) sub.menu("SEQUENCER_MT_view") - if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'): + if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}: sub.menu("SEQUENCER_MT_select") sub.menu("SEQUENCER_MT_marker") sub.menu("SEQUENCER_MT_add") @@ -50,17 +50,17 @@ class SEQUENCER_HT_header(bpy.types.Header): layout.prop(st, "view_type", expand=True, text="") - if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'): + if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}: layout.prop(st, "display_mode", expand=True, text="") - if (st.view_type == 'SEQUENCER'): + if st.view_type == 'SEQUENCER': row = layout.row(align=True) row.operator("sequencer.copy", text="", icon='COPYDOWN') row.operator("sequencer.paste", text="", icon='PASTEDOWN') layout.separator() layout.operator("sequencer.refresh_all") - elif (st.view_type == 'SEQUENCER_PREVIEW'): + elif st.view_type == 'SEQUENCER_PREVIEW': layout.separator() layout.operator("sequencer.refresh_all") layout.prop(st, "display_channel", text="Channel") @@ -101,9 +101,9 @@ class SEQUENCER_MT_view(bpy.types.Menu): layout.separator() - if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'): + if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}: layout.operator("sequencer.view_all", text='View all Sequences') - if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'): + if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}: layout.operator_context = 'INVOKE_REGION_PREVIEW' layout.operator("sequencer.view_all_preview", text='Fit preview in window') layout.operator("sequencer.view_zoom_ratio", text='Show preview 1:1').ratio = 1.0 @@ -300,7 +300,7 @@ class SequencerButtonsPanel(): @staticmethod def has_sequencer(context): - return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW') + return (context.space_data.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}) @classmethod def poll(cls, context): @@ -313,7 +313,7 @@ class SequencerButtonsPanel_Output(): @staticmethod def has_preview(context): - return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW') + return (context.space_data.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}) @classmethod def poll(cls, context): @@ -657,11 +657,17 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): layout.template_ID(strip, "scene") + scene = strip.scene + if scene: + layout.prop(scene.render, "use_sequencer") + layout.label(text="Camera Override") layout.template_ID(strip, "scene_camera") - sce = strip.scene - layout.label(text="Original frame range: %d-%d (%d)" % (sce.frame_start, sce.frame_end, sce.frame_end - sce.frame_start + 1)) + if scene: + sta = scene.frame_start + end = scene.frame_end + layout.label(text="Original frame range: %d-%d (%d)" % (sta, end, end - sta + 1)) class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index f018785a925..7804a1a3c93 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -94,7 +94,7 @@ class USERPREF_HT_header(bpy.types.Header): layout.operator("wm.keyconfig_import") elif userpref.active_section == 'ADDONS': layout.operator("wm.addon_install") - layout.menu("USERPREF_MT_addons_dev_guides", text=" Addons Developer Guides", icon='INFO') + layout.menu("USERPREF_MT_addons_dev_guides") elif userpref.active_section == 'THEMES': layout.operator("ui.reset_default_theme") @@ -438,6 +438,8 @@ class USERPREF_PT_system(bpy.types.Panel): col.label(text="OpenGL:") col.prop(system, "gl_clip_alpha", slider=True) col.prop(system, "use_mipmaps") + col.label(text="Anisotropic Filtering") + col.prop(system, "anisotropic_filter", text="") col.prop(system, "use_vertex_buffer_objects") #Anti-aliasing is disabled as it breaks broder/lasso select #col.prop(system, "use_antialiasing") @@ -847,17 +849,14 @@ class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel): class USERPREF_MT_addons_dev_guides(bpy.types.Menu): - bl_label = "Addons develoment guides" + bl_label = "Develoment Guides" # menu to open webpages with addons development guides def draw(self, context): layout = self.layout - layout.operator('wm.url_open', text='API Concepts' - ).url = 'http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro' - layout.operator('wm.url_open', text='Addons guidelines', - ).url = 'http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons' - layout.operator('wm.url_open', text='How to share your addon', - ).url = 'http://wiki.blender.org/index.php/Dev:Py/Sharing' + layout.operator('wm.url_open', text='API Concepts', icon='URL').url = 'http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro' + layout.operator('wm.url_open', text='Addon Guidelines', icon='URL').url = 'http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons' + layout.operator('wm.url_open', text='How to share your addon', icon='URL').url = 'http://wiki.blender.org/index.php/Dev:Py/Sharing' class USERPREF_PT_addons(bpy.types.Panel): diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 698f0f0fecf..7d3de68c005 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -216,7 +216,7 @@ void pose_remove_group(struct Object *ob); /* Assorted Evaluation ----------------- */ /* Used for the Action Constraint */ -void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); +void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); /* for proxy */ void copy_pose_result(struct bPose *to, struct bPose *from); diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 14251fb1762..f36073ba841 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -51,22 +51,23 @@ struct GHash; /* **** DAG relation types *** */ /* scene link to object */ -#define DAG_RL_SCENE 1 +#define DAG_RL_SCENE (1<<0) /* object link to data */ -#define DAG_RL_DATA 2 +#define DAG_RL_DATA (1<<1) /* object changes object (parent, track, constraints) */ -#define DAG_RL_OB_OB 4 +#define DAG_RL_OB_OB (1<<2) /* object changes obdata (hooks, constraints) */ -#define DAG_RL_OB_DATA 8 +#define DAG_RL_OB_DATA (1<<3) /* data changes object (vertex parent) */ -#define DAG_RL_DATA_OB 16 +#define DAG_RL_DATA_OB (1<<4) /* data changes data (deformers) */ -#define DAG_RL_DATA_DATA 32 +#define DAG_RL_DATA_DATA (1<<5) -#define DAG_NO_RELATION 64 -#define DAG_RL_ALL 63 -#define DAG_RL_ALL_BUT_DATA 61 +#define DAG_NO_RELATION (1<<6) + +#define DAG_RL_ALL_BUT_DATA (DAG_RL_SCENE|DAG_RL_OB_OB|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_DATA_DATA) +#define DAG_RL_ALL (DAG_RL_ALL_BUT_DATA|DAG_RL_DATA) typedef void (*graph_action_func)(void * ob, void **data); diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 68745975dae..b00db53a199 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -97,15 +97,10 @@ extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -extern void shadeDispList(struct Scene *scene, struct Base *base); -extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me); int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); -void reshadeall_displist(struct Scene *scene); void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); -void fastshade_free_render(void); - float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 4dfc53e1734..feeab98ad78 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -300,6 +300,8 @@ void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, in void psys_check_boid_data(struct ParticleSystem *psys); +void psys_get_birth_coordinates(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra); + void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys); /* ----------- functions needed only inside particlesystem ------------ */ diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 1fed115893c..ef4f320602b 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -69,8 +69,9 @@ typedef struct DagNode void * ob; void * first_ancestor; int ancestor_count; - unsigned int lay; // accumulated layers of its relations + itself + unsigned int lay; // accumulated layers of its relations + itself unsigned int scelay; // layers due to being in scene + unsigned int customdata_mask; // customdata mask int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing int BFS_dist; // BFS distance int DFS_dist; // DFS distance diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 77f56058a4f..f7086c81756 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1128,7 +1128,7 @@ void copy_pose_result(bPose *to, bPose *from) /* For the calculation of the effects of an Action at the given frame on an object * This is currently only used for the Action Constraint */ -void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) +void what_does_obaction (Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { bActionGroup *agrp= action_groups_find_named(act, groupname); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5a9432552d2..0f545ad3ff9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -154,7 +154,6 @@ static void clear_global(void) { // extern short winqueue_break; /* screen.c */ - fastshade_free_render(); /* lamps hang otherwise */ free_main(G.main); /* free all lib data */ // free_vertexpaint(); diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 5520e4d1d41..cc45abb5998 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -493,7 +493,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co, // NOTE: casts to "float*" here are due to co being "const float*" closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1); - dist = len_v3v3(nearest_tmp, (float*)co); + dist = len_squared_v3v3(nearest_tmp, (float*)co); if(dist < nearest->dist) { diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index d3c14a9dd12..7be4744a224 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -424,7 +424,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* ------------ General Target Matrix Tools ---------- */ /* function that sets the given matrix based on given vertex group in mesh */ -static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4]) +static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4]) { DerivedMesh *dm = NULL; Mesh *me= ob->data; @@ -449,16 +449,9 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substr freeDM= 1; } else { - /* when not in EditMode, use the 'final' derived mesh - * - check if the custom data masks for derivedFinal mean that we can just use that - * (this is more effficient + sufficient for most cases) - */ - if (!(ob->lastDataMask & CD_MASK_MDEFORMVERT)) { - dm = mesh_get_derived_final(scene, ob, CD_MASK_MDEFORMVERT); - freeDM= 1; - } - else - dm = (DerivedMesh *)ob->derivedFinal; + /* when not in EditMode, use the 'final' derived mesh, depsgraph + * ensures we build with CD_MDEFORMVERT layer */ + dm = (DerivedMesh *)ob->derivedFinal; } /* only continue if there's a valid DerivedMesh */ @@ -587,7 +580,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* generic function to get the appropriate matrix for most target cases */ /* The cases where the target can be object data have not been implemented */ -static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) +static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) { /* Case OBJECT */ if (!strlen(substring)) { @@ -604,7 +597,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *sub * way as constraints can only really affect things on object/bone level. */ else if (ob->type == OB_MESH) { - contarget_get_mesh_mat(scene, ob, substring, mat); + contarget_get_mesh_mat(ob, substring, mat); constraint_mat_convertspace(ob, NULL, mat, from, to); } else if (ob->type == OB_LATTICE) { @@ -684,10 +677,10 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { /* This function should be used for the get_target_matrix member of all * constraints that are not picky about what happens to their target matrix. */ -static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) unit_m4(ct->matrix); } @@ -1159,7 +1152,7 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra bKinematicConstraint *data= con->data; if (VALID_CONS_TARGET(ct)) - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) { if (data->flag & CONSTRAINT_IK_AUTO) { Object *ob= cob->ob; @@ -2046,7 +2039,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT /* firstly calculate the matrix the normal way, then let the py-function override * this matrix if it needs to do so */ - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* only execute target calculation if allowed */ #ifdef WITH_PYTHON @@ -2165,7 +2158,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint unit_m4(ct->matrix); /* get the transform matrix of the target */ - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* determine where in transform range target is */ /* data->type is mapped as follows for backwards compatability: @@ -2216,7 +2209,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint tchan->rotmode= pchan->rotmode; /* evaluate action using workob (it will only set the PoseChannel in question) */ - what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t); + what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t); /* convert animation to matrices for use here */ pchan_calc_mat(tchan); @@ -2230,7 +2223,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* evaluate using workob */ // FIXME: we don't have any consistent standards on limiting effects on object... - what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, NULL, t); + what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); object_to_mat4(&workob, ct->matrix); } else { diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 472d7d77b80..c2800410657 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -372,6 +372,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O node2->first_ancestor = ob; node2->ancestor_count += 1; } + + /* also build a custom data mask for dependencies that need certain layers */ + node->customdata_mask= 0; if (ob->type == OB_ARMATURE) { if (ob->pose){ @@ -451,8 +454,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O case PARSKEL: dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); break; - case PARVERT1: case PARVERT3: case PARBONE: + case PARVERT1: case PARVERT3: dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + node2->customdata_mask |= CD_MASK_ORIGINDEX; + break; + case PARBONE: + dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); break; default: if(ob->parent->type==OB_LATTICE) @@ -647,8 +654,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); else { - if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) + if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + if (obt->type == OB_MESH) + node2->customdata_mask |= CD_MASK_MDEFORMVERT; + } else dag_add_relation(dag, node2, node, DAG_RL_OB_OB, cti->name); } @@ -722,6 +732,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) itA->node->color |= itA->type; } } + + /* also flush custom data mask */ + ((Object*)node->ob)->customdata_mask= node->customdata_mask; } } /* now set relations equal, so that when only one parent changes, the correct recalcs are found */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9aa794aa97e..8f57490d057 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -65,9 +65,6 @@ #include "BKE_lattice.h" #include "BKE_modifier.h" -#include "RE_pipeline.h" -#include "RE_shader_ext.h" - #include "BLO_sys_types.h" // for intptr_t support #include "ED_curve.h" /* for BKE_curve_nurbs */ @@ -286,499 +283,6 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i return 1; } -/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */ - -/* create default shade input... save cpu cycles with ugly global */ -/* XXXX bad code warning: local ShadeInput initialize... */ -static ShadeInput shi; -static void init_fastshade_shadeinput(Render *re) -{ - memset(&shi, 0, sizeof(ShadeInput)); - shi.lay= RE_GetScene(re)->lay; - shi.view[2]= -1.0f; - shi.passflag= SCE_PASS_COMBINED; - shi.combinedflag= -1; -} - -static Render *fastshade_get_render(Scene *UNUSED(scene)) -{ - // XXX 2.5: this crashes combined with previewrender - // due to global R so disabled for now -#if 0 - /* XXX ugly global still, but we can't do preview while rendering */ - if(G.rendering==0) { - - Render *re= RE_GetRender("_Shade View_"); - if(re==NULL) { - re= RE_NewRender("_Shade View_"); - - RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */ - } - return re; - } -#endif - - return NULL; -} - -/* called on file reading */ -void fastshade_free_render(void) -{ - Render *re= RE_GetRender("_Shade View_"); - - if(re) { - RE_Database_Free(re); - RE_FreeRender(re); - } -} - - -static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma) -{ - CustomDataLayer *layer; - MTFace *mtface; - int index, needuv= ma->texco & TEXCO_UV; - char *vertcol; - - shi.totuv= 0; - shi.totcol= 0; - - for(index=0; indextotlayer; index++) { - layer= &fdata->layers[index]; - - if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) { - mtface= &((MTFace*)layer->data)[a]; - - shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f; - shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f; - shi.uv[shi.totuv].uv[2]= 1.0f; - - shi.uv[shi.totuv].name= layer->name; - shi.totuv++; - } - else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) { - vertcol= (char*)&((MCol*)layer->data)[a*4 + j]; - - shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f; - shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f; - shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f; - - shi.col[shi.totcol].name= layer->name; - shi.totcol++; - } - } - - if(needuv && shi.totuv == 0) - VECCOPY(shi.uv[0].uv, shi.lo); - - if(shi.totcol) - VECCOPY(shi.vcol, shi.col[0].col); -} - -static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2) -{ - ShadeResult shr; - int a; - - VECCOPY(shi.co, co); - shi.vn[0]= -nor[0]; - shi.vn[1]= -nor[1]; - shi.vn[2]= -nor[2]; - VECCOPY(shi.vno, shi.vn); - VECCOPY(shi.facenor, shi.vn); - - if(ma->texco) { - VECCOPY(shi.lo, orco); - - if(ma->texco & TEXCO_GLOB) { - VECCOPY(shi.gl, shi.lo); - } - if(ma->texco & TEXCO_WINDOW) { - VECCOPY(shi.winco, shi.lo); - } - if(ma->texco & TEXCO_STICKY) { - VECCOPY(shi.sticky, shi.lo); - } - if(ma->texco & TEXCO_OBJECT) { - VECCOPY(shi.co, shi.lo); - } - if(ma->texco & TEXCO_NORM) { - VECCOPY(shi.orn, shi.vn); - } - if(ma->texco & TEXCO_REFL) { - float inp= 2.0f * (shi.vn[2]); - shi.ref[0]= (inp*shi.vn[0]); - shi.ref[1]= (inp*shi.vn[1]); - shi.ref[2]= (-1.0f + inp*shi.vn[2]); - } - } - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col1[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col1[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col1[2]= CLAMPIS(a, 0, 255); - - if(col2) { - shi.vn[0]= -shi.vn[0]; - shi.vn[1]= -shi.vn[1]; - shi.vn[2]= -shi.vn[2]; - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col2[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col2[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col2[2]= CLAMPIS(a, 0, 255); - } -} - -static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3]) -{ - float tmat[4][4]; - float amb[3]= {0.0f, 0.0f, 0.0f}; - int a; - - /* initialize globals in render */ - RE_shade_external(re, NULL, NULL); - - /* initialize global here */ - init_fastshade_shadeinput(re); - - RE_DataBase_GetView(re, tmat); - mul_m4_m4m4(mat, ob->obmat, tmat); - - invert_m4_m4(tmat, mat); - copy_m3_m4(imat, tmat); - if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0); - - if (need_orco_r) *need_orco_r= 0; - for(a=0; atotcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) { - init_render_material(ma, 0, amb); - - if(ma->texco & TEXCO_ORCO) { - if (need_orco_r) *need_orco_r= 1; - } - } - } -} - -static void end_fastshade_for_ob(Object *ob) -{ - int a; - - for(a=0; atotcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) - end_render_material(ma); - } -} - - -static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r) -{ - Mesh *me= ob->data; - DerivedMesh *dm; - MVert *mvert; - MFace *mface; - unsigned int *col1, *col2; - float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3]; - int a, i, need_orco, totface, totvert; - CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL - | CD_MASK_MTFACE | CD_MASK_NORMAL; - - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if(need_orco) - dataMask |= CD_MASK_ORCO; - - if (onlyForMesh) - dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask); - else - dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask); - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - nors = dm->getFaceDataArray(dm, CD_NORMAL); - totvert = dm->getNumVerts(dm); - totface = dm->getNumFaces(dm); - orco= dm->getVertDataArray(dm, CD_ORCO); - - if (onlyForMesh) { - col1 = *col1_r; - col2 = NULL; - } else { - *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1"); - - if (col2_r && (me->flag & ME_TWOSIDED)) - col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2"); - else - col2 = NULL; - - if (col2_r) *col2_r = col2; - } - - /* vertexnormals */ - vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp"); - for (a=0; ano[0]; - float yn= mv->no[1]; - float zn= mv->no[2]; - - /* transpose ! */ - vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; - vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; - vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - normalize_v3(vn); - } - - for (i=0; imat_nr+1); - int j, vidx[4], nverts= mf->v4?4:3; - unsigned char *col1base= (unsigned char*) &col1[i*4]; - unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL); - float nor[3], n1[3]; - - if(ma==NULL) ma= &defmaterial; - - vidx[0]= mf->v1; - vidx[1]= mf->v2; - vidx[2]= mf->v3; - vidx[3]= mf->v4; - - if (nors) { - VECCOPY(nor, &nors[i*3]); - } else { - if (mf->v4) - normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - else - normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); - } - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - for (j=0; jflag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - mul_v3_m4v3(vec, mat, mv->co); - - mul_v3_v3fl(vec, vn, 0.001f); - - fastshade_customdata(&dm->faceData, i, j, ma); - fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2); - } - } - MEM_freeN(vnors); - - dm->release(dm); - - end_fastshade_for_ob(ob); -} - -void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me) -{ - Render *re= fastshade_get_render(scene); - int a; - char *cp; - unsigned int *mcol= (unsigned int*)me->mcol; - - if(re) { - mesh_create_shadedColors(re, ob, 1, &mcol, NULL); - me->mcol= (MCol*)mcol; - - /* swap bytes */ - for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) { - SWAP(char, cp[0], cp[3]); - SWAP(char, cp[1], cp[2]); - } - } -} - -/* has base pointer, to check for layer */ -/* called from drawobject.c */ -void shadeDispList(Scene *scene, Base *base) -{ - Object *ob= base->object; - DispList *dl, *dlob; - Material *ma = NULL; - Render *re; - float imat[3][3], mat[4][4], vec[3]; - float *fp, *nor, n1[3]; - unsigned int *col1; - int a, need_orco; - - re= fastshade_get_render(scene); - if(re==NULL) - return; - - dl = find_displist(&ob->disp, DL_VERTCOL); - if (dl) { - BLI_remlink(&ob->disp, dl); - free_disp_elem(dl); - } - - if(ob->type==OB_MESH) { - dl= MEM_callocN(sizeof(DispList), "displistshade"); - dl->type= DL_VERTCOL; - - mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2); - - /* add dl to ob->disp after mesh_create_shadedColors, because it - might indirectly free ob->disp */ - BLI_addtail(&ob->disp, dl); - } - else { - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - - /* now we need the normals */ - dl= ob->disp.first; - - while(dl) { - dlob= MEM_callocN(sizeof(DispList), "displistshade"); - BLI_addtail(&ob->disp, dlob); - dlob->type= DL_VERTCOL; - dlob->parts= dl->parts; - dlob->nr= dl->nr; - - if(dl->type==DL_INDEX3) { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - } - else { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1"); - } - - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - if(dl->type==DL_INDEX3) { - if(dl->nors) { - /* there's just one normal */ - n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2]; - n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2]; - n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2]; - normalize_v3(n1); - - fp= dl->verts; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; - } - } - } - else if(dl->type==DL_SURF) { - if(dl->nors) { - a= dl->nr*dl->parts; - fp= dl->verts; - nor= dl->nors; - - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; nor+= 3; col1++; - } - } - } - dl= dl->next; - } - } - else if(ob->type==OB_MBALL) { - /* there are normals already */ - dl= ob->disp.first; - - while(dl) { - - if(dl->type==DL_INDEX4) { - if(dl->nors) { - if(dl->col1) MEM_freeN(dl->col1); - col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - fp= dl->verts; - nor= dl->nors; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - /* transpose ! */ - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; nor+= 3; - } - } - } - dl= dl->next; - } - } - - end_fastshade_for_ob(ob); - } -} - -/* frees render and shade part of displists */ -/* note: dont do a shade again, until a redraw happens */ -void reshadeall_displist(Scene *scene) -{ - Base *base; - Object *ob; - - fastshade_free_render(); - - for(base= scene->base.first; base; base= base->next) { - ob= base->object; - - if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) - freedisplist(&ob->disp); - - if(base->lay & scene->lay) { - /* Metaballs have standard displist at the Object */ - if(ob->type==OB_MBALL) shadeDispList(scene, base); - } - } -} - /* ****************** make displists ********************* */ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6090b7166e9..b02bdd8e57e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2651,11 +2651,12 @@ void object_handle_update(Scene *scene, Object *ob) #else /* ensure CD_MASK_BAREMESH for now */ EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if(em) { - makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */ + makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); } else - makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH); + makeDerivedMesh(scene, ob, NULL, data_mask); #endif } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index fca8d470dc1..4e3840832bb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1562,8 +1562,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) } } } -/* sets particle to the emitter surface with initial velocity & rotation */ -void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) +void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra) { Object *ob = sim->ob; ParticleSystem *psys = sim->psys; @@ -1575,17 +1574,6 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float q_phase[4]; int p = pa - psys->particles; part=psys->part; - - /* get precise emitter matrix if particle is born */ - if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { - /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ - while(ob) { - BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); - ob = ob->parent; - } - ob = sim->ob; - where_is_object_time(sim->scene, ob, pa->time); - } /* get birth location from object */ if(part->tanfac != 0.f) @@ -1594,7 +1582,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); /* get possible textural influence */ - psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra); + psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra); /* particles live in global space so */ /* let's convert: */ @@ -1654,37 +1642,27 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, mat4_to_quat(rot,ob->obmat); mul_qt_qtqt(r_rot,r_rot,rot); } -#if 0 - } -#endif if(part->phystype==PART_PHYS_BOIDS && pa->boid) { - BoidParticle *bpa = pa->boid; float dvec[3], q[4], mat[3][3]; - copy_v3_v3(pa->state.co,loc); + copy_v3_v3(state->co,loc); /* boids don't get any initial velocity */ - zero_v3(pa->state.vel); + zero_v3(state->vel); /* boids store direction in ave */ if(fabsf(nor[2])==1.0f) { - sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]); - normalize_v3(pa->state.ave); + sub_v3_v3v3(state->ave, loc, ob->obmat[3]); + normalize_v3(state->ave); } else { - VECCOPY(pa->state.ave, nor); + VECCOPY(state->ave, nor); } - /* and gravity in r_ve */ - bpa->gravity[0] = bpa->gravity[1] = 0.0f; - bpa->gravity[2] = -1.0f; - if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) - && sim->scene->physics_settings.gravity[2]!=0.0f) - bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; /* calculate rotation matrix */ - project_v3_v3v3(dvec, r_vel, pa->state.ave); - sub_v3_v3v3(mat[0], pa->state.ave, dvec); + project_v3_v3v3(dvec, r_vel, state->ave); + sub_v3_v3v3(mat[0], state->ave, dvec); normalize_v3(mat[0]); negate_v3_v3(mat[2], r_vel); normalize_v3(mat[2]); @@ -1692,12 +1670,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* apply rotation */ mat3_to_quat_is_ok( q,mat); - copy_qt_qt(pa->state.rot, q); - - bpa->data.health = part->boids->health; - bpa->data.mode = eBoidMode_InAir; - bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; - bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; + copy_qt_qt(state->rot, q); } else { /* conversion done so now we apply new: */ @@ -1710,7 +1683,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter velocity */ if(dtime != 0.f && part->obfac != 0.f){ - sub_v3_v3v3(vel, loc, pa->state.co); + sub_v3_v3v3(vel, loc, state->co); mul_v3_fl(vel, part->obfac/dtime); } @@ -1747,13 +1720,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, if(part->partfac != 0.f) madd_v3_v3fl(vel, p_vel, part->partfac); - mul_v3_v3fl(pa->state.vel, vel, ptex.ivel); + mul_v3_v3fl(state->vel, vel, ptex.ivel); /* -location from emitter */ - copy_v3_v3(pa->state.co,loc); + copy_v3_v3(state->co,loc); /* -rotation */ - unit_qt(pa->state.rot); + unit_qt(state->rot); if(part->rotmode){ /* create vector into which rotation is aligned */ @@ -1793,32 +1766,74 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ - mul_qt_qtqt(pa->state.rot, rot, q_phase); + mul_qt_qtqt(state->rot, rot, q_phase); } /* -angular velocity */ - zero_v3(pa->state.ave); + zero_v3(state->ave); if(part->avemode){ switch(part->avemode){ case PART_AVE_SPIN: - copy_v3_v3(pa->state.ave, vel); + copy_v3_v3(state->ave, vel); break; case PART_AVE_RAND: - copy_v3_v3(pa->state.ave, r_ave); + copy_v3_v3(state->ave, r_ave); break; } - normalize_v3(pa->state.ave); - mul_v3_fl(pa->state.ave,part->avefac); + normalize_v3(state->ave); + mul_v3_fl(state->ave, part->avefac); } } +} +/* sets particle to the emitter surface with initial velocity & rotation */ +void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) +{ + Object *ob = sim->ob; + ParticleSystem *psys = sim->psys; + ParticleSettings *part; + ParticleTexture ptex; + int p = pa - psys->particles; + part=psys->part; + + /* get precise emitter matrix if particle is born */ + if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { + /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ + while(ob) { + BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); + ob = ob->parent; + } + ob = sim->ob; + where_is_object_time(sim->scene, ob, pa->time); + } + + psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra); + + if(part->phystype==PART_PHYS_BOIDS && pa->boid) { + BoidParticle *bpa = pa->boid; + + /* and gravity in r_ve */ + bpa->gravity[0] = bpa->gravity[1] = 0.0f; + bpa->gravity[2] = -1.0f; + if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) + && sim->scene->physics_settings.gravity[2]!=0.0f) + bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; + + bpa->data.health = part->boids->health; + bpa->data.mode = eBoidMode_InAir; + bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; + bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; + } if(part->type == PART_HAIR){ pa->lifetime = 100.0f; } else{ + /* get possible textural influence */ + psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra); + pa->lifetime = part->lifetime * ptex.life; if(part->randlife != 0.0f) @@ -1904,6 +1919,7 @@ static void set_keyed_keys(ParticleSimulationData *sim) PARTICLE_P; ParticleKey *key; int totpart = psys->totpart, k, totkeys = psys->totkeyed; + int keyed_flag = 0; ksim.scene= sim->scene; @@ -1933,6 +1949,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) for(k=0; kob ? pt->ob : sim->ob; ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1); + keyed_flag = (ksim.psys->flag & PSYS_KEYED); + ksim.psys->flag &= ~PSYS_KEYED; LOOP_PARTICLES { key = pa->keys + k; @@ -1956,6 +1974,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f) k++; + ksim.psys->flag |= keyed_flag; + pt = (pt->next && pt->next->flag & PTARGET_VALID)? pt->next : psys->targets.first; } diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 16cef67ea6d..0d523599598 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -430,6 +430,7 @@ void init_actuator(bActuator *act) act->data= MEM_callocN(sizeof(bCameraActuator), "camact"); ca = act->data; ca->axis = ACT_CAMERA_X; + ca->damping = 1.0/32.0; break; case ACT_EDIT_OBJECT: act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact"); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 83925ab7927..9c45d2b9d7b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4322,6 +4322,7 @@ static void direct_link_object(FileData *fd, Object *ob) MEM_freeN(hook); } + ob->customdata_mask= 0; ob->bb= NULL; ob->derivedDeform= NULL; ob->derivedFinal= NULL; @@ -11797,6 +11798,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + { + /* add default value for behind strength of camera actuator */ + Object *ob; + bActuator *act; + for(ob = main->object.first; ob; ob= ob->id.next) { + for(act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_CAMERA) { + bCameraActuator *ba= act->data; + + ba->damping = 1.0/32.0; + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index bccc7bdb769..77cdf889ea5 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -113,9 +113,10 @@ LIBIMPORT void interlace(struct ImBuf *ib); LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height); -LIBIMPORT void IMB_rectfill(struct ImBuf *drect, float col[4]); +LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]); LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value); #endif /* IFF_H */ diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 72341e1caa2..10e6d611cc5 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -959,12 +959,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) { att2 = quadatt; - d = (1.0f/quadatt) * 2; + d = sqrt(1.0f/quadatt); } // linear light else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) { att1 = linatt; - d = (1.0f/linatt) * 2; + d = (1.0f/linatt); } else if (IS_EQ(constatt, 1.0f)) { att1 = 1.0f; } else { @@ -987,9 +987,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) case COLLADAFW::Light::SPOT_LIGHT: { lamp->type = LA_SPOT; - lamp->falloff_type = LA_FALLOFF_INVSQUARE; lamp->att1 = att1; lamp->att2 = att2; + if(IS_EQ(att1, 0.0f) && att2 > 0) + lamp->falloff_type = LA_FALLOFF_INVSQUARE; + if(IS_EQ(att2, 0.0f) && att1 > 0) + lamp->falloff_type = LA_FALLOFF_INVLINEAR; lamp->spotsize = light->getFallOffAngle().getValue(); lamp->spotblend = light->getFallOffExponent().getValue(); } @@ -1004,9 +1007,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) case COLLADAFW::Light::POINT_LIGHT: { lamp->type = LA_LOCAL; - lamp->falloff_type = LA_FALLOFF_INVSQUARE; lamp->att1 = att1; lamp->att2 = att2; + if(IS_EQ(att1, 0.0f) && att2 > 0) + lamp->falloff_type = LA_FALLOFF_INVSQUARE; + if(IS_EQ(att2, 0.0f) && att1 > 0) + lamp->falloff_type = LA_FALLOFF_INVLINEAR; } break; case COLLADAFW::Light::UNDEFINED: diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index 89599c62768..12ccf77f6ad 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -68,20 +68,18 @@ void LightsExporter::operator()(Object *ob) std::string la_name(id_name(la)); COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy); float e, d, constatt, linatt, quadatt; - float r; d = la->dist; - r = d/2.0f; constatt = 1.0f; if(la->falloff_type==LA_FALLOFF_INVLINEAR) { - linatt = 1.0f / r; + linatt = 1.0f / d; quadatt = 0.0f; } else { linatt = 0.0f; - quadatt = 1.0f / r; + quadatt = 1.0f / (d * d); } // sun diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bd016a06e99..ddcb204fc29 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1586,21 +1586,22 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu CurveMapping *cumap = cumap_v; uiBlock *block; uiBut *bt; + float width= 8*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -4, 16, 128, 106, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping", - 0,100,120,18, &cumap->flag, 0.0, 0.0, 10, 0, ""); + 0,5*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL); uiBlockBeginAlign(block); - uiDefButF(block, NUM, 0, "Min X ", 0,74,120,18, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); - uiDefButF(block, NUM, 0, "Min Y ", 0,56,120,18, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); - uiDefButF(block, NUM, 0, "Max X ", 0,38,120,18, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "Max Y ", 0,20,120,18, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "Min X ", 0,4*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, ""); + uiDefButF(block, NUM, 0, "Min Y ", 0,3*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, ""); + uiDefButF(block, NUM, 0, "Max X ", 0,2*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "Max Y ", 0,UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, ""); uiBlockSetDirection(block, UI_RIGHT); @@ -1644,17 +1645,17 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) { uiBlock *block; - short yco= 0, menuwidth=120; + short yco= 0, menuwidth=10*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1666,15 +1667,15 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void *cumap_v) { uiBlock *block; - short yco= 0, menuwidth=120; + short yco= 0, menuwidth=10*UI_UNIT_X; block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1728,15 +1729,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1746,19 +1747,19 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[3].curve) { - bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1768,15 +1769,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if(cumap->cm[0].curve) { - bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[1].curve) { - bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } if(cumap->cm[2].curve) { - bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); + bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } @@ -1791,24 +1792,24 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); + bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in"); uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL); - bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); + bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out"); uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); if(brush) - bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, "Tools"); else - bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools"); + bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, "Tools"); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; - bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, 18, "Clipping Options"); + bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, "Clipping Options"); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); + bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points"); uiButSetNFunc(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap); uiBlockSetEmboss(block, UI_EMBOSS); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 41bb12e4433..b6e255b6758 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2326,39 +2326,43 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s wtb.outline= 0; widgetbase_draw(&wtb, wcol); - /* slider part */ - VECCOPY(outline, wcol->outline); - VECCOPY(wcol->outline, wcol->item); - VECCOPY(wcol->inner, wcol->item); + /* draw left/right parts only when not in text editing */ + if(!(state & UI_TEXTINPUT)) { + + /* slider part */ + VECCOPY(outline, wcol->outline); + VECCOPY(wcol->outline, wcol->item); + VECCOPY(wcol->inner, wcol->item); - if(!(state & UI_SELECT)) - SWAP(short, wcol->shadetop, wcol->shadedown); - - rect1= *rect; - - value= ui_get_but_val(but); - fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); - - /* left part of slider, always rounded */ - rect1.xmax= rect1.xmin + ceil(offs+1.0f); - round_box_edges(&wtb1, roundboxalign & ~6, &rect1, offs); - wtb1.outline= 0; - widgetbase_draw(&wtb1, wcol); - - /* right part of slider, interpolate roundness */ - rect1.xmax= rect1.xmin + fac + offs; - rect1.xmin+= floor(offs-1.0f); - if(rect1.xmax + offs > rect->xmax) - offs*= (rect1.xmax + offs - rect->xmax)/offs; - else - offs= 0.0f; - round_box_edges(&wtb1, roundboxalign & ~9, &rect1, offs); - - widgetbase_draw(&wtb1, wcol); - VECCOPY(wcol->outline, outline); - - if(!(state & UI_SELECT)) - SWAP(short, wcol->shadetop, wcol->shadedown); + if(!(state & UI_SELECT)) + SWAP(short, wcol->shadetop, wcol->shadedown); + + rect1= *rect; + + value= ui_get_but_val(but); + fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); + + /* left part of slider, always rounded */ + rect1.xmax= rect1.xmin + ceil(offs+1.0f); + round_box_edges(&wtb1, roundboxalign & ~6, &rect1, offs); + wtb1.outline= 0; + widgetbase_draw(&wtb1, wcol); + + /* right part of slider, interpolate roundness */ + rect1.xmax= rect1.xmin + fac + offs; + rect1.xmin+= floor(offs-1.0f); + if(rect1.xmax + offs > rect->xmax) + offs*= (rect1.xmax + offs - rect->xmax)/offs; + else + offs= 0.0f; + round_box_edges(&wtb1, roundboxalign & ~9, &rect1, offs); + + widgetbase_draw(&wtb1, wcol); + VECCOPY(wcol->outline, outline); + + if(!(state & UI_SELECT)) + SWAP(short, wcol->shadetop, wcol->shadedown); + } /* outline */ wtb.outline= 1; @@ -2597,6 +2601,7 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED( /* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects * over the top to indicate disabled buttons */ + /* XXX, this doesnt work right since the color applies to buttons outside the box too. */ glClearColor(wcol->inner[0]/255.0, wcol->inner[1]/255.0, wcol->inner[2]/255.0, 1.0); VECCOPY(wcol->inner, old_col); @@ -2872,7 +2877,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct ThemeUI *tui= &btheme->tui; uiFontStyle *fstyle= &style->widget; uiWidgetType *wt= NULL; - + /* handle menus separately */ if(but->dt==UI_EMBOSSP) { switch (but->type) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 6527e0140b8..3f825762d74 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1580,6 +1580,8 @@ void init_userdef_do_versions(void) U.dragthreshold= 5; if (U.widget_unit==0) U.widget_unit= (U.dpi * 20 + 36)/72; + if (U.anisotropic_filter <= 0) + U.anisotropic_filter = 1; /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 424d3dd5a38..bfae101d38e 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3967,6 +3967,7 @@ short sharesFace(EditMesh *em, EditEdge* e1, EditEdge* e2) return 0; } +#if 0 typedef struct SlideUv { float origuv[2]; @@ -3980,7 +3981,6 @@ typedef struct SlideVert { EditVert origvert; } SlideVert; -#if 0 int EdgeSlide(EditMesh *em, wmOperator *op, short immediate, float imperc) { return 0; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index f3e26cfee36..c4a302d4d18 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -235,7 +235,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) return 1; } -int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set) +int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *me, const char *name, int active_set) { EditMesh *em; MCol *mcol; @@ -272,9 +272,6 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum); mesh_update_customdata_pointers(me); - - if(!mcol) - shadeMeshMCol(scene, ob, me); } DAG_id_tag_update(&me->id, 0); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c5236a38970..7ca172c6945 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -823,8 +823,6 @@ static int object_delete_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - if(islamp) reshadeall_displist(scene); /* only frees displist */ - DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 565c5810cff..fc5f09f2fe0 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -858,29 +858,7 @@ static void finish_images(MultiresBakeRender *bkr) if(ibuf->x<=0 || ibuf->y<=0) continue; - /* Margin */ - if(bkr->bake_filter) { - char *temprect; - - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - - for(i=0; ibake_filter; i++) - IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin */ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - - for(i= 0; ibake_filter; i++) - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, bkr->bake_filter); ibuf->userflags|= IB_BITMAPDIRTY; if(ibuf->mipmap[0]) { @@ -1028,7 +1006,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l static void clear_images(MTFace *mtface, int totface) { int a; - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; for(a= 0; aid.flag&= ~LIB_DOIT; @@ -1039,7 +1018,7 @@ static void clear_images(MTFace *mtface, int totface) if((ima->id.flag&LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); ima->id.flag|= LIB_DOIT; } } @@ -1332,7 +1311,6 @@ static void finish_bake_internal(BakeRender *bkr) /* freed when baking is done, but if its canceled we need to free here */ if (ibuf->userdata) { - printf("freed\n"); MEM_freeN(ibuf->userdata); ibuf->userdata= NULL; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 32844e6af5d..fca35683c6f 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -399,6 +399,13 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) { + ModifierTypeInfo *mti= modifierType_getInfo(md->type); + + if (mti->isDisabled && mti->isDisabled(md, 0)) { + BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); + return 0; + } + if (ob->type==OB_MESH) { DerivedMesh *dm; Mesh *me= ob->data; @@ -442,7 +449,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, { ModifierTypeInfo *mti= modifierType_getInfo(md->type); - if (!(md->mode&eModifierMode_Realtime) || (mti->isDisabled && mti->isDisabled(md, 0))) { + if (mti->isDisabled && mti->isDisabled(md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } @@ -484,7 +491,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); } } - } + } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu; int numVerts; @@ -530,6 +537,8 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, ModifierData *md, int mode) { + int prev_mode; + if (scene->obedit) { BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in editmode"); return 0; @@ -541,12 +550,20 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi if (md!=ob->modifiers.first) BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected."); + /* allow apply of a not-realtime modifier, by first re-enabling realtime. */ + prev_mode= md->mode; + md->mode |= eModifierMode_Realtime; + if (mode == MODIFIER_APPLY_SHAPE) { - if (!modifier_apply_shape(reports, scene, ob, md)) + if (!modifier_apply_shape(reports, scene, ob, md)) { + md->mode= prev_mode; return 0; + } } else { - if (!modifier_apply_obdata(reports, scene, ob, md)) + if (!modifier_apply_obdata(reports, scene, ob, md)) { + md->mode= prev_mode; return 0; + } } BLI_remlink(&ob->modifiers, md); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index f7158e4b4ec..aa2e6d2c145 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1127,8 +1127,6 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - - if(islamp) reshadeall_displist(scene); /* only frees */ /* warning, active object may be hidden now */ diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 4aa9b942cf3..b573c77c7f3 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -56,6 +56,7 @@ #include "DNA_object_fluidsim.h" #include "BLI_blenlib.h" +#include "BLI_fileops.h" #include "BLI_threads.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -125,7 +126,7 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { copy_v3_v3(gravity, scene->physics_settings.gravity); } else { - copy_v3_v3(gravity, &fss->gravx); + copy_v3_v3(gravity, fss->grav); } } @@ -443,7 +444,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE); - float rot_d[3], old_rot[3] = {0.f, 0.f, 0.f}; + float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f}; if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; @@ -809,6 +810,44 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, } } +/* copied from rna_fluidsim.c: fluidsim_find_lastframe() */ +static void fluidsim_delete_until_lastframe(FluidsimSettings *fss) +{ + char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; + char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR]; + char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR]; + int curFrame = 1, exists = 0; + + BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath); + BLI_snprintf(targetDirVel, sizeof(targetDir), "%sfluidsurface_final_####.bvel.gz", fss->surfdataPath); + BLI_snprintf(previewDir, sizeof(targetDir), "%sfluidsurface_preview_####.bobj.gz", fss->surfdataPath); + + BLI_path_abs(targetDir, G.main->name); + BLI_path_abs(targetDirVel, G.main->name); + BLI_path_abs(previewDir, G.main->name); + + do { + BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); + BLI_strncpy(targetFileVel, targetDirVel, sizeof(targetFileVel)); + BLI_strncpy(previewFile, previewDir, sizeof(previewFile)); + + BLI_path_frame(targetFile, curFrame, 0); + BLI_path_frame(targetFileVel, curFrame, 0); + BLI_path_frame(previewFile, curFrame, 0); + + curFrame++; + + if((exists = BLI_exist(targetFile))) + { + BLI_delete(targetFile, 0, 0); + BLI_delete(targetFileVel, 0, 0); + BLI_delete(previewFile, 0, 0); + } + } while(exists); + + return; +} + static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) { Scene *scene= CTX_data_scene(C); @@ -878,6 +917,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) // reset last valid frame domainSettings->lastgoodframe = -1; + + /* delete old baked files */ + fluidsim_delete_until_lastframe(domainSettings); /* rough check of settings... */ if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { @@ -1018,6 +1060,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP; else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP; fsset->domainobsPartslip = domainSettings->partSlipValue; + + /* use domainobsType also for surface generation flag (bit: >=64) */ + if(domainSettings->typeFlags & OB_FSSG_NOOBS) + fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS; + else + fsset->mFsSurfGenSetting = 0; // "normal" mode + fsset->generateVertexVectors = (domainSettings->domainNovecgen==0); // init blender domain transform matrix diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 6191ec9c035..d4de1386871 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -302,6 +302,9 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) BLI_timestr(rs->lastframetime, info_time_str); spos+= sprintf(spos, "Time:%s ", info_time_str); + if(rs->curfsa) + spos+= sprintf(spos, "| Full Sample %d ", rs->curfsa); + if(rs->infostr && rs->infostr[0]) spos+= sprintf(spos, "| %s ", rs->infostr); diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index bf5df87610c..905fed4f30b 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -83,11 +83,13 @@ typedef struct ConsoleDrawContext { int console_width; int winx; int ymin, ymax; +#if 0 /* used by textview, may use later */ int *xy; // [2] int *sel; // [2] int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. int *mval; // [2] int draw; +#endif } ConsoleDrawContext; void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index adce540cee4..0210b0dd78d 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -662,7 +662,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char block= uiLayoutGetBlock(layout); - imaptr= RNA_property_pointer_get(ptr, prop); ima= imaptr.data; iuser= userptr->data; @@ -719,21 +718,17 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } } else { - row= uiLayoutRow(layout, 0); - uiItemR(row, &imaptr, "source", 0, NULL, ICON_NONE); + uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if(ima->source != IMA_SRC_GENERATED) { row= uiLayoutRow(layout, 1); - split = uiLayoutSplit(row, 0.0, 0); if (ima->packedfile) - uiItemO(split, "", ICON_PACKAGE, "image.unpack"); + uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else - uiItemO(split, "", ICON_UGLYPACKAGE, "image.pack"); + uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - split = uiLayoutSplit(row, 0.0, 0); - row= uiLayoutRow(split, 1); + row= uiLayoutRow(row, 0); uiLayoutSetEnabled(row, ima->packedfile==NULL); - uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } @@ -771,11 +766,10 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col= uiLayoutColumn(split, 0); uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); row= uiLayoutRow(col, 0); - uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); - - col= uiLayoutColumn(split, 0); - uiItemR(col, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); + uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + + uiItemR(split, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); } } @@ -787,10 +781,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col= uiLayoutColumn(split, 0); sprintf(str, "(%d) Frames", iuser->framenr); - row= uiLayoutRow(col, 1); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); if(ima->anim) { - block= uiLayoutGetBlock(row); + block= uiLayoutGetBlock(col); but= uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X*2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence."); uiButSetFunc(but, set_frames_cb, ima, iuser); } @@ -810,8 +803,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); - col= uiLayoutColumn(split, 0); - uiItemR(col, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index bce492f5a04..019ce2a714a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3786,6 +3786,8 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(layout, 1); uiItemR(row, ptr, "min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "max", 0, NULL, ICON_NONE); + + uiItemR(layout, ptr, "damping", 0, NULL, ICON_NONE); } static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext *C) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 0c9f12966ef..5f8ab0dded5 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -288,7 +288,7 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); layout= uiBlockLayout(node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, - node->locx+NODE_DYS, dy, node->butr.xmax, 20, U.uistyles.first); + node->locx+NODE_DYS, dy, node->butr.xmax, NODE_DY, U.uistyles.first); node->typeinfo->uifunc(layout, (bContext *)C, &ptr); uiBlockEndAlign(node->block); @@ -392,6 +392,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode bNode *node; bNodeSocket *sock, *gsock; rctf *rect= &gnode->totr; + float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; int counter; int dy; @@ -430,7 +431,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->inputs)-1); for(gsock=ngroup->inputs.first, sock=gnode->inputs.first; gsock; gsock=gsock->next, sock=sock->next) { gsock->locx = rect->xmin; - sock->locx = rect->xmin - NODE_GROUP_FRAME; + sock->locx = rect->xmin - node_group_frame; sock->locy = gsock->locy = dy; /* prevent long socket lists from growing out of the group box */ @@ -446,7 +447,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->outputs)-1); for(gsock=ngroup->outputs.first, sock=gnode->outputs.first; gsock; gsock=gsock->next, sock=sock->next) { gsock->locx = rect->xmax; - sock->locx = rect->xmax + NODE_GROUP_FRAME; + sock->locx = rect->xmax + node_group_frame; sock->locy = gsock->locy = dy - NODE_DYS; /* prevent long socket lists from growing out of the group box */ @@ -654,7 +655,7 @@ static uiBlock *socket_vector_menu(bContext *C, ARegion *ar, void *args_v) block= uiBeginBlock(C, ar, "socket menu", 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, 20, U.uistyles.first), 0); + layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, U.uistyles.first), 0); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -675,7 +676,7 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c switch (sock->type) { case SOCK_VALUE: bt=uiDefButR(block, NUM, B_NODE_EXEC, name, - x, y+1, width, 17, + x, y+1, width, NODE_DY-2, &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); if (cb) uiButSetFunc(bt, cb, arg1, arg2); @@ -693,7 +694,7 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c args->arg2 = arg2; uiDefBlockButN(block, socket_vector_menu, args, name, - x, y+1, width, 17, + x, y+1, width, NODE_DY-2, ""); break; @@ -701,14 +702,14 @@ static void node_draw_socket_button(bNodeTree *ntree, bNodeSocket *sock, const c labelw= width - 40; bt=uiDefButR(block, COL, B_NODE_EXEC, "", - x, y+2, (labelw>0 ? 40 : width), 15, + x, y+2, (labelw>0 ? 40 : width), NODE_DY-2, &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); if (cb) uiButSetFunc(bt, cb, arg1, arg2); if (name[0]!='\0' && labelw>0) uiDefBut(block, LABEL, 0, name, - x + 40, y+2, labelw, 15, + x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, ""); break; } @@ -719,6 +720,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN bNodeSocket *sock; rctf *rct= &node->totr; float iconofs; + float socket_size= NODE_SOCKSIZE*U.dpi/72; + float iconbutw= 0.8f*UI_UNIT_X; int color_id= node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; @@ -761,32 +764,32 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN icon_id= ICON_MATERIAL; else icon_id= ICON_MATERIAL_DATA; - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, icon_id, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } if(node->type == NODE_GROUP) { - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, ICON_NODETREE, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } if(node->typeinfo->flag & NODE_OPTIONS) { - iconofs-=15.0f; + iconofs-=iconbutw; uiDefIconBut(node->block, LABEL, B_REDR, ICON_BUTS, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } { /* always hide/reveal unused sockets */ int shade; - iconofs-=15.0f; + iconofs-=iconbutw; // XXX re-enable /*if(node_has_hidden_sockets(node)) shade= -40; else*/ shade= -90; uiDefIconBut(node->block, LABEL, B_REDR, ICON_PLUS, iconofs, rct->ymax-NODE_DY, - UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } /* title */ @@ -851,7 +854,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* socket inputs, buttons */ for(sock= node->inputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); if(node->block && sock->link==NULL) { node_draw_socket_button(ntree, sock, sock->name, node->block, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY, node_sync_cb, snode, node); @@ -869,7 +872,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN float slen; int ofs= 0; - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); UI_ThemeColor(TH_TEXT); slen= snode->aspect*UI_GetStringWidth(sock->name); @@ -904,6 +907,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b rctf *rct= &node->totr; float dx, centy= 0.5f*(rct->ymax+rct->ymin); float hiddenrad= 0.5f*(rct->ymax-rct->ymin); + float socket_size= NODE_SOCKSIZE*U.dpi/72; int color_id= node_get_colorid(node); char showname[128]; /* 128 is used below */ @@ -978,12 +982,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* sockets */ for(sock= node->inputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); } for(sock= node->outputs.first; sock; sock= sock->next) { if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - socket_circle_draw(sock, NODE_SOCKSIZE); + socket_circle_draw(sock, socket_size); } uiEndBlock(C, node->block); @@ -1043,17 +1047,30 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN { bNodeTree *ngroup= (bNodeTree *)gnode->id; bNodeSocket *sock; - rctf rect= gnode->totr; - int index; uiLayout *layout; PointerRNA ptr; uiBut *bt; + rctf rect= gnode->totr; + float socket_size= NODE_SOCKSIZE*U.dpi/72; + float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; + float group_header= 26*U.dpi/72; + float arrowbutw= 0.8f*UI_UNIT_X; + /* layout stuff for buttons on group left frame */ + float col1= 6, colw1= 0.6f*node_group_frame; + float col2= col1 + colw1+6; + float col3= node_group_frame - arrowbutw - 6; + /* layout stuff for buttons on group right frame */ + float cor1= 6; + float cor2= cor1 + arrowbutw + 6; + float cor3= cor2 + arrowbutw + 6, corw3= node_group_frame - cor3-6; + + int index; /* backdrop header */ glEnable(GL_BLEND); uiSetRoundBox(3); UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); - uiDrawBox(GL_POLYGON, rect.xmin-NODE_GROUP_FRAME, rect.ymax, rect.xmax+NODE_GROUP_FRAME, rect.ymax+26, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymax, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); /* backdrop body */ UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); @@ -1063,12 +1080,12 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* input column */ UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); uiSetRoundBox(8); - uiDrawBox(GL_POLYGON, rect.xmin-NODE_GROUP_FRAME, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD); /* output column */ UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); uiSetRoundBox(4); - uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+NODE_GROUP_FRAME, rect.ymax, BASIS_RAD); + uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+node_group_frame, rect.ymax, BASIS_RAD); /* input column separator */ glColor4ub(200, 200, 200, 140); @@ -1088,15 +1105,15 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiSetRoundBox(15); glColor4ub(200, 200, 200, 140); glEnable( GL_LINE_SMOOTH ); - uiDrawBox(GL_LINE_LOOP, rect.xmin-NODE_GROUP_FRAME, rect.ymin, rect.xmax+NODE_GROUP_FRAME, rect.ymax+26, BASIS_RAD); + uiDrawBox(GL_LINE_LOOP, rect.xmin-node_group_frame, rect.ymin, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); glDisable( GL_LINE_SMOOTH ); glDisable(GL_BLEND); /* backdrop title */ UI_ThemeColor(TH_TEXT_HI); - layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+23), - MIN2((int)(rect.xmax - rect.xmin-18.0f), 140), 20, U.uistyles.first); + layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header), + MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, U.uistyles.first); RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL); uiBlockLayoutResolve(gnode->block, NULL, NULL); @@ -1106,31 +1123,33 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* group sockets */ for(sock=ngroup->inputs.first, index=0; sock; sock=sock->next, ++index) { - socket_circle_draw(sock, NODE_SOCKSIZE); + float locx= sock->locx - node_group_frame; + + socket_circle_draw(sock, socket_size); /* small hack to use socket_circle_draw function with offset */ - sock->locx -= NODE_GROUP_FRAME; - socket_circle_draw(sock, NODE_SOCKSIZE); - sock->locx += NODE_GROUP_FRAME; + sock->locx -= node_group_frame; + socket_circle_draw(sock, socket_size); + sock->locx += node_group_frame; bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx-114, sock->locy+1, 72, NODE_DY, + locx+col1, sock->locy+1, colw1, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); node_draw_socket_button(ngroup, sock, "", gnode->block, - sock->locx-114, sock->locy-NODE_DY, 72, + locx+col1, sock->locy-NODE_DY, colw1, NULL, NULL, NULL); uiBlockSetDirection(gnode->block, UI_TOP); uiBlockBeginAlign(gnode->block); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP, - sock->locx-40, sock->locy, 16, 16, ""); + locx+col2, sock->locy, arrowbutw, arrowbutw, ""); if (!sock->prev) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_IN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN, - sock->locx-40, sock->locy-16, 16, 16, ""); + locx+col2, sock->locy-arrowbutw, arrowbutw, arrowbutw, ""); if (!sock->next) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); @@ -1140,22 +1159,24 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetEmboss(gnode->block, UI_EMBOSSN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X, - sock->locx-22, sock->locy-8, 16, 16, ""); + locx+col3, sock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_IN); uiBlockSetEmboss(gnode->block, UI_EMBOSS); } for(sock=ngroup->outputs.first, index=0; sock; sock=sock->next, ++index) { - socket_circle_draw(sock, NODE_SOCKSIZE); + float locx= sock->locx; + + socket_circle_draw(sock, socket_size); /* small hack to use socket_circle_draw function with offset */ - sock->locx += NODE_GROUP_FRAME; - socket_circle_draw(sock, NODE_SOCKSIZE); - sock->locx -= NODE_GROUP_FRAME; + sock->locx += node_group_frame; + socket_circle_draw(sock, socket_size); + sock->locx -= node_group_frame; uiBlockSetEmboss(gnode->block, UI_EMBOSSN); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X, - sock->locx+6, sock->locy-8, 16, 16, ""); + locx+col1, sock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_OUT); uiBlockSetEmboss(gnode->block, UI_EMBOSS); @@ -1163,13 +1184,13 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetDirection(gnode->block, UI_TOP); uiBlockBeginAlign(gnode->block); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP, - sock->locx+24, sock->locy, 16, 16, ""); + locx+cor2, sock->locy, arrowbutw, arrowbutw, ""); if (!sock->prev) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", SOCK_OUT); bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN, - sock->locx+24, sock->locy-16, 16, 16, ""); + locx+cor2, sock->locy-arrowbutw, arrowbutw, arrowbutw, ""); if (!sock->next) uiButSetFlag(bt, UI_BUT_DISABLED); RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); @@ -1179,17 +1200,17 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (sock->link) { bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx+42, sock->locy-NODE_DYS+1, 72, NODE_DY, + locx+cor3, sock->locy-NODE_DYS+1, corw3, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); } else { bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx+42, sock->locy+1, 72, NODE_DY, + locx+cor3, sock->locy+1, corw3, NODE_DY, sock->name, 0, 31, 0, 0, ""); uiButSetFunc(bt, group_verify_cb, snode, ngroup); - node_draw_socket_button(ngroup, sock, "", gnode->block, sock->locx+42, sock->locy-NODE_DY, 72, NULL, NULL, NULL); + node_draw_socket_button(ngroup, sock, "", gnode->block, locx+cor3, sock->locy-NODE_DY, corw3, NULL, NULL, NULL); } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 99f2ea99efc..46c66c55d51 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1332,7 +1332,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) } else { node->width= nsw->oldwidth + mx - nsw->mxstart; - CLAMP(node->width, node->typeinfo->minwidth, node->typeinfo->maxwidth); + CLAMP(node->width, UI_DPI_FAC*node->typeinfo->minwidth, UI_DPI_FAC*node->typeinfo->maxwidth); } } @@ -1366,10 +1366,17 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); - /* rect we're interested in is just the bottom right corner */ totr= node->totr; - totr.xmin= totr.xmax-10.0f; - totr.ymax= totr.ymin+10.0f; + + if(node->flag & NODE_HIDDEN) { + /* right part of node */ + totr.xmin= node->totr.xmax-20.0f; + } + else { + /* bottom right corner */ + totr.xmin= totr.xmax-10.0f; + totr.ymax= totr.ymin+10.0f; + } if(BLI_in_rctf(&totr, snode->mx, snode->my)) { NodeSizeWidget *nsw= MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index fcf1c182600..a1c0f5535fe 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -152,8 +152,8 @@ extern const char *node_context_dir[]; // XXX from BSE_node.h #define HIDDEN_RAD 15.0f #define BASIS_RAD 8.0f -#define NODE_DYS 10 -#define NODE_DY 20 +#define NODE_DYS (U.widget_unit/2) +#define NODE_DY U.widget_unit #define NODE_SOCKSIZE 5 // XXX button events (butspace) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 6900271deea..c8965c4d3db 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -124,7 +124,7 @@ typedef struct TransSeq { int startstill, endstill; int startdisp, enddisp; int startofs, endofs; - int final_left, final_right; + /* int final_left, final_right; */ /* UNUSED */ int len; } TransSeq; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 35edd961b1e..dcdb7954b16 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -215,7 +215,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - return (scene->gm.matmode == GAME_MAT_GLSL) && (dt >= OB_SHADED); + return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); } static int check_material_alpha(Base *base, Mesh *me, int glsl) @@ -2584,7 +2584,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob)); int draw_wire = 0; int /* totvert,*/ totedge, totface; - DispList *dl; DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); if(!dm) @@ -2718,10 +2717,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if(dt==OB_SHADED) { - int do_draw= 1; /* to resolve all G.f settings below... */ - if(ob==OBACT) { - do_draw= 0; if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ GPU_enable_material(0, NULL); @@ -2750,38 +2746,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material); } } - else do_draw= 1; - } - if(do_draw) { - dl = ob->disp.first; - if (!dl || !dl->col1) { - /* release and reload derivedmesh because it might be freed in - shadeDispList due to a different datamask */ - dm->release(dm); - shadeDispList(scene, base); - dl = find_displist(&ob->disp, DL_VERTCOL); - dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); - } - - if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire) { - draw_mesh_object_outline(v3d, ob, dm); - } - - /* False for dupliframe objects */ - if (dl) { - unsigned int *obCol1 = dl->col1; - unsigned int *obCol2 = dl->col2; - - dm->drawFacesColored(dm, me->flag&ME_TWOSIDED, (unsigned char*) obCol1, (unsigned char*) obCol2); - } - - if(base->flag & SELECT) { - UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT); - } else { - UI_ThemeColor(TH_WIRE); - } - if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) - dm->drawLooseEdges(dm); } } @@ -3139,57 +3103,6 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) glFrontFace(GL_CCW); } -static void drawDispListshaded(ListBase *lb, Object *ob) -{ - DispList *dl, *dlob; - unsigned int *cdata; - - if(lb==NULL) return; - - glShadeModel(GL_SMOOTH); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - - dl= lb->first; - dlob= ob->disp.first; - while(dl && dlob) { - - cdata= dlob->col1; - if(cdata==NULL) break; - - switch(dl->type) { - case DL_SURF: - if(dl->index) { - glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata); - glDrawElements(GL_QUADS, 4*dl->totindex, GL_UNSIGNED_INT, dl->index); - } - break; - - case DL_INDEX3: - - glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata); - glDrawElements(GL_TRIANGLES, 3*dl->parts, GL_UNSIGNED_INT, dl->index); - break; - - case DL_INDEX4: - - glVertexPointer(3, GL_FLOAT, 0, dl->verts); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, cdata); - glDrawElements(GL_QUADS, 4*dl->parts, GL_UNSIGNED_INT, dl->index); - break; - } - - dl= dl->next; - dlob= dlob->next; - } - - glShadeModel(GL_FLAT); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - static void drawCurveDMWired(Object *ob) { DerivedMesh *dm = ob->derivedFinal; @@ -3270,10 +3183,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 1); GPU_end_object_materials(); } - else if(dt == OB_SHADED) { - if(ob->disp.first==NULL) shadeDispList(scene, base); - drawDispListshaded(lb, ob); - } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); @@ -3312,10 +3221,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 1); GPU_end_object_materials(); } - else if(dt==OB_SHADED) { - if(ob->disp.first==NULL) shadeDispList(scene, base); - drawDispListshaded(lb, ob); - } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); @@ -3341,11 +3246,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 1); GPU_end_object_materials(); } - else if(dt == OB_SHADED) { - dl= lb->first; - if(dl && dl->col1==NULL) shadeDispList(scene, base); - drawDispListshaded(lb, ob); - } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); @@ -6311,7 +6211,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } - if(dtflag2 & V3D_RENDER_OVERRIDE)==0) { + if(dt<=OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { if((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) { float imat[4][4], vec[3]= {0.0f, 0.0f, 0.0f}; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 573951da4ca..d316ef50679 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2074,10 +2074,6 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { CustomDataMask mask= 0; - if(v3d->drawtype == OB_SHADED) { - /* this includes normals for mesh_create_shadedColors */ - mask |= CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_NORMAL | CD_MASK_ORCO; - } if((v3d->drawtype == OB_TEXTURE) || ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 68aa27a7b62..bf14b6e99ec 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5077,10 +5077,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t) #if 0 // TRANSFORM_FIX_ME if(resetslowpar) reset_slowparents(); - - /* note; should actually only be done for all objects when a lamp is moved... (ton) */ - if(t->spacetype==SPACE_VIEW3D && G.vd->drawtype == OB_SHADED) - reshadeall_displist(); #endif } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8699eb1cc2d..20a26d8c58d 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -675,8 +675,9 @@ void recalcData(TransInfo *t) EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh; /* mirror modifier clipping? */ if(t->state != TRANS_CANCEL) { - clipMirrorModifier(t, t->obedit); + /* apply clipping after so we never project past the clip plane [#25423] */ applyProject(t); + clipMirrorModifier(t, t->obedit); } if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) editmesh_apply_to_mirror(t); @@ -839,9 +840,6 @@ void recalcData(TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } - - if(((View3D*)t->view)->drawtype == OB_SHADED) - reshadeall_displist(t->scene); } } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 705fb83264c..3dd7514429e 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -106,10 +106,6 @@ void ED_editors_exit(bContext *C) if(sce->obedit) { Object *ob= sce->obedit; - /* global in meshtools... */ - mesh_octree_table(NULL, NULL, NULL, 'e'); - mesh_mirrtopo_table(NULL, 'e'); - if(ob) { if(ob->type==OB_MESH) { Mesh *me= ob->data; @@ -122,26 +118,13 @@ void ED_editors_exit(bContext *C) else if(ob->type==OB_ARMATURE) { ED_armature_edit_free(ob); } - else if(ob->type==OB_FONT) { - // free_editText(); - } - // else if(ob->type==OB_MBALL) - // BLI_freelistN(&editelems); - // free_editLatt(); - // free_posebuf(); // XXX this is still a global... - } - } - else if(sce->basact && sce->basact->object) { - Object *ob= sce->basact->object; - - /* if weight-painting is on, free mesh octree data */ - if(ob->mode & OB_MODE_WEIGHT_PAINT) { - mesh_octree_table(NULL, NULL, NULL, 'e'); - mesh_mirrtopo_table(NULL, 'e'); } } } - + + /* global in meshtools... */ + mesh_octree_table(NULL, NULL, NULL, 'e'); + mesh_mirrtopo_table(NULL, 'e'); } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 24a868891de..8a6ec7f75db 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -156,11 +156,11 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) int do_glob_undo= 0; if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) + if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname)) do_glob_undo= 1; } else if(obact && obact->mode & OB_MODE_SCULPT) { - if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname) && undoname) + if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname)) do_glob_undo= 1; } else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 18a6f1ba73d..d75b8db2c4e 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -112,6 +112,11 @@ void GPU_set_mipmap(int mipmap); void GPU_set_linear_mipmap(int linear); void GPU_paint_set_mipmap(int mipmap); +/* Anisotropic filtering settings + * - these will free textures on changes */ +void GPU_set_anisotropic(float value); +float GPU_get_anisotropic(void); + /* Image updates and free * - these deal with images bound as opengl textures */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7dfbc52819e..87d25ac850a 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -246,8 +246,9 @@ static struct GPUTextureState { int domipmap, linearmipmap; int alphamode; + float anisotropic; MTFace *lasttface; -} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, NULL}; +} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL}; /* Mipmap settings */ @@ -292,6 +293,26 @@ static GLenum gpu_get_mipmap_filter(int mag) } } +/* Anisotropic filtering settings */ +void GPU_set_anisotropic(float value) +{ + if (GTS.anisotropic != value) + { + GPU_free_images(); + + /* Clamp value to the maximum value the graphics card supports */ + if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) + value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; + + GTS.anisotropic = value; + } +} + +float GPU_get_anisotropic() +{ + return GTS.anisotropic; +} + /* Set OpenGL state for an MTFace */ static void gpu_make_repbind(Image *ima) @@ -559,6 +580,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int ima->tpageflag |= IMA_MIPMAP_COMPLETE; } + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); /* set to modulate with vertex color */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 5d61452e149..e9592fdc164 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -442,8 +442,9 @@ void IMB_freezbuffloatImBuf(struct ImBuf *ibuf); * * @attention Defined in rectop.c */ -void IMB_rectfill(struct ImBuf *drect, float col[4]); +void IMB_rectfill(struct ImBuf *drect, const float col[4]); void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); +void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt index c1140bc59a9..9ca4dff5bc8 100644 --- a/source/blender/imbuf/intern/openexr/CMakeLists.txt +++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt @@ -44,7 +44,7 @@ set(SRC ) if(WITH_IMAGE_OPENEXR) - list(APPEND INC_SYS ${OPENEXR_INC}) + list(APPEND INC_SYS ${OPENEXR_INCLUDE_DIRS}) add_definitions(-DWITH_OPENEXR) endif() diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 9fd6cd1c3fa..7b528ed9624 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -76,18 +76,18 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include #include #else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif using namespace Imf; diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 44af7ffdb3f..844478e03cb 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -450,7 +450,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, /* fill */ -void IMB_rectfill(struct ImBuf *drect, float col[4]) +void IMB_rectfill(struct ImBuf *drect, const float col[4]) { int num; @@ -561,3 +561,18 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i if (!ibuf) return; buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, x1, y1, x2, y2); } + + +void IMB_rectfill_alpha(ImBuf *ibuf, const float value) +{ + int i; + if (ibuf->rect_float) { + float *fbuf= ibuf->rect_float + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf+= 4) { *fbuf = value; } + } + else { + const unsigned char cvalue= value * 255; + unsigned char *cbuf= ((unsigned char *)ibuf->rect) + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf+= 4) { *cbuf = cvalue; } + } +} diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 683d8142cc9..887a0300ee2 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -133,7 +133,7 @@ typedef struct bIpoActuator { typedef struct bCameraActuator { struct Object *ob; float height, min, max; - float pad; + float damping; short pad1, axis; float pad2; } bCameraActuator ; diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h index 6f4c16cb7f3..578bf8dd415 100644 --- a/source/blender/makesdna/DNA_object_fluidsim.h +++ b/source/blender/makesdna/DNA_object_fluidsim.h @@ -69,7 +69,7 @@ typedef struct FluidsimSettings { short viscosityMode; short viscosityExponent; /* gravity strength */ - float gravx,gravy,gravz; + float grav[3]; /* anim start end time (in seconds) */ float animStart, animEnd; /* bake start end time (in blender frames) */ @@ -161,6 +161,9 @@ typedef struct FluidsimSettings { #define OB_FSBND_FREESLIP (1<<(OB_TYPEFLAG_START+4)) #define OB_FSINFLOW_LOCALCOORD (1<<(OB_TYPEFLAG_START+5)) +/* surface generation flag (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM") */ +#define OB_FSSG_NOOBS (1<<(OB_TYPEFLAG_START+6)) + // guiDisplayMode particle flags #define OB_FSDOM_GEOM 1 #define OB_FSDOM_PREVIEW 2 diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 54a885a0860..dfc7d42793d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -250,12 +250,11 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; - int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + unsigned int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + unsigned int 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 */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ - int pad2; - ListBase gpulamp; /* runtime, for lamps only */ ListBase pc_ids; ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */ @@ -291,10 +290,6 @@ typedef struct DupliObject { float orco[3], uv[2]; } DupliObject; -/* this work object is defined in object.c */ -extern Object workob; - - /* **************** OBJECT ********************* */ /* used many places... should be specialized */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index c3dcd0256e9..bbfd95614b9 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -258,19 +258,12 @@ typedef struct RenderData { */ short yparts; - short winpos, planes, imtype, subimtype; - - /** Mode bits: */ - /* 0: Enable backbuffering for images */ - short bufflag; - short quality; + short planes, imtype, subimtype, quality; /** * Render to image editor, fullscreen or to new window. */ short displaymode; - - short rpad1, rpad2; /** * Flags for render settings. Use bit-masking to access the settings. @@ -327,11 +320,7 @@ typedef struct RenderData { /** * Adjustment factors for the aspect ratio in the x direction, was a short in 2.45 */ - float xasp; - /** - * Adjustment factors for the aspect ratio in the x direction, was a short in 2.45 - */ - float yasp; + float xasp, yasp; float frs_sec_base; @@ -354,7 +343,7 @@ typedef struct RenderData { short bake_normal_space, bake_quad_split; float bake_maxdist, bake_biasdist, bake_pad; - /* paths to backbufffer, output */ + /* path to render output */ char pic[240]; /* stamps flags. */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 907710ae4cd..ae57cf3f80b 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -375,7 +375,7 @@ typedef struct UserDef { short scrcastwait; /* milliseconds between screencast snapshots */ short widget_unit; /* defaults to 20 for 72 DPI setting */ - short pad[3]; + short anisotropic_filter; char versemaster[160]; char verseuser[160]; @@ -385,7 +385,6 @@ typedef struct UserDef { short autokey_flag; /* flags for autokeying */ short text_render, pad9; /*options for text rendering*/ - float pad10; struct ColorBand coba_weight; /* from texture.h */ diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index c7cf511d5c7..cddba59f979 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -922,6 +922,13 @@ static void rna_def_camera_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Max", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "damping"); + RNA_def_property_range(prop, 0, 10.0); + RNA_def_property_ui_range(prop, 0, 5.0, 1, 2); + RNA_def_property_ui_text(prop, "Damping", "Specify the strength of the constraint that drive the camera behind the target"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + /* x/y */ prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 1705e2e5376..37912f810fc 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -133,7 +133,7 @@ void RNA_def_camera(BlenderRNA *brna) prop= RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ortho_scale"); - RNA_def_property_range(prop, 0.01f, 1000.0f); + RNA_def_property_range(prop, 0.01f, 4000.0f); RNA_def_property_ui_text(prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 92c762098c7..db5409bf7ef 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -87,6 +87,20 @@ static void rna_Controller_type_set(struct PointerRNA *ptr, int value) } } +static void rna_Controller_mode_set(struct PointerRNA *ptr, int value) +{ + bController *cont= (bController *)ptr->data; + bPythonCont *pycon= (bPythonCont *)cont->data; + + // if mode changed and previous mode were Script + if (value != pycon->mode && pycon->mode == CONT_PY_SCRIPT) + { + // clear script to avoid it to get linked with the controller + pycon->text = NULL; + } + pycon->mode = value; +} + static int rna_Controller_state_number_get(struct PointerRNA *ptr) { bController *cont= (bController *)ptr->data; @@ -222,6 +236,7 @@ void RNA_def_controller(BlenderRNA *brna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, python_controller_modes); + RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_mode_set", NULL); RNA_def_property_ui_text(prop, "Execution Method", "Python script type (textblock or module - faster)"); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 7c93ae4168b..1ba2e32502f 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -312,7 +312,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) /* advanced settings */ prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); - RNA_def_property_float_sdna(prop, NULL, "gravx"); + RNA_def_property_float_sdna(prop, NULL, "grav"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -1000.1, 1000.1); RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction"); @@ -384,6 +384,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Generate Speed Vectors", "Generate speed vectors for vector blur"); + /* no collision object surface */ + prop= RNA_def_property(srna, "surface_noobs", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSSG_NOOBS); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Hide fluid surface", ""); + /* particles */ prop= RNA_def_property(srna, "tracer_particles", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index a5097cc8b41..5d71d204a72 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -95,7 +95,7 @@ static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Add this object to a group"); /* object to add */ parm= RNA_def_pointer(func, "object", "Object", "", "Object to add."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); /* remove object */ func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 3a80207ba15..9e3a31ddb2e 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -135,6 +135,7 @@ static void rna_Texture_update(Main *bmain, Scene *scene, PointerRNA *ptr) DAG_id_tag_update(&tex->id, 0); WM_main_add_notifier(NC_TEXTURE, tex); + WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, NULL); } static void rna_Texture_voxeldata_update(Main *bmain, Scene *scene, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 14af5ed7a3f..cf371fbf9bc 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -117,6 +117,12 @@ static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr rna_userdef_update(bmain, scene, ptr); } +static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + GPU_set_anisotropic(U.anisotropic_filter); + rna_userdef_update(bmain, scene, ptr); +} + static void rna_userdef_gl_texture_limit_update(Main *bmain, Scene *scene, PointerRNA *ptr) { GPU_free_images(); @@ -2346,6 +2352,14 @@ static void rna_def_userdef_system(BlenderRNA *brna) {128, "CLAMP_128", 0, "128", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem anisotropic_items[] ={ + {1, "FILTER_0", 0, "Off", ""}, + {2, "FILTER_2", 0, "2x", ""}, + {4, "FILTER_4", 0, "4x", ""}, + {8, "FILTER_8", 0, "8x", ""}, + {16, "FILTER_16", 0, "16x", ""}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem audio_mixing_samples_items[] = { {256, "SAMPLES_256", 0, "256", "Set audio mixing buffer size to 256 samples"}, {512, "SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, @@ -2568,6 +2582,13 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop= RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_AA); RNA_def_property_ui_text(prop, "Anti-aliasing", "Use anti-aliasing for the 3D view (may impact redraw performance)"); + + prop= RNA_def_property(srna, "anisotropic_filter", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "anisotropic_filter"); + RNA_def_property_enum_items(prop, anisotropic_items); + RNA_def_property_enum_default(prop, 1); + RNA_def_property_ui_text(prop, "Anisotropic Filter", "The quality of the anisotropic filtering (values greater than 1.0 enable anisotropic filtering)"); + RNA_def_property_update(prop, 0, "rna_userdef_anisotropic_update"); prop= RNA_def_property(srna, "gl_texture_limit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "glreslimit"); diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index f1bc0d33fd8..10bcbee6661 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -779,11 +779,11 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, ParticleSettings *part=psmd->psys->part; ParticleSimulationData sim= {NULL}; ParticleData *pa=NULL, *pars=psmd->psys->particles; - ParticleKey state; + ParticleKey state, birth; EdgeHash *vertpahash; EdgeHashIterator *ehi; float *vertco= NULL, imat[4][4]; - float loc0[3], nor[3]; + float rot[4]; float cfra; /* float timestep; */ int *facepa=emd->facepa; @@ -814,7 +814,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, for (i=0; itime) + if(facepa[i]==totpart || cfra < (pars+facepa[i])->time) mindex = totvert+totpart; else mindex = totvert+facepa[i]; @@ -868,26 +868,26 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* get particle */ pa= pars+i; - /* get particle state */ - psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,NULL,NULL,NULL,NULL); - mul_m4_v3(ob->obmat,loc0); + psys_get_birth_coordinates(&sim, pa, &birth, 0, 0); state.time=cfra; psys_get_particle_state(&sim, i, &state, 1); vertco=CDDM_get_vert(explode,v)->co; - mul_m4_v3(ob->obmat,vertco); - VECSUB(vertco,vertco,loc0); + sub_v3_v3(vertco, birth.co); /* apply rotation, size & location */ - mul_qt_v3(state.rot,vertco); + sub_qt_qtqt(rot, state.rot, birth.rot); + mul_qt_v3(rot, vertco); + if(emd->flag & eExplodeFlag_PaSize) mul_v3_fl(vertco,pa->size); - VECADD(vertco,vertco,state.co); - mul_m4_v3(imat,vertco); + add_v3_v3(vertco, state.co); + + mul_m4_v3(imat, vertco); } } BLI_edgehashIterator_free(ehi); @@ -911,7 +911,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, orig_v4 = source.v4; - if(facepa[i]!=totpart && cfra <= pa->time) + if(facepa[i]!=totpart && cfra < pa->time) mindex = totvert+totpart; else mindex = totvert+facepa[i]; diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 61345427d1c..277f0852f90 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -90,10 +90,10 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->viscosityValue = 1.0; fss->viscosityExponent = 6; - // dg TODO: change this to [] - fss->gravx = 0.0; - fss->gravy = 0.0; - fss->gravz = -9.81; + fss->grav[0] = 0.0; + fss->grav[1] = 0.0; + fss->grav[2] = -9.81; + fss->animStart = 0.0; fss->animEnd = 4.0; fss->gstar = 0.005; // used as normgstar @@ -111,7 +111,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) // no bounding box needed // todo - reuse default init from elbeem! - fss->typeFlags = OB_FSBND_PARTSLIP; + fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS; fss->domainNovecgen = 0; fss->volumeInitType = 1; // volume fss->partSlipValue = 0.2; diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index b36d6848533..94442d96367 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -45,6 +45,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "BKE_action.h" /* get_pose_channel */ #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" @@ -102,7 +103,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm= derivedData, *result= NULL; GHash *vertHash=NULL, *edgeHash, *faceHash; GHashIterator *hashIter; - MDeformVert *dvert= NULL; + MDeformVert *dvert= NULL, *dv; int numFaces=0, numEdges=0, numVerts=0; int maxVerts, maxEdges, maxFaces; int i; @@ -130,50 +131,46 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* if mode is to use selected armature bones, aggregate the bone groups */ if (mmd->mode == MOD_MASK_MODE_ARM) /* --- using selected bones --- */ { - GHash *vgroupHash, *boneHash; + GHash *vgroupHash; Object *oba= mmd->ob_arm; bPoseChannel *pchan; bDeformGroup *def; + char *bone_select_array; + int bone_select_tot= 0; /* check that there is armature object with bones to use, otherwise return original mesh */ - if (ELEM(NULL, mmd->ob_arm, mmd->ob_arm->pose)) - return derivedData; - + if (ELEM3(NULL, mmd->ob_arm, mmd->ob_arm->pose, ob->defbase.first)) + return derivedData; + + bone_select_array= MEM_mallocN(BLI_countlist(&ob->defbase) * sizeof(char), "mask array"); + + for (i = 0, def = ob->defbase.first; def; def = def->next, i++) + { + if (((pchan= get_pose_channel(oba->pose, def->name)) && pchan->bone && (pchan->bone->flag & BONE_SELECTED))) + { + bone_select_array[i]= TRUE; + bone_select_tot++; + } + else { + bone_select_array[i]= FALSE; + } + } + /* hashes for finding mapping of: * - vgroups to indices -> vgroupHash (string, int) * - bones to vgroup indices -> boneHash (index of vgroup, dummy) */ vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); - boneHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask bone gh"); /* build mapping of names of vertex groups to indices */ for (i = 0, def = ob->defbase.first; def; def = def->next, i++) BLI_ghash_insert(vgroupHash, def->name, SET_INT_IN_POINTER(i)); - /* get selected-posechannel <-> vertexgroup index mapping */ - for (pchan= oba->pose->chanbase.first; pchan; pchan= pchan->next) - { - /* check if bone is selected */ - // TODO: include checks for visibility too? - // FIXME: the depsgraph needs extensions to make this work in realtime... - if ( (pchan->bone) && (pchan->bone->flag & BONE_SELECTED) ) - { - /* check if hash has group for this bone */ - if (BLI_ghash_haskey(vgroupHash, pchan->name)) - { - int defgrp_index= GET_INT_FROM_POINTER(BLI_ghash_lookup(vgroupHash, pchan->name)); - - /* add index to hash (store under key only) */ - BLI_ghash_insert(boneHash, SET_INT_IN_POINTER(defgrp_index), pchan); - } - } - } - /* if no bones selected, free hashes and return original mesh */ - if (BLI_ghash_size(boneHash) == 0) + if (bone_select_tot == 0) { BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); + MEM_freeN(bone_select_array); return derivedData; } @@ -183,7 +180,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (dvert == NULL) { BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); + MEM_freeN(bone_select_array); return derivedData; } @@ -192,28 +189,29 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); /* add vertices which exist in vertexgroups into vertHash for filtering */ - for (i = 0; i < maxVerts; i++) + for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - MDeformWeight *def_weight = NULL; + MDeformWeight *dw= dv->dw; int j; - - for (j= 0; j < dvert[i].totweight; j++) + + for (j= dv->totweight; j > 0; j--, dw++) { - if (BLI_ghash_haskey(boneHash, SET_INT_IN_POINTER(dvert[i].dw[j].def_nr))) + if (bone_select_array[dw->def_nr]) { - def_weight = &dvert[i].dw[j]; - break; + if(dw->weight != 0.0f) { + break; + } } } /* check if include vert in vertHash */ if (mmd->flag & MOD_MASK_INV) { /* if this vert is in the vgroup, don't include it in vertHash */ - if (def_weight) continue; + if (dw) continue; } else { /* if this vert isn't in the vgroup, don't include it in vertHash */ - if (!def_weight) continue; + if (!dw) continue; } /* add to ghash for verts (numVerts acts as counter for mapping) */ @@ -223,7 +221,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* free temp hashes */ BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); + MEM_freeN(bone_select_array); } else /* --- Using Nominated VertexGroup only --- */ { @@ -241,28 +239,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); /* add vertices which exist in vertexgroup into ghash for filtering */ - for (i = 0; i < maxVerts; i++) + for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - MDeformWeight *def_weight = NULL; - int j; - - for (j= 0; j < dvert[i].totweight; j++) - { - if (dvert[i].dw[j].def_nr == defgrp_index) - { - def_weight = &dvert[i].dw[j]; - break; - } - } + const int weight_set= defvert_find_weight(dv, defgrp_index) != 0.0f; /* check if include vert in vertHash */ if (mmd->flag & MOD_MASK_INV) { /* if this vert is in the vgroup, don't include it in vertHash */ - if (def_weight) continue; + if (weight_set) continue; } else { /* if this vert isn't in the vgroup, don't include it in vertHash */ - if (!def_weight) continue; + if (!weight_set) continue; } /* add to ghash for verts (numVerts acts as counter for mapping) */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 4fdf0fe9d60..1d04eb891d6 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -146,7 +146,7 @@ typedef struct RenderResult { typedef struct RenderStats { int cfra; int totface, totvert, totstrand, tothalo, totlamp, totpart; - short curfield, curblur, curpart, partsdone, convertdone; + short curfield, curblur, curpart, partsdone, convertdone, curfsa; double starttime, lastframetime; const char *infostr, *statstr; char scenename[32]; diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 958c19ab9ca..b6af781f4d4 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -193,6 +193,8 @@ typedef struct ShadeInput /* node shaders... */ struct Tex; struct MTex; +struct ImBuf; + /* this one uses nodes */ int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres); /* nodes disabled */ @@ -206,9 +208,8 @@ struct Render; struct Image; struct Object; -void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr); int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress); struct Image *RE_bake_shade_get_image(void); +void RE_bake_ibuf_filter(struct ImBuf *ibuf, unsigned char *mask, const int filter); #endif /* RE_SHADER_EXT_H */ - diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index c0b40b32587..19ae9f8c777 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -214,7 +214,7 @@ struct Render ListBase instancetable; int totinstance; - struct Image *backbuf, *bakebuf; + struct Image *bakebuf; struct GHash *orco_hash; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c1c2fb60abd..15fc9d38c01 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4665,7 +4665,6 @@ void RE_Database_Free(Render *re) re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0; re->i.convertdone= 0; - re->backbuf= NULL; re->bakebuf= NULL; if(re->scene) diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 1e40ab886ae..e2ab21ef877 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -149,7 +149,6 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->r.layers.first= envre->r.layers.last= NULL; envre->r.filtertype= 0; envre->r.xparts= envre->r.yparts= 2; - envre->r.bufflag= 0; envre->r.size= 100; envre->r.yasp= envre->r.xasp= 1; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 559bd759754..0f716cfa85f 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2076,35 +2076,6 @@ static void do_render_fields_3d(Render *re) re->display_draw(re->ddh, re->result, NULL); } -static void load_backbuffer(Render *re) -{ - if(re->r.alphamode == R_ADDSKY) { - ImBuf *ibuf; - char name[256]; - - BLI_path_abs(name, re->main->name); - BLI_path_frame(name, re->r.cfra, 0); - - if(re->backbuf) { - re->backbuf->id.us--; - if(re->backbuf->id.us<1) - BKE_image_signal(re->backbuf, NULL, IMA_SIGNAL_RELOAD); - } - - re->backbuf= BKE_add_image_file(name); - ibuf= BKE_image_get_ibuf(re->backbuf, NULL); - if(ibuf==NULL) { - // error() doesnt work with render window open - //error("No backbuf there!"); - printf("Error: No backbuf %s\n", name); - } - else { - if (re->r.mode & R_FIELDS) - image_de_interlace(re->backbuf, re->r.mode & R_ODDFIELD); - } - } -} - /* main render routine, no compositing */ static void do_render_fields_blur_3d(Render *re) { @@ -2115,10 +2086,6 @@ static void do_render_fields_blur_3d(Render *re) G.afbreek= 1; return; } - - /* backbuffer initialize */ - if(re->r.bufflag & 1) - load_backbuffer(re); /* now use renderdata and camera to set viewplane */ RE_SetCamera(re, camera); @@ -2213,6 +2180,24 @@ static void render_scene(Render *re, Scene *sce, int cfra) do_render_fields_blur_3d(resc); } +/* helper call to detect if this scene needs a render, or if there's a any render layer to render */ +static int composite_needs_render(Scene *sce, int this_scene) +{ + bNodeTree *ntree= sce->nodetree; + bNode *node; + + if(ntree==NULL) return 1; + if(sce->use_nodes==0) return 1; + if((sce->r.scemode & R_DOCOMP)==0) return 1; + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type==CMP_NODE_R_LAYERS) + if(this_scene==0 || node->id==NULL || node->id==&sce->id) + return 1; + } + return 0; +} + static void tag_scenes_for_render(Render *re) { bNode *node; @@ -2221,7 +2206,8 @@ static void tag_scenes_for_render(Render *re) for(sce= re->main->scene.first; sce; sce= sce->id.next) sce->id.flag &= ~LIB_DOIT; - re->scene->id.flag |= LIB_DOIT; + if(RE_GetCamera(re) && composite_needs_render(re->scene, 1)) + re->scene->id.flag |= LIB_DOIT; if(re->scene->nodetree==NULL) return; @@ -2268,24 +2254,6 @@ static void ntree_render_scenes(Render *re) set_scene_bg(re->main, re->scene); } -/* helper call to detect if theres a composite with render-result node */ -static int composite_needs_render(Scene *sce) -{ - bNodeTree *ntree= sce->nodetree; - bNode *node; - - if(ntree==NULL) return 1; - if(sce->use_nodes==0) return 1; - if((sce->r.scemode & R_DOCOMP)==0) return 1; - - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) - if(node->id==NULL || node->id==&sce->id) - return 1; - } - return 0; -} - /* bad call... need to think over proper method still */ static void render_composit_stats(void *UNUSED(arg), char *str) { @@ -2361,6 +2329,16 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) float *rectf, filt[3][3]; int sample; + /* interaction callbacks */ + if(ntree) { + ntree->stats_draw= render_composit_stats; + ntree->test_break= re->test_break; + ntree->progress= re->progress; + ntree->sdh= re->sdh; + ntree->tbh= re->tbh; + ntree->prh= re->prh; + } + /* filtmask needs it */ R= *re; @@ -2368,26 +2346,29 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) rectf= MEM_mapallocN(re->rectx*re->recty*sizeof(float)*4, "fullsample rgba"); for(sample=0; sampler.osa; sample++) { + Render *re1; RenderResult rres; int x, y, mask; - /* set all involved renders on the samplebuffers (first was done by render itself) */ + /* enable full sample print */ + R.i.curfsa= sample+1; + + /* set all involved renders on the samplebuffers (first was done by render itself, but needs tagged) */ /* also function below assumes this */ - if(sample) { - Render *re1; - tag_scenes_for_render(re); - for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { - if(re1->scene->id.flag & LIB_DOIT) { - if(re1->r.scemode & R_FULL_SAMPLE) { + tag_scenes_for_render(re); + for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { + if(re1->scene->id.flag & LIB_DOIT) { + if(re1->r.scemode & R_FULL_SAMPLE) { + if(sample) { read_render_result(re1, sample); composite_freestyle_renders(re1, sample); - ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ } + ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ } } } - + /* composite */ if(ntree) { ntreeCompositTagRender(re->scene); @@ -2430,6 +2411,17 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) break; } + /* clear interaction callbacks */ + if(ntree) { + ntree->stats_draw= NULL; + ntree->test_break= NULL; + ntree->progress= NULL; + ntree->tbh= ntree->sdh= ntree->prh= NULL; + } + + /* disable full sample print */ + R.i.curfsa= 0; + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); if(re->result->rectf) MEM_freeN(re->result->rectf); @@ -2469,8 +2461,10 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree) } /* own render result should be read/allocated */ - if(re->scene->id.flag & LIB_DOIT) + if(re->scene->id.flag & LIB_DOIT) { RE_ReadRenderResult(re->scene, re->scene); + re->scene->id.flag &= ~LIB_DOIT; + } /* and now we can draw (result is there) */ re->display_init(re->dih, re->result); @@ -2488,12 +2482,21 @@ static void do_render_composite_fields_blur_3d(Render *re) /* INIT seeding, compositor can use random texture */ BLI_srandom(re->r.cfra); - if(composite_needs_render(re->scene)) { + if(composite_needs_render(re->scene, 1)) { /* save memory... free all cached images */ ntreeFreeCache(ntree); do_render_fields_blur_3d(re); - } else { + } + else { + /* ensure new result gets added, like for regular renders */ + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); + + RE_FreeRenderResult(re->result); + re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); + + BLI_rw_mutex_unlock(&re->resultmutex); + /* scene render process already updates animsys */ update_newframe = 1; } @@ -2831,7 +2834,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo } if(scene->r.scemode & R_FULL_SAMPLE) { - if(composite_needs_render(scene)==0) { + if(composite_needs_render(scene, 0)==0) { error(erh, "Full Sample AA not supported without 3d rendering"); return 0; } diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 2d42938f6ac..56a1c870904 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -502,21 +502,6 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, /* ------------------------------------------------------------------------- */ -static void fillBackgroundImage(float *collector, float fx, float fy) -{ - collector[0] = 0.0; - collector[1] = 0.0; - collector[2] = 0.0; - collector[3] = 0.0; - - if(R.backbuf) { - float dx= 1.0f/(float)R.winx; - float dy= 1.0f/(float)R.winy; - - image_sample(R.backbuf, fx*dx, fy*dy, dx, dy, collector); - } -} - /* Only view vector is important here. Result goes to colf[3] */ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short thread) { @@ -626,18 +611,14 @@ void shadeSkyPixel(float *collector, float fx, float fy, short thread) float fac; - /* 1. Do a backbuffer image: */ - if(R.r.bufflag & 1) { - fillBackgroundImage(collector, fx, fy); - } - else if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { - /* 2. solid color */ + if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { + /* 1. solid color */ VECCOPY(collector, &R.wrld.horr); collector[3] = 0.0f; } else { - /* 3. */ + /* 2. */ /* This one true because of the context of this routine */ if(R.wrld.skytype & WO_SKYPAPER) { diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 5f5dab94ba3..c4587b83fcd 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2192,6 +2192,7 @@ void do_material_tex(ShadeInput *shi) } } else if(mtex->texco==TEXCO_REFL) { + calc_R_ref(shi); co= shi->ref; dx= shi->dxref; dy= shi->dyref; } else if(mtex->texco==TEXCO_NORM) { @@ -2509,9 +2510,6 @@ void do_material_tex(ShadeInput *shi) shi->orn[0]= -shi->vn[0]; shi->orn[1]= -shi->vn[1]; shi->orn[2]= -shi->vn[2]; - - /* reflection vector */ - calc_R_ref(shi); } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 0087be8cca9..7c197bb440e 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1956,40 +1956,6 @@ void add_halo_flare(Render *re) R.r.mode= mode; } -/* ************************* used for shaded view ************************ */ - -/* if *re, then initialize, otherwise execute */ -void RE_shade_external(Render *re, ShadeInput *shi, ShadeResult *shr) -{ - static VlakRen vlr; - static ObjectRen obr; - static ObjectInstanceRen obi; - - /* init */ - if(re) { - R= *re; - - /* fake render face */ - memset(&vlr, 0, sizeof(VlakRen)); - memset(&obr, 0, sizeof(ObjectRen)); - memset(&obi, 0, sizeof(ObjectInstanceRen)); - obr.lay= -1; - obi.obr= &obr; - - return; - } - shi->vlr= &vlr; - shi->obr= &obr; - shi->obi= &obi; - - if(shi->mat->nodetree && shi->mat->use_nodes) - ntreeShaderExecTree(shi->mat->nodetree, shi, shr); - else { - shade_input_init_material(shi); - shade_material_loop(shi, shr); - } -} - /* ************************* bake ************************ */ @@ -2464,7 +2430,8 @@ static int get_next_bake_face(BakeShade *bs) if(tface && tface->tpage) { Image *ima= tface->tpage; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; if(ibuf==NULL) continue; @@ -2484,7 +2451,7 @@ static int get_next_bake_face(BakeShade *bs) imb_freerectImBuf(ibuf); /* clear image */ if(R.r.bake_flag & R_BAKE_CLEAR) - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ R.bakebuf= ima; @@ -2589,6 +2556,48 @@ static void *do_bake_thread(void *bs_v) return NULL; } +void RE_bake_ibuf_filter(ImBuf *ibuf, unsigned char *mask, const int filter) +{ + /* must check before filtering */ + const short is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + + /* Margin */ + if(filter) { + char *temprect; + int i; + + /* extend the mask +2 pixels from the image, + * this is so colors dont blend in from outside */ + + for(i=0; i< filter; i++) + IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); + + temprect = MEM_dupallocN(ibuf->userdata); + + /* expand twice to clear this many pixels, so they blend back in */ + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + + /* clear all pixels in the margin */ + IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); + MEM_freeN(temprect); + + for(i= 0; i < filter; i++) + IMB_filter_extend(ibuf, (char *)ibuf->userdata); + } + + /* if the bake results in new alpha then change the image setting */ + if(is_new_alpha) { + ibuf->depth= 32; + } + else { + if(filter && ibuf->depth != 32) { + /* clear alpha added by filtering */ + IMB_rectfill_alpha(ibuf, 1.0f); + } + } +} + /* using object selection tags, the faces with UV maps get baked */ /* render should have been setup */ /* returns 0 if nothing was handled */ @@ -2675,36 +2684,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up if(!ibuf) continue; - if(re->r.bake_filter) { - if (usemask) { - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - char *temprect; - - for(a=0; ar.bake_filter; a++) - IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin*/ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - } - - for(a=0; ar.bake_filter; a++) { - /*the mask, ibuf->userdata - can be null, in this case only zero alpha is used */ - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } - - if (ibuf->userdata) { - MEM_freeN(ibuf->userdata); - ibuf->userdata= NULL; - } - } + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, re->r.bake_filter); ibuf->userflags |= IB_BITMAPDIRTY; if (ibuf->rect_float) IMB_rect_from_float(ibuf); diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 539e673a9d0..923bb5a1ae4 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -543,11 +543,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_REFL) { - /* mirror reflection color textures (and envmap) */ - calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ - } - if(texco & TEXCO_STRESS) { /* not supported */ } @@ -1208,11 +1203,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_REFL) { - /* mirror reflection color textures (and envmap) */ - calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ - } - if(texco & TEXCO_STRESS) { float *s1, *s2, *s3; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 2e4148ca51d..c61db1d653e 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -169,6 +169,7 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { GPU_extensions_init(); GPU_set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP)); + GPU_set_anisotropic(U.anisotropic_filter); UI_init(); } @@ -328,7 +329,6 @@ static void free_openrecent(void) /* bad stuff*/ -extern ListBase editelems; extern wchar_t *copybuf; extern wchar_t *copybufinfo; @@ -380,7 +380,6 @@ void WM_exit(bContext *C) BKE_freecubetable(); - fastshade_free_render(); /* shaded view */ ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ if(C && CTX_wm_manager(C)) @@ -394,10 +393,6 @@ void WM_exit(bContext *C) free_anim_drivers_copybuf(); free_fmodifiers_copybuf(); free_posebuf(); -// free_vertexpaint(); -// free_imagepaint(); - -// fsmenu_free(); BLF_exit(); @@ -420,10 +415,6 @@ void WM_exit(bContext *C) BPY_python_end(); #endif - if (!G.background) { -// XXX UI_filelist_free_icons(); - } - GPU_buffer_pool_free(NULL); GPU_free_unused_buffers(); GPU_extensions_exit(); diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 901aaea3eca..5fe045fda10 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -183,6 +183,12 @@ endif() message(STATUS "Player Skipping: (${REM_MSG})") endif() target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS}) + + unset(SEARCHLIB) + unset(SORTLIB) + unset(REMLIB) + unset(REM_MSG) + # else() # target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS}) # endif() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 4fcb8a66d5c..a7a6014498a 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -853,6 +853,12 @@ endif() message(STATUS "Blender Skipping: (${REM_MSG})") endif() target_link_libraries(blender ${BLENDER_SORTED_LIBS}) + + unset(SEARCHLIB) + unset(SORTLIB) + unset(REMLIB) + unset(REM_MSG) + #else() # target_link_libraries(blender ${BLENDER_LINK_LIBS}) #endif() diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c00e7ec7e29..7e353d590bb 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -405,7 +405,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) // 2.5x - could also do this but looks too high level, constraints use this, it works ok. // Object workob; /* evaluate using workob */ -// what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime); +// what_does_obaction(obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime); } // done getting the pose from the action diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 87d6c619229..7da474241a0 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -287,7 +287,8 @@ void BL_ConvertActuators(char* maggiename, camact->height, camact->min, camact->max, - camact->axis=='x'); + camact->axis=='x', + camact->damping); baseact = tmpcamact; } break; diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 0a65fc1584a..c270d9a312b 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -55,10 +55,10 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( m_rasterizer(rasterizer), m_scene(scene) { - m_gameObj = NULL; + m_gameobj = NULL; if(gameobj){ m_propNames = gameobj->GetPropertyNames(); - m_gameObj = gameobj; + m_gameobj = gameobj; } } @@ -91,7 +91,7 @@ bool SCA_2DFilterActuator::Update() } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { - m_scene->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText); + m_scene->Update2DFilter(m_propNames, m_gameobj, m_type, m_int_arg, m_shaderText); } // once the filter is in place, no need to update it again => disable the actuator return false; diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 87d2e8ddbcf..7f31c1713f4 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -42,7 +42,6 @@ class SCA_2DFilterActuator : public SCA_IActuator private: vector m_propNames; - void * m_gameObj; RAS_2DFilterManager::RAS_2DFILTER_MODE m_type; short m_disableMotionBlur; float m_float_arg; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 121f38eef02..14048c70516 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -408,6 +408,7 @@ int main(int argc, char** argv) // We load our own G.main, so free the one that initglobals() gives us free_main(G.main); + G.main = NULL; IMB_init(); @@ -450,6 +451,9 @@ int main(int argc, char** argv) U.audioformat = 0x24; U.audiochannels = 2; + // XXX this one too + U.anisotropic_filter = 2; + sound_init_once(); /* if running blenderplayer the last argument can't be parsed since it has to be the filename. */ @@ -705,6 +709,8 @@ int main(int argc, char** argv) { GPU_set_mipmap(0); } + + GPU_set_anisotropic(U.anisotropic_filter); // Create the system if (GHOST_ISystem::createSystem() == GHOST_kSuccess) diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index d2438a66367..a306e059442 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -28,6 +28,7 @@ #define spit(x) std::cout << x << std::endl; #include "MEM_guardedalloc.h" +#include "GPU_draw.h" extern "C" { // envmaps @@ -175,6 +176,8 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix ); } + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } @@ -199,6 +202,9 @@ void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, newPixels ); } + + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); free(newPixels); } diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index d68cb453fe8..ebb291b2284 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -54,14 +54,16 @@ KX_CameraActuator::KX_CameraActuator( float hght, float minhght, float maxhght, - bool xytog + bool xytog, + float damping ): SCA_IActuator(gameobj, KX_ACT_CAMERA), m_ob (obj), m_height (hght), m_minHeight (minhght), m_maxHeight (maxhght), - m_x (xytog) + m_x (xytog), + m_damping (damping) { if (m_ob) m_ob->RegisterActuator(this); @@ -283,7 +285,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) } inp= fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2]; - fac= (-1.0 + inp)/32.0; + fac= (-1.0 + inp) * m_damping; from[0]+= fac*fp1[0]; from[1]+= fac*fp1[1]; @@ -390,6 +392,7 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("height",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_height), KX_PYATTRIBUTE_BOOL_RW("useXY",KX_CameraActuator,m_x), KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object), + KX_PYATTRIBUTE_FLOAT_RW("damping",0.f,10.f,KX_CameraActuator,m_damping), {NULL} }; diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index d59fcff9370..f844f6418b8 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -73,6 +73,9 @@ private : /** xy toggle (pick one): true == x, false == y */ bool m_x; + + /** damping (float), */ + float m_damping; /* get the KX_IGameObject with this name */ CValue *findObject(char *obName); @@ -95,7 +98,8 @@ private : float hght, float minhght, float maxhght, - bool xytog + bool xytog, + float damping ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 97dc65c5850..08445654916 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -226,18 +226,43 @@ struct CcdConstructionInfo CcdConstructionInfo() - : m_localInertiaTensor(1.f, 1.f, 1.f), + :m_localInertiaTensor(1.f, 1.f, 1.f), m_gravity(0,0,0), m_scaling(1.f,1.f,1.f), m_mass(0.f), - m_clamp_vel_min(-1.f), - m_clamp_vel_max(-1.f), + m_clamp_vel_min(-1.f), + m_clamp_vel_max(-1.f), m_restitution(0.1f), m_friction(0.5f), m_linearDamping(0.1f), m_angularDamping(0.1f), m_margin(0.06f), m_gamesoftFlag(0), + m_soft_linStiff(1.f), + m_soft_angStiff(1.f), + m_soft_volume(1.f), + m_soft_viterations(0), + m_soft_piterations(1), + m_soft_diterations(0), + m_soft_citerations(4), + m_soft_kSRHR_CL(0.1f), + m_soft_kSKHR_CL(1.f), + m_soft_kSSHR_CL(0.5f), + m_soft_kSR_SPLT_CL(0.5f), + m_soft_kSK_SPLT_CL(0.5f), + m_soft_kSS_SPLT_CL(0.5f), + m_soft_kVCF(1.f), + m_soft_kDP(0.f), + m_soft_kDG(0.f), + m_soft_kLF(0.f), + m_soft_kPR(0.f), + m_soft_kVC(0.f), + m_soft_kDF(0.2f), + m_soft_kMT(0), + m_soft_kCHR(1.0f), + m_soft_kKHR(0.1f), + m_soft_kSHR(1.0f), + m_soft_kAHR(0.7f), m_collisionFlags(0), m_bRigid(false), m_bSoft(false), @@ -252,38 +277,13 @@ struct CcdConstructionInfo m_inertiaFactor(1.f), m_do_anisotropic(false), m_anisotropicFriction(1.f,1.f,1.f), - m_contactProcessingThreshold(1e10f), - m_soft_linStiff(1.f), - m_soft_angStiff(1.f), - m_soft_volume(1.f), - m_soft_viterations(0), - m_soft_piterations(1), - m_soft_diterations(0), - m_soft_citerations(4), m_do_fh(false), m_do_rot_fh(false), m_fh_spring(0.f), m_fh_damping(0.f), m_fh_distance(1.f), m_fh_normal(false), - m_soft_kVCF(1.f), - m_soft_kDG(0.f), - m_soft_kLF(0.f), - m_soft_kDP(0.f), - m_soft_kPR(0.f), - m_soft_kVC(0.f), - m_soft_kDF(0.2f), - m_soft_kMT(0), - m_soft_kCHR(1.0f), - m_soft_kKHR(0.1f), - m_soft_kSHR(1.0f), - m_soft_kAHR(0.7f), - m_soft_kSRHR_CL(0.1f), - m_soft_kSKHR_CL(1.f), - m_soft_kSSHR_CL(0.5f), - m_soft_kSR_SPLT_CL(0.5f), - m_soft_kSK_SPLT_CL(0.5f), - m_soft_kSS_SPLT_CL(0.5f) + m_contactProcessingThreshold(1e10f) { }