Cycles: svn merge -r41225:41232 ^/trunk/blender
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 24 Oct 2011 22:32:00 +0000 (22:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 24 Oct 2011 22:32:00 +0000 (22:32 +0000)
191 files changed:
1  2 
CMakeLists.txt
GNUmakefile
SConstruct
build_files/cmake/cmake_consistency_check.py
build_files/cmake/macros.cmake
build_files/cmake/project_info.py
build_files/cmake/project_source_info.py
extern/CMakeLists.txt
intern/CMakeLists.txt
intern/ffmpeg/ffmpeg_compat.h
intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_System.cpp
intern/ghost/intern/GHOST_System.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/itasc/CMakeLists.txt
intern/itasc/ConstraintSet.cpp
intern/itasc/ControlledObject.cpp
intern/itasc/CopyPose.cpp
intern/itasc/Scene.cpp
intern/itasc/WDLSSolver.cpp
intern/itasc/WSDLSSolver.cpp
intern/memutil/MEM_CacheLimiter.h
intern/memutil/MEM_CacheLimiterC-Api.h
intern/moto/CMakeLists.txt
intern/opennl/CMakeLists.txt
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/properties_particle.py
source/blender/blenfont/intern/blf_lang.c
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_depsgraph.h
source/blender/blenkernel/BKE_fcurve.h
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/seqcache.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/BLI_bpath.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/math_vector_inline.c
source/blender/blenlib/intern/string_utf8.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/include/ED_node.h
source/blender/editors/include/ED_uvedit.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/CMakeLists.txt
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_preview.c
source/blender/editors/render/render_shading.c
source/blender/editors/render/render_update.c
source/blender/editors/screen/area.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_buttons/CMakeLists.txt
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_intern.h
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_node/CMakeLists.txt
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_material.c
source/blender/ikplugin/CMakeLists.txt
source/blender/imbuf/CMakeLists.txt
source/blender/imbuf/IMB_imbuf.h
source/blender/imbuf/intern/IMB_filetype.h
source/blender/imbuf/intern/allocimbuf.c
source/blender/imbuf/intern/filetype.c
source/blender/imbuf/intern/indexer.c
source/blender/imbuf/intern/module.c
source/blender/imbuf/intern/readimage.c
source/blender/imbuf/intern/util.c
source/blender/imbuf/intern/writeimage.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_lamp_types.h
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesdna/DNA_world_types.h
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_nodetree_types.h
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/makesrna/intern/rna_world.c
source/blender/nodes/NOD_shader.h
source/blender/nodes/intern/node_common.c
source/blender/nodes/intern/node_socket.c
source/blender/nodes/shader/node_shader_tree.c
source/blender/nodes/shader/node_shader_util.c
source/blender/nodes/shader/node_shader_util.h
source/blender/nodes/shader/nodes/node_shader_camera.c
source/blender/nodes/shader/nodes/node_shader_common.c
source/blender/nodes/shader/nodes/node_shader_curves.c
source/blender/nodes/shader/nodes/node_shader_dynamic.c
source/blender/nodes/shader/nodes/node_shader_geom.c
source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
source/blender/nodes/shader/nodes/node_shader_invert.c
source/blender/nodes/shader/nodes/node_shader_mapping.c
source/blender/nodes/shader/nodes/node_shader_material.c
source/blender/nodes/shader/nodes/node_shader_math.c
source/blender/nodes/shader/nodes/node_shader_mixRgb.c
source/blender/nodes/shader/nodes/node_shader_normal.c
source/blender/nodes/shader/nodes/node_shader_output.c
source/blender/nodes/shader/nodes/node_shader_rgb.c
source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
source/blender/nodes/shader/nodes/node_shader_squeeze.c
source/blender/nodes/shader/nodes/node_shader_texture.c
source/blender/nodes/shader/nodes/node_shader_valToRgb.c
source/blender/nodes/shader/nodes/node_shader_value.c
source/blender/nodes/shader/nodes/node_shader_vectMath.c
source/blender/python/intern/bpy_interface.c
source/blender/render/extern/include/RE_engine.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/external_engine.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c
source/blenderplayer/CMakeLists.txt
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_SkinDeformer.cpp
source/gameengine/Converter/CMakeLists.txt
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/Ketsji/BL_Action.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

diff --combined CMakeLists.txt
@@@ -1,5 -1,4 +1,4 @@@
  # -*- mode: cmake; indent-tabs-mode: t; -*-
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -62,6 -61,13 +61,6 @@@ set(CMAKE_BUILD_TYPE_INIT "Release"
  # quiet output for Makefiles, 'make -s' helps too
  # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
  
 -# global compile definitions since add_definitions() adds for all.
 -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG           DEBUG _DEBUG)
 -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE         NDEBUG)
 -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL      NDEBUG)
 -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO  DEBUG _DEBUG)
 -
 -
  #-----------------------------------------------------------------------------
  # Set policy
  
@@@ -99,7 -105,6 +98,7 @@@ enable_testing(
  
  set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE )
  set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
 +set(INCLUDE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/include CACHE INTERNAL "" FORCE )
  
  #-----------------------------------------------------------------------------
  # Set default config options
@@@ -150,7 -155,7 +149,7 @@@ else(
  endif()
  
  if(UNIX AND NOT APPLE)
 -      option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)"   ON)
 +      option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
        option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
  else()
        # not an option for other OS's
@@@ -203,15 -208,6 +202,15 @@@ if(UNIX AND NOT APPLE
  endif()
  option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
  
 +# Cycles
 +option(WITH_CYCLES                    "Enable Cycles Render Engine" ON)
 +OPTION(WITH_CYCLES_OSL                "Build with Open Shading Language support" OFF)
 +OPTION(WITH_CYCLES_CUDA               "Build with CUDA binaries" OFF)
 +OPTION(WITH_CYCLES_BLENDER    "Build Blender Python extension" ON)
 +OPTION(WITH_CYCLES_PARTIO     "Build with Partio point cloud support (unfinished)" OFF)
 +OPTION(WITH_CYCLES_NETWORK    "Build with network rendering support (unfinished)" OFF)
 +OPTION(WITH_CYCLES_TEST               "Build cycles test application" OFF)
 +
  # disable for now, but plan to support on all platforms eventually
  option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
  mark_as_advanced(WITH_MEM_JEMALLOC)
@@@ -283,16 -279,6 +282,16 @@@ if(WITH_PYTHON_MODULE
        set(WITH_HEADLESS ON)
  endif()
  
 +# auto enable openimageio and boost for cycles
 +if(WITH_CYCLES)
 +      set(WITH_OPENIMAGEIO ON)
 +      set(WITH_BOOST ON)
 +endif()
 +
 +if(WITH_OPENIMAGEIO)
 +      set(WITH_BOOST ON)
 +endif()
 +
  TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
  
  # don't store paths to libs for portable distrobution
@@@ -497,47 -483,6 +496,47 @@@ if(UNIX AND NOT APPLE
                endif()
        endif()
  
 +      if(WITH_BOOST)
 +              if(CYCLES_BOOST)
 +                      set(BOOST ${CYCLES_BOOST} CACHE PATH "Boost Directory")
 +                      unset(CYCLES_BOOST CACHE)
 +              else()
 +                      set(BOOST "/usr" CACHE PATH "Boost Directory")
 +              endif()
 +
 +              if(NOT BOOST_CUSTOM)
 +                      set(BOOST_ROOT ${BOOST})
 +                      set(Boost_USE_MULTITHREADED ON)
 +                      find_package(Boost 1.34 REQUIRED COMPONENTS filesystem regex system thread)
 +              endif()
 +
 +              set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
 +              set(BOOST_LIBRARIES ${Boost_LIBRARIES})
 +              set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
 +              set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
 +      endif()
 +
 +      if(WITH_OPENIMAGEIO)
 +
 +              # temp, update
 +              if(CYCLES_OIIO)
 +                      set(OPENIMAGEIO ${CYCLES_OIIO})
 +                      unset(CYCLES_OIIO CACHE)
 +              endif()
 +
 +              set(OPENIMAGEIO_ROOT_DIR ${OPENIMAGEIO})
 +              find_package(OpenImageIO REQUIRED)
 +
 +              set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
 +              set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
 +              set(OPENIMAGEIO_DEFINITIONS)
 +
 +              if(NOT OPENIMAGEIO_FOUND)
 +                      set(WITH_OPENIMAGEIO OFF)
 +              endif()
 +
 +      endif()
 +
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
        set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
  
  
        set(PLATFORM_LINKFLAGS "-pthread")
  
 -      # lfs on glibc, all compilers should use
 -      add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
 +      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
 +      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
  
        # GNU Compiler
        if(CMAKE_COMPILER_IS_GNUCC)
@@@ -674,21 -619,21 +673,21 @@@ elseif(WIN32
                set(CMAKE_C_FLAGS   "/nologo /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
  
                if(CMAKE_CL_64)
 -                      set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
 +                      set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
                else()
 -                      set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
 +                      set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
                endif()
 -              set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 -              set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 -              set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
 +              set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 +              set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 +              set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
                if(CMAKE_CL_64)
 -                      set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
 +                      set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
                else()
 -                      set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
 +                      set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
                endif()
 -              set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 -              set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 -              set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
 +              set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 +              set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
 +              set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
  
                if(WITH_INTERNATIONAL)
                        set(GETTEXT ${LIBDIR}/gettext)
                        set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
                endif()
  
 +              if(WITH_BOOST)
 +                      set(BOOST ${LIBDIR}/boost)
 +                      set(BOOST_INCLUDE_DIR ${BOOST}/include)
 +                      if(CMAKE_CL_64)
 +                              set(BOOST_POSTFIX "vc90-mt-s-1_45.lib")
 +                              set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_45.lib")
 +                      else()
 +                              set(BOOST_POSTFIX "vc90-mt-s-1_46_1.lib")
 +                              set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_46_1.lib")
 +                      endif()
 +                      set(BOOST_LIBRARIES
 +                              optimized libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
 +                              libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX}
 +                              debug libboost_date_time-${BOOST_DEBUG_POSTFIX} libboost_filesystem-${BOOST_DEBUG_POSTFIX}
 +                              libboost_regex-${BOOST_DEBUG_POSTFIX} libboost_system-${BOOST_DEBUG_POSTFIX} libboost_thread-${BOOST_DEBUG_POSTFIX})
 +                      set(BOOST_LIBPATH ${BOOST}/lib)
 +                      set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
 +              endif()
 +                      
 +              if(WITH_OPENIMAGEIO)
 +                      set(OPENIMAGEIO ${LIBDIR}/openimageio)
 +                      set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
 +                      set(OPENIMAGEIO_LIBRARIES OpenImageIO)
 +                      set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
 +                      set(OPENIMAGEIO_DEFINITIONS)
 +              endif()
 +
                set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
  
                # MSVC only, Mingw doesnt need
  
                add_definitions(-DFREE_WINDOWS)
  
 +              set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
 +              set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
 +
                if(WITH_INTERNATIONAL)
                        set(GETTEXT ${LIBDIR}/gcc/gettext)
                        set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
                        set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
                endif()
  
 +              if(WITH_BOOST)
 +                      set(BOOST ${LIBDIR}/boost)
 +                      set(BOOST_INCLUDE_DIR ${BOOST}/include)
 +                      set(BOOST_POSTFIX "vc90-mt-s-1_46_1")
 +                      set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_46_1")
 +                      set(BOOST_LIBRARIES
 +                              optimized libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
 +                              libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX}
 +                              debug libboost_date_time-${BOOST_DEBUG_POSTFIX} libboost_filesystem-${BOOST_DEBUG_POSTFIX}
 +                              libboost_regex-${BOOST_DEBUG_POSTFIX} libboost_system-${BOOST_DEBUG_POSTFIX} libboost_thread-${BOOST_DEBUG_POSTFIX})
 +                      set(BOOST_LIBPATH ${BOOST}/lib)
 +                      set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
 +              endif()
 +                      
 +              if(WITH_OPENIMAGEIO)
 +                      set(OPENIMAGEIO ${LIBDIR}/openimageio)
 +                      set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
 +                      set(OPENIMAGEIO_LIBRARIES OpenImageIO)
 +                      set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
 +                      set(OPENIMAGEIO_DEFINITIONS)
 +              endif()
 +
                set(PLATFORM_LINKFLAGS "--stack,2097152")
  
        endif()
@@@ -1189,22 -1082,6 +1188,22 @@@ elseif(APPLE
                # linker needs "-weak_framework 3DconnexionClient"
        endif()
  
 +      if(WITH_BOOST)
 +              set(BOOST ${LIBDIR}/boost)
 +              set(BOOST_INCLUDE_DIR ${BOOST}/include)
 +              set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
 +              set(BOOST_LIBPATH ${BOOST}/lib)
 +              set(BOOST_DEFINITIONS)
 +      endif()
 +
 +      if(WITH_OPENIMAGEIO)
 +              set(OPENIMAGEIO ${LIBDIR}/openimageio)
 +              set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
 +              set(OPENIMAGEIO_LIBRARIES OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
 +              set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
 +              set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
 +      endif()
 +
        set(EXETYPE MACOSX_BUNDLE)
  
        set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
@@@ -1344,21 -1221,6 +1343,21 @@@ endif(
  #-----------------------------------------------------------------------------
  # Extra compile flags
  
 +if((NOT WIN32) AND (NOT MSVC))
 +      # used for internal debug checks
 +      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
 +      set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
 +
 +      # assert() checks for this.
 +      set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
 +      set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
 +      set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
 +
 +      set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
 +      set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
 +      set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
 +endif()
 +
  if(CMAKE_COMPILER_IS_GNUCC)
  
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
@@@ -1534,7 -1396,6 +1533,7 @@@ if(FIRST_RUN
        info_cfg_option(WITH_IMAGE_OPENJPEG)
        info_cfg_option(WITH_IMAGE_REDCODE)
        info_cfg_option(WITH_IMAGE_TIFF)
 +      info_cfg_option(WITH_OPENIMAGEIO)
  
        info_cfg_text("Audio:")
        info_cfg_option(WITH_OPENAL)
diff --combined GNUmakefile
@@@ -1,6 -1,5 +1,6 @@@
  # -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
 -# vim: tabstop=4
 +# vim: tabstop=8
- # $Id$
++# $Id: GNUmakefile 41122 2011-10-19 21:55:27Z campbellbarton $
  #
  # ##### BEGIN GPL LICENSE BLOCK #####
  #
diff --combined SConstruct
@@@ -1,5 -1,5 +1,5 @@@
  #!/usr/bin/env python
- # $Id$
 -#
++# $Id: SConstruct 41169 2011-10-21 04:23:26Z campbellbarton $
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -30,6 -30,8 +30,6 @@@
  # Then read all SConscripts and build
  #
  # TODO: fix /FORCE:MULTIPLE on windows to get proper debug builds.
 -# TODO: directory copy functions are far too complicated, see:
 -#       http://wiki.blender.org/index.php/User:Ideasman42/SConsNotSimpleInstallingFiles
  
  import platform as pltfrm
  
@@@ -1,6 -1,5 +1,5 @@@
  #!/usr/bin/env python
  
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -75,7 -74,7 +74,7 @@@ def is_c_header(filename)
  
  def is_c(filename):
      ext = splitext(filename)[1]
 -    return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl"))
 +    return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
  
  
  def is_c_any(filename):
@@@ -1,5 -1,4 +1,4 @@@
  # -*- mode: cmake; indent-tabs-mode: t; -*-
- # $Id$
  
  
  # foo_bar.spam --> foo_barMySuffix.spam
@@@ -17,7 -16,7 +16,7 @@@ macro(file_suffi
        unset(_file_name_EXT)
  endmacro()
  
 -# useful for adding debug suffix to library lists:
 +# usefil for adding debug suffix to library lists:
  # /somepath/foo.lib --> /somepath/foo_d.lib
  macro(file_list_suffix
        fp_list_new fp_list fn_suffix
@@@ -166,12 -165,6 +165,12 @@@ macro(SETUP_LIBDIRS
        if(WITH_IMAGE_TIFF)
                link_directories(${TIFF_LIBPATH})
        endif()
 +      if(WITH_BOOST)
 +              link_directories(${BOOST_LIBPATH})
 +      endif()
 +      if(WITH_OPENIMAGEIO)
 +              link_directories(${OPENIMAGEIO_LIBPATH})
 +      endif()
        if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
                link_directories(${OPENJPEG_LIBPATH})
        endif()
@@@ -266,12 -259,6 +265,12 @@@ macro(setup_liblink
        if(WITH_IMAGE_TIFF)
                target_link_libraries(${target} ${TIFF_LIBRARY})
        endif()
 +      if(WITH_OPENIMAGEIO)
 +              target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
 +      endif()
 +      if(WITH_BOOST)
 +              target_link_libraries(${target} ${BOOST_LIBRARIES})
 +      endif()
        if(WITH_IMAGE_OPENEXR)
                if(WIN32 AND NOT UNIX)
                        file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
@@@ -425,6 -412,32 +424,6 @@@ macro(remove_strict_flags
  
  endmacro()
  
 -# note, we can only append flags on a single file so we need to negate the options.
 -# at the moment we cant shut up ffmpeg deprecations, so use this, but will
 -# probably add more removals here.
 -macro(remove_strict_flags_file
 -      filenames)
 -
 -      foreach(_SOURCE ${ARGV})
 -
 -              if(CMAKE_COMPILER_IS_GNUCC)
 -                      set_source_files_properties(${_SOURCE}
 -                              PROPERTIES
 -                                      COMPILE_FLAGS "-Wno-deprecated-declarations"
 -                      )
 -              endif()
 -
 -              if(MSVC)
 -                      # TODO
 -              endif()
 -
 -      endforeach()    
 -
 -      unset(_SOURCE)
 -
 -endmacro()
 -
 -
  macro(ADD_CHECK_C_COMPILER_FLAG
        _CFLAGS
        _CACHE_VAR
@@@ -595,38 -608,3 +594,38 @@@ macro(blender_project_hack_post
        endif()
  
  endmacro()
 +
 +# pair of macros to allow libraries to be specify files to install, but to
 +# only install them at the end so the directories don't get cleared with
 +# the files in them. used by cycles to install addon.
 +macro(delayed_install
 +      base
 +      files
 +      destination)
 +
 +      foreach(f ${files})
 +              set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f})
 +              set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_DESTINATIONS ${destination})
 +      endforeach()
 +endmacro()
 +
 +# note this is a function instead of a macro so that ${BUILD_TYPE} in targetdir
 +# does not get expanded in calling but is preserved
 +function(delayed_do_install
 +      targetdir)
 +
 +      get_property(files GLOBAL PROPERTY DELAYED_INSTALL_FILES)
 +      get_property(destinations GLOBAL PROPERTY DELAYED_INSTALL_DESTINATIONS)
 +
 +      if(files)
 +              list(LENGTH files n)
 +              math(EXPR n "${n}-1")
 +
 +              foreach(i RANGE ${n})
 +                      list(GET files ${i} f)
 +                      list(GET destinations ${i} d)
 +                      install(FILES ${f} DESTINATION ${targetdir}/${d})
 +              endforeach()
 +      endif()
 +endfunction()
 +
@@@ -1,6 -1,5 +1,5 @@@
  #!/usr/bin/env python
  
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -105,7 -104,7 +104,7 @@@ def is_glsl(filename)
  
  def is_c(filename):
      ext = splitext(filename)[1]
 -    return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl"))
 +    return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
  
  
  def is_c_any(filename):
@@@ -1,4 -1,3 +1,3 @@@
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -41,7 -40,7 +40,7 @@@ def is_c_header(filename)
  
  def is_c(filename):
      ext = os.path.splitext(filename)[1]
 -    return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl"))
 +    return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
  
  
  def is_c_any(filename):
diff --combined extern/CMakeLists.txt
@@@ -1,4 -1,3 +1,3 @@@
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -27,6 -26,8 +26,6 @@@
  # Otherwise we get warnings here that we cant fix in external projects
  remove_strict_flags()
  
 -add_subdirectory(colamd)
 -
  if(WITH_BULLET)
        add_subdirectory(bullet2)
  endif()
diff --combined intern/CMakeLists.txt
@@@ -1,4 -1,3 +1,3 @@@
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -58,8 -57,3 +57,8 @@@ endif(
  if(WITH_IK_ITASC)
        add_subdirectory(itasc)
  endif()
 +
 +if(WITH_CYCLES)
 +      add_subdirectory(cycles)
 +endif()
 +
@@@ -2,7 -2,6 +2,6 @@@
  #define __ffmpeg_compat_h_included__ 1
  
  /*
-  * $Id$
   *
   * compatibility macros to make every ffmpeg installation appear
   * like the most current installation (wrapping some functionality sometimes)
@@@ -151,7 -150,8 +150,7 @@@ int64_t av_get_pts_from_frame(AVFormatC
        if (pts == AV_NOPTS_VALUE) {
                pts = 0;
        }
 -
 -      (void)avctx;
 +      
        return pts;
  }
  
@@@ -1,5 -1,4 +1,4 @@@
  /*
-  * $Id$
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -253,7 -252,7 +252,7 @@@ public
         * @return      Indication of success.
         */
        virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
 -              const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0) = 0;
 +              const bool stereoVisual) = 0;
  
        /**
         * Ends full screen mode.
@@@ -1,5 -1,4 +1,4 @@@
  /*
-  * $Id$
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -137,7 -136,7 +136,7 @@@ bool GHOST_System::validWindow(GHOST_IW
  
  
  GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
 -                                                                                       const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
 +                                                                                       const bool stereoVisual)
  {
        GHOST_TSuccess success = GHOST_kFailure;
        GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager")
                        success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
                        if (success == GHOST_kSuccess) {
                                //GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n");
 -                              success = createFullScreenWindow((GHOST_Window**)window, stereoVisual, numOfAASamples);
 +                              success = createFullScreenWindow((GHOST_Window**)window, stereoVisual);
                                if (success == GHOST_kSuccess) {
                                        m_windowManager->beginFullScreen(*window, stereoVisual);
                                }
@@@ -331,7 -330,7 +330,7 @@@ GHOST_TSuccess GHOST_System::exit(
  }
  
  
 -GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
 +GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const bool stereoVisual)
  {
        GHOST_TSuccess success;
        GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager")
                                        0, 0, settings.xPixels, settings.yPixels,
                                        GHOST_kWindowStateFullScreen,
                                        GHOST_kDrawingContextTypeOpenGL,
 -                                      stereoVisual,
 -                                      numOfAASamples);
 +                                      stereoVisual);
                success = *window == 0 ? GHOST_kFailure : GHOST_kSuccess;
        }
        return success;
@@@ -1,5 -1,4 +1,4 @@@
  /*
-  * $Id$
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -142,7 -141,7 +141,7 @@@ public
         * @return      Indication of success.
         */
        virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
 -              const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0);
 +              const bool stereoVisual);
  
        /**
         * Ends full screen mode.
@@@ -306,7 -305,7 +305,7 @@@ protected
         * @return Indication of success.
         */
        virtual GHOST_TSuccess createFullScreenWindow(GHOST_Window** window,
 -              const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0);
 +              const bool stereoVisual);
  
        /** The display manager (platform dependant). */
        GHOST_DisplayManager* m_displayManager;
@@@ -1,5 -1,4 +1,4 @@@
- /**
-  * $Id$
+ /*
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -1686,6 -1685,10 +1685,6 @@@ GHOST_TSuccess GHOST_SystemCocoa::handl
                                }
                        }
  
 -                      /* arrow keys should not have utf8 */
 -                      if ((keyCode > 266) && (keyCode < 271))
 -                              utf8_buf[0] = '\0';
 -
                        if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
                                break; //Cmd-Q is directly handled by Cocoa
  
@@@ -1,4 -1,3 +1,3 @@@
- # $Id: CMakeLists.txt 19905 2009-04-23 13:29:54Z ben2610 $
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -25,7 -24,7 +24,7 @@@
  # ***** END GPL LICENSE BLOCK *****
  
  set(INC
 -      ../../extern/Eigen3
 +      ../../extern/Eigen2
  )
  
  set(INC_SYS
@@@ -47,6 -46,8 +46,6 @@@ set(SR
        WSDLSSolver.cpp
        WorldObject.cpp
        eigen_types.cpp
 -      ublas_types.hpp
 -
        kdl/chain.cpp
        kdl/chainfksolverpos_recursive.cpp
        kdl/chainjnttojacsolver.cpp
        kdl/utilities/traits.h
        kdl/utilities/utility.h
        kdl/utilities/utility_io.h
 -
 -      kdl/frameacc.inl
 -      kdl/frames.inl
 -      kdl/framevel.inl
 +      ublas_types.hpp
  
        # until we have another user...
 -      ../../extern/Eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h
 -      ../../extern/Eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h
 -      ../../extern/Eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h
 -      ../../extern/Eigen3/Eigen/src/plugins/BlockMethods.h
 -      ../../extern/Eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h
 -      ../../extern/Eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h
 -      ../../extern/Eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h
 -      ../../extern/Eigen3/Eigen/src/misc/Kernel.h
 -      ../../extern/Eigen3/Eigen/src/misc/Image.h
 -      ../../extern/Eigen3/Eigen/src/misc/Solve.h
 -      ../../extern/Eigen3/Eigen/src/QR/HouseholderQR.h
 -      ../../extern/Eigen3/Eigen/src/QR/ColPivHouseholderQR.h
 -      ../../extern/Eigen3/Eigen/src/QR/FullPivHouseholderQR.h
 -      ../../extern/Eigen3/Eigen/src/StlSupport/details.h
 -      ../../extern/Eigen3/Eigen/src/StlSupport/StdList.h
 -      ../../extern/Eigen3/Eigen/src/StlSupport/StdDeque.h
 -      ../../extern/Eigen3/Eigen/src/StlSupport/StdVector.h
 -      ../../extern/Eigen3/Eigen/src/SVD/UpperBidiagonalization.h
 -      ../../extern/Eigen3/Eigen/src/SVD/JacobiSVD.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/ComplexSchur.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/RealSchur.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/EigenvaluesCommon.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h
 -      ../../extern/Eigen3/Eigen/src/Eigenvalues/EigenSolver.h
 -      ../../extern/Eigen3/Eigen/src/Jacobi/Jacobi.h
 -      ../../extern/Eigen3/Eigen/src/Householder/Householder.h
 -      ../../extern/Eigen3/Eigen/src/Householder/BlockHouseholder.h
 -      ../../extern/Eigen3/Eigen/src/Householder/HouseholderSequence.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/RotationBase.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Rotation2D.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Homogeneous.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Hyperplane.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/EulerAngles.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/ParametrizedLine.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/OrthoMethods.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/AngleAxis.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Umeyama.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Scaling.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Translation.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/AlignedBox.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Transform.h
 -      ../../extern/Eigen3/Eigen/src/Geometry/Quaternion.h
 -      ../../extern/Eigen3/Eigen/src/LU/PartialPivLU.h
 -      ../../extern/Eigen3/Eigen/src/LU/Determinant.h
 -      ../../extern/Eigen3/Eigen/src/LU/arch/Inverse_SSE.h
 -      ../../extern/Eigen3/Eigen/src/LU/FullPivLU.h
 -      ../../extern/Eigen3/Eigen/src/LU/Inverse.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseMatrixBase.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseSelfAdjointView.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseVector.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseDiagonalProduct.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/TriangularSolver.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/AmbiVector.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseDenseProduct.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseBlock.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseTriangularView.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseCwiseBinaryOp.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/CoreIterators.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseAssign.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseSparseProduct.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseDot.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/DynamicSparseMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseRedux.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseFuzzy.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseCwiseUnaryOp.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseView.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/MappedSparseMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseUtil.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseTranspose.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/SparseProduct.h
 -      ../../extern/Eigen3/Eigen/src/Sparse/CompressedStorage.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Cwise.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/TriangularSolver.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/QR.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Lazy.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Memory.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/SVD.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/CwiseOperators.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/VectorBlock.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Meta.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Macros.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/LeastSquares.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/LU.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Block.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/All.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/Minor.h
 -      ../../extern/Eigen3/Eigen/src/Eigen2Support/MathFunctions.h
 -      ../../extern/Eigen3/Eigen/src/Core/SelfAdjointView.h
 -      ../../extern/Eigen3/Eigen/src/Core/MatrixBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/Swap.h
 -      ../../extern/Eigen3/Eigen/src/Core/DenseCoeffsBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/DenseBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/GlobalFunctions.h
 -      ../../extern/Eigen3/Eigen/src/Core/ProductBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/CwiseBinaryOp.h
 -      ../../extern/Eigen3/Eigen/src/Core/Stride.h
 -      ../../extern/Eigen3/Eigen/src/Core/Matrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/Visitor.h
 -      ../../extern/Eigen3/Eigen/src/Core/Array.h
 -      ../../extern/Eigen3/Eigen/src/Core/ReturnByValue.h
 -      ../../extern/Eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h
 -      ../../extern/Eigen3/Eigen/src/Core/EigenBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/Random.h
 -      ../../extern/Eigen3/Eigen/src/Core/Redux.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/Default/Settings.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/AltiVec/Complex.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/NEON/PacketMath.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/NEON/Complex.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/SSE/Complex.h
 -      ../../extern/Eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h
 -      ../../extern/Eigen3/Eigen/src/Core/BooleanRedux.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/BlasUtil.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/Memory.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/Meta.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/Constants.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/Macros.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/ForwardDeclarations.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/StaticAssert.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/DisableStupidWarnings.h
 -      ../../extern/Eigen3/Eigen/src/Core/util/XprHelper.h
 -      ../../extern/Eigen3/Eigen/src/Core/VectorBlock.h
 -      ../../extern/Eigen3/Eigen/src/Core/Transpositions.h
 -      ../../extern/Eigen3/Eigen/src/Core/Select.h
 -      ../../extern/Eigen3/Eigen/src/Core/BandMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/CwiseUnaryView.h
 -      ../../extern/Eigen3/Eigen/src/Core/Dot.h
 -      ../../extern/Eigen3/Eigen/src/Core/GenericPacketMath.h
 -      ../../extern/Eigen3/Eigen/src/Core/Product.h
 -      ../../extern/Eigen3/Eigen/src/Core/Transpose.h
 -      ../../extern/Eigen3/Eigen/src/Core/Block.h
 -      ../../extern/Eigen3/Eigen/src/Core/ArrayWrapper.h
 -      ../../extern/Eigen3/Eigen/src/Core/MapBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/NoAlias.h
 -      ../../extern/Eigen3/Eigen/src/Core/ForceAlignedAccess.h
 -      ../../extern/Eigen3/Eigen/src/Core/PlainObjectBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/IO.h
 -      ../../extern/Eigen3/Eigen/src/Core/DiagonalMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/CwiseUnaryOp.h
 -      ../../extern/Eigen3/Eigen/src/Core/Reverse.h
 -      ../../extern/Eigen3/Eigen/src/Core/Fuzzy.h
 -      ../../extern/Eigen3/Eigen/src/Core/DenseStorage.h
 -      ../../extern/Eigen3/Eigen/src/Core/StableNorm.h
 -      ../../extern/Eigen3/Eigen/src/Core/NumTraits.h
 -      ../../extern/Eigen3/Eigen/src/Core/Map.h
 -      ../../extern/Eigen3/Eigen/src/Core/Functors.h
 -      ../../extern/Eigen3/Eigen/src/Core/PermutationMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/ArrayBase.h
 -      ../../extern/Eigen3/Eigen/src/Core/CwiseNullaryOp.h
 -      ../../extern/Eigen3/Eigen/src/Core/SolveTriangular.h
 -      ../../extern/Eigen3/Eigen/src/Core/NestByValue.h
 -      ../../extern/Eigen3/Eigen/src/Core/DiagonalProduct.h
 -      ../../extern/Eigen3/Eigen/src/Core/CommaInitializer.h
 -      ../../extern/Eigen3/Eigen/src/Core/MathFunctions.h
 -      ../../extern/Eigen3/Eigen/src/Core/Diagonal.h
 -      ../../extern/Eigen3/Eigen/src/Core/Replicate.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/SelfadjointProduct.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/GeneralMatrixVector.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/CoeffBasedProduct.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/Parallelizer.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/TriangularSolverVector.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/TriangularMatrixVector.h
 -      ../../extern/Eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h
 -      ../../extern/Eigen3/Eigen/src/Core/TriangularMatrix.h
 -      ../../extern/Eigen3/Eigen/src/Core/VectorwiseOp.h
 -      ../../extern/Eigen3/Eigen/src/Core/Assign.h
 -      ../../extern/Eigen3/Eigen/src/Core/Flagged.h
 -      ../../extern/Eigen3/Eigen/src/Cholesky/LDLT.h
 -      ../../extern/Eigen3/Eigen/src/Cholesky/LLT.h
 +      ../../extern/Eigen2/Eigen/src/Array/BooleanRedux.h
 +      ../../extern/Eigen2/Eigen/src/Array/CwiseOperators.h
 +      ../../extern/Eigen2/Eigen/src/Array/Functors.h
 +      ../../extern/Eigen2/Eigen/src/Array/Norms.h
 +      ../../extern/Eigen2/Eigen/src/Array/PartialRedux.h
 +      ../../extern/Eigen2/Eigen/src/Array/Random.h
 +      ../../extern/Eigen2/Eigen/src/Array/Select.h
 +      ../../extern/Eigen2/Eigen/src/Cholesky/LDLT.h
 +      ../../extern/Eigen2/Eigen/src/Cholesky/LLT.h
 +      ../../extern/Eigen2/Eigen/src/Core/Assign.h
 +      ../../extern/Eigen2/Eigen/src/Core/Block.h
 +      ../../extern/Eigen2/Eigen/src/Core/CacheFriendlyProduct.h
 +      ../../extern/Eigen2/Eigen/src/Core/Coeffs.h
 +      ../../extern/Eigen2/Eigen/src/Core/CommaInitializer.h
 +      ../../extern/Eigen2/Eigen/src/Core/Cwise.h
 +      ../../extern/Eigen2/Eigen/src/Core/CwiseBinaryOp.h
 +      ../../extern/Eigen2/Eigen/src/Core/CwiseNullaryOp.h
 +      ../../extern/Eigen2/Eigen/src/Core/CwiseUnaryOp.h
 +      ../../extern/Eigen2/Eigen/src/Core/DiagonalCoeffs.h
 +      ../../extern/Eigen2/Eigen/src/Core/DiagonalMatrix.h
 +      ../../extern/Eigen2/Eigen/src/Core/DiagonalProduct.h
 +      ../../extern/Eigen2/Eigen/src/Core/Dot.h
 +      ../../extern/Eigen2/Eigen/src/Core/Flagged.h
 +      ../../extern/Eigen2/Eigen/src/Core/Functors.h
 +      ../../extern/Eigen2/Eigen/src/Core/Fuzzy.h
 +      ../../extern/Eigen2/Eigen/src/Core/GenericPacketMath.h
 +      ../../extern/Eigen2/Eigen/src/Core/IO.h
 +      ../../extern/Eigen2/Eigen/src/Core/Map.h
 +      ../../extern/Eigen2/Eigen/src/Core/MapBase.h
 +      ../../extern/Eigen2/Eigen/src/Core/MathFunctions.h
 +      ../../extern/Eigen2/Eigen/src/Core/Matrix.h
 +      ../../extern/Eigen2/Eigen/src/Core/MatrixBase.h
 +      ../../extern/Eigen2/Eigen/src/Core/MatrixStorage.h
 +      ../../extern/Eigen2/Eigen/src/Core/Minor.h
 +      ../../extern/Eigen2/Eigen/src/Core/NestByValue.h
 +      ../../extern/Eigen2/Eigen/src/Core/NumTraits.h
 +      ../../extern/Eigen2/Eigen/src/Core/Part.h
 +      ../../extern/Eigen2/Eigen/src/Core/Product.h
 +      ../../extern/Eigen2/Eigen/src/Core/Redux.h
 +      ../../extern/Eigen2/Eigen/src/Core/SolveTriangular.h
 +      ../../extern/Eigen2/Eigen/src/Core/Sum.h
 +      ../../extern/Eigen2/Eigen/src/Core/Swap.h
 +      ../../extern/Eigen2/Eigen/src/Core/Transpose.h
 +      ../../extern/Eigen2/Eigen/src/Core/Visitor.h
 +      ../../extern/Eigen2/Eigen/src/Core/arch/AltiVec/PacketMath.h
 +      ../../extern/Eigen2/Eigen/src/Core/arch/SSE/PacketMath.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/Constants.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/DisableMSVCWarnings.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/EnableMSVCWarnings.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/ForwardDeclarations.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/Macros.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/Memory.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/Meta.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/StaticAssert.h
 +      ../../extern/Eigen2/Eigen/src/Core/util/XprHelper.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/AlignedBox.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/AngleAxis.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/EulerAngles.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/Hyperplane.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/OrthoMethods.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/ParametrizedLine.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/Quaternion.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/Rotation2D.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/RotationBase.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/Scaling.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/Transform.h
 +      ../../extern/Eigen2/Eigen/src/Geometry/Translation.h
 +      ../../extern/Eigen2/Eigen/src/LU/Determinant.h
 +      ../../extern/Eigen2/Eigen/src/LU/Inverse.h
 +      ../../extern/Eigen2/Eigen/src/LU/LU.h
 +      ../../extern/Eigen2/Eigen/src/LeastSquares/LeastSquares.h
 +      ../../extern/Eigen2/Eigen/src/QR/EigenSolver.h
 +      ../../extern/Eigen2/Eigen/src/QR/HessenbergDecomposition.h
 +      ../../extern/Eigen2/Eigen/src/QR/QR.h
 +      ../../extern/Eigen2/Eigen/src/QR/SelfAdjointEigenSolver.h
 +      ../../extern/Eigen2/Eigen/src/QR/Tridiagonalization.h
 +      ../../extern/Eigen2/Eigen/src/SVD/SVD.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/AmbiVector.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/CholmodSupport.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/CompressedStorage.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/CoreIterators.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/DynamicSparseMatrix.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/MappedSparseMatrix.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/RandomSetter.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseAssign.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseBlock.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseCwise.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseCwiseBinaryOp.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseCwiseUnaryOp.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseDiagonalProduct.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseDot.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseFlagged.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseFuzzy.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseLDLT.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseLLT.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseLU.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseMatrix.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseMatrixBase.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseProduct.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseRedux.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseTranspose.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseUtil.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SparseVector.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/SuperLUSupport.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/TaucsSupport.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/TriangularSolver.h
 +      ../../extern/Eigen2/Eigen/src/Sparse/UmfPackSupport.h
  )
  
 -if(WIN32)
 -      add_definitions(-DEIGEN_DONT_ALIGN_STATICALLY)
 -endif()
 -
  blender_add_lib(bf_intern_itasc "${SRC}" "${INC}" "${INC_SYS}")
@@@ -1,7 -1,7 +1,7 @@@
  /** \file itasc/ConstraintSet.cpp
   *  \ingroup itasc
   */
- /* $Id$
+ /*
   * ConstraintSet.cpp
   *
   *  Created on: Jan 5, 2009
@@@ -80,7 -80,7 +80,7 @@@ void ConstraintSet::modelUpdate(Frame& 
  
  double ConstraintSet::getMaxTimestep(double& timestep)
  {
 -      e_scalar maxChidot = m_chidot.array().abs().maxCoeff();
 +      e_scalar maxChidot = m_chidot.cwise().abs().maxCoeff();
        if (timestep*maxChidot > m_maxDeltaChi) {
                timestep = m_maxDeltaChi/maxChidot;
        }
@@@ -162,9 -162,9 +162,9 @@@ bool ConstraintSet::closeLoop()
          }else
              m_B.row(i) = m_U.col(i)/m_S(i);
  
 -    m_Jf_inv.noalias()=m_V*m_B;
 +    m_Jf_inv=(m_V*m_B).lazy();
  
 -    m_chi.noalias()+=m_Jf_inv*m_tdelta;
 +    m_chi+=(m_Jf_inv*m_tdelta).lazy();
      updateJacobian();
        // m_externalPose-m_internalPose in end effector frame
        // this is just to compare the pose, a different formula would work too
@@@ -1,7 -1,7 +1,7 @@@
  /** \file itasc/ControlledObject.cpp
   *  \ingroup itasc
   */
- /* $Id$
+ /*
   * ControlledObject.cpp
   *
   *  Created on: Jan 5, 2009
@@@ -54,7 -54,7 +54,7 @@@ const e_matrix& ControlledObject::getJq
  
  double ControlledObject::getMaxTimestep(double& timestep)
  {
 -      e_scalar maxQdot = m_qdot.array().abs().maxCoeff();
 +      e_scalar maxQdot = m_qdot.cwise().abs().maxCoeff();
        if (timestep*maxQdot > m_maxDeltaQ) {
                timestep = m_maxDeltaQ/maxQdot;
        }
@@@ -1,7 -1,7 +1,7 @@@
  /** \file itasc/CopyPose.cpp
   *  \ingroup itasc
   */
- /* $Id$
+ /*
   * CopyPose.cpp
   *
   *  Created on: Mar 17, 2009
@@@ -473,7 -473,7 +473,7 @@@ double CopyPose::getMaxTimestep(double
        // CopyPose should not have any limit on linear velocity: 
        // in case the target is out of reach, this can be very high.
        // We will simply limit on rotation
 -      e_scalar maxChidot = m_chidot.block(3,0,3,1).array().abs().maxCoeff();
 +      e_scalar maxChidot = m_chidot.block(3,0,3,1).cwise().abs().maxCoeff();
        if (timestep*maxChidot > m_maxDeltaChi) {
                timestep = m_maxDeltaChi/maxChidot;
        }
diff --combined intern/itasc/Scene.cpp
@@@ -1,7 -1,7 +1,7 @@@
  /** \file itasc/Scene.cpp
   *  \ingroup itasc
   */
- /* $Id$
+ /*
   * Scene.cpp
   *
   *  Created on: Jan 5, 2009
@@@ -356,7 -356,7 +356,7 @@@ bool Scene::update(double timestamp, do
                                        m_Uf.col(i).setConstant(0.0);
                                else
                                        m_Uf.col(i)*=(1/m_Sf(i));
 -                      project(m_Jf_inv,cs->featurerange,cs->featurerange).noalias()=m_Vf*m_Uf.transpose();
 +                      project(m_Jf_inv,cs->featurerange,cs->featurerange)=(m_Vf*m_Uf.transpose()).lazy();
  
                        //Get the robotjacobian associated with this constraintset
                        //Each jacobian is expressed in robot base frame => convert to world reference
                }
  
            //Calculate A
 -              m_Atemp.noalias()=m_Cf*m_Jf_inv;
 -              m_A.noalias() = m_Cq-(m_Atemp*m_Jq);
 +              m_Atemp=(m_Cf*m_Jf_inv).lazy();
 +              m_A = m_Cq-(m_Atemp*m_Jq).lazy();
                if (m_nuTotal > 0) {
 -                      m_B.noalias()=m_Atemp*m_Ju;
 -                      m_ydot.noalias() += m_B*m_xdot;
 +                      m_B=(m_Atemp*m_Ju).lazy();
 +                      m_ydot += (m_B*m_xdot).lazy();
                }
  
                //Call the solver with A, Wq, Wy, ydot to solver qdot:
                        //Calculate the twist of the world reference frame due to the robots (Jq*qdot+Ju*chiudot):
                        e_vector6 external_vel = e_zero_vector(6);
                        if (ob1->jointrange.count > 0)
 -                              external_vel.noalias() += (project(m_Jq,cs->featurerange,ob1->jointrange)*project(m_qdot,ob1->jointrange));
 +                              external_vel += (project(m_Jq,cs->featurerange,ob1->jointrange)*project(m_qdot,ob1->jointrange)).lazy();
                        if (ob2->jointrange.count > 0)
 -                              external_vel.noalias() += (project(m_Jq,cs->featurerange,ob2->jointrange)*project(m_qdot,ob2->jointrange));
 +                              external_vel += (project(m_Jq,cs->featurerange,ob2->jointrange)*project(m_qdot,ob2->jointrange)).lazy();
                        if (ob1->coordinaterange.count > 0)
 -                              external_vel.noalias() += (project(m_Ju,cs->featurerange,ob1->coordinaterange)*project(m_xdot,ob1->coordinaterange));
 +                              external_vel += (project(m_Ju,cs->featurerange,ob1->coordinaterange)*project(m_xdot,ob1->coordinaterange)).lazy();
                        if (ob2->coordinaterange.count > 0)
 -                              external_vel.noalias() += (project(m_Ju,cs->featurerange,ob2->coordinaterange)*project(m_xdot,ob2->coordinaterange));
 +                              external_vel += (project(m_Ju,cs->featurerange,ob2->coordinaterange)*project(m_xdot,ob2->coordinaterange)).lazy();
                        //the twist caused by the constraint must be opposite because of the closed loop
                        //estimate the velocity of the joints using the inverse jacobian
                        e_vector6 estimated_chidot = project(m_Jf_inv,cs->featurerange,cs->featurerange)*(-external_vel);
@@@ -1,7 -1,7 +1,7 @@@
  /** \file itasc/WDLSSolver.cpp
   *  \ingroup itasc
   */
- /* $Id$
+ /*
   * WDLSSolver.hpp.cpp
   *
   *  Created on: Jan 8, 2009
@@@ -65,10 -65,10 +65,10 @@@ bool WDLSSolver::solve(const e_matrix& 
      if(ret<0)
          return false;
  
 -    m_WqV.noalias() = Wq*m_V;
 +    m_WqV = (Wq*m_V).lazy();
  
      //Wy*ydot
 -      m_Wy_ydot = Wy.array() * ydot.array();
 +      m_Wy_ydot = Wy.cwise() * ydot;
      //S^-1*U'*Wy*ydot
        e_scalar maxDeltaS = e_scalar(0.0);
        e_scalar prevS = e_scalar(0.0);
@@@ -85,7 -85,7 +85,7 @@@
                }
                lambda = (S < m_epsilon) ? (e_scalar(1.0)-KDL::sqr(S/m_epsilon))*m_lambda*m_lambda : e_scalar(0.0);
                alpha = m_U.col(i).dot(m_Wy_ydot)*S/(S*S+lambda);
 -              vmax = m_WqV.col(i).array().abs().maxCoeff();
 +              vmax = m_WqV.col(i).cwise().abs().maxCoeff();
                norm = fabs(alpha*vmax);
                if (norm > m_qmax) {
                        qdot += m_WqV.col(i)*(alpha*m_qmax/norm);
@@@ -1,7 -1,7 +1,7 @@@
  /** \file itasc/WSDLSSolver.cpp
   *  \ingroup itasc
   */
- /* $Id$
+ /*
   * WDLSSolver.hpp.cpp
   *
   *  Created on: Jan 8, 2009
@@@ -60,7 -60,7 +60,7 @@@ bool WSDLSSolver::solve(const e_matrix
        e_scalar N, M;
  
        // Create the Weighted jacobian
 -    m_AWq.noalias() = A*Wq;
 +    m_AWq = (A*Wq).lazy();
        for (i=0; i<m_nc; i++)
                m_WyAWq.row(i) = Wy(i)*m_AWq.row(i);
  
@@@ -75,8 -75,8 +75,8 @@@
      if(ret<0)
          return false;
  
 -      m_Wy_ydot = Wy.array() * ydot.array();
 -    m_WqV.noalias() = Wq*m_V;
 +      m_Wy_ydot = Wy.cwise() * ydot;
 +    m_WqV = (Wq*m_V).lazy();
        qdot.setZero();
        e_scalar maxDeltaS = e_scalar(0.0);
        e_scalar prevS = e_scalar(0.0);
                M *= Sinv;
                alpha = m_U.col(i).dot(m_Wy_ydot);
                _qmax = (N < M) ? m_qmax*N/M : m_qmax;
 -              vmax = m_WqV.col(i).array().abs().maxCoeff();
 +              vmax = m_WqV.col(i).cwise().abs().maxCoeff();
                norm = fabs(Sinv*alpha*vmax);
                if (norm > _qmax) {
                        damp = Sinv*alpha*_qmax/norm;
@@@ -1,5 -1,4 +1,4 @@@
  /*
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -126,6 -125,10 +125,6 @@@ class MEM_CacheLimiter 
  public:
        typedef typename std::list<MEM_CacheLimiterHandle<T> *,
          MEM_Allocator<MEM_CacheLimiterHandle<T> *> >::iterator iterator;
 -      typedef intptr_t (*MEM_CacheLimiter_DataSize_Func) (void *data);
 -      MEM_CacheLimiter(MEM_CacheLimiter_DataSize_Func getDataSize_)
 -              : getDataSize(getDataSize_) {
 -      }
        ~MEM_CacheLimiter() {
                for (iterator it = queue.begin(); it != queue.end(); it++) {
                        delete *it;
        }
        void enforce_limits() {
                intptr_t max = MEM_CacheLimiter_get_maximum();
 -              intptr_t mem_in_use, cur_size;
 +              intptr_t mem_in_use= MEM_get_memory_in_use();
 +              intptr_t mmap_in_use= MEM_get_mapped_memory_in_use();
  
                if (max == 0) {
                        return;
                }
 -
 -              if(getDataSize) {
 -                      mem_in_use = total_size();
 -              } else {
 -                      mem_in_use = MEM_get_memory_in_use();
 -              }
 -
                for (iterator it = queue.begin(); 
 -                   it != queue.end() && mem_in_use > max;) {
 +                   it != queue.end() && mem_in_use + mmap_in_use > max;) {
                        iterator jt = it;
                        ++it;
 -
 -                      if(getDataSize) {
 -                              cur_size= getDataSize((*jt)->get()->get_data());
 -                      } else {
 -                              cur_size= mem_in_use;
 -                      }
 -
                        (*jt)->destroy_if_possible();
 -
 -                      if(getDataSize) {
 -                              mem_in_use-= cur_size;
 -                      } else {
 -                              mem_in_use-= cur_size - MEM_get_memory_in_use();
 -                      }
                }
        }
        void touch(MEM_CacheLimiterHandle<T> * handle) {
                handle->me = it;
        }
  private:
 -      intptr_t total_size() {
 -              intptr_t size = 0;
 -              for (iterator it = queue.begin(); it != queue.end(); it++) {
 -                      size+= getDataSize((*it)->get()->get_data());
 -              }
 -              return size;
 -      }
 -
        std::list<MEM_CacheLimiterHandle<T>*,
          MEM_Allocator<MEM_CacheLimiterHandle<T> *> > queue;
 -      MEM_CacheLimiter_DataSize_Func getDataSize;
  };
  
  #endif // MEM_CACHELIMITER_H
@@@ -1,5 -1,4 +1,4 @@@
  /*
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -42,6 -41,9 +41,6 @@@ typedef struct MEM_CacheLimiterHandle_
  /* function used to remove data from memory */
  typedef void(*MEM_CacheLimiter_Destruct_Func)(void*);
  
 -/* function used to measure stored data element size */
 -typedef intptr_t(*MEM_CacheLimiter_DataSize_Func) (void*);
 -
  #ifndef MEM_CACHELIMITER_H
  extern void MEM_CacheLimiter_set_maximum(int m);
  extern int MEM_CacheLimiter_get_maximum(void);
@@@ -55,7 -57,8 +54,7 @@@
   */
  
  extern MEM_CacheLimiterC * new_MEM_CacheLimiter(
 -      MEM_CacheLimiter_Destruct_Func data_destructor,
 -      MEM_CacheLimiter_DataSize_Func data_size);
 +      MEM_CacheLimiter_Destruct_Func data_destructor);
  
  /** 
   * Delete MEM_CacheLimiter
@@@ -1,4 -1,3 +1,3 @@@
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -69,6 -68,16 +68,6 @@@ set(SR
        include/MT_assert.h
        include/MT_random.h
        include/NM_Scalar.h
 -
 -      include/MT_Matrix3x3.inl
 -      include/MT_Matrix4x4.inl
 -      include/MT_Plane3.inl
 -      include/MT_Point2.inl
 -      include/MT_Point3.inl
 -      include/MT_Quaternion.inl
 -      include/MT_Vector2.inl
 -      include/MT_Vector3.inl
 -      include/MT_Vector4.inl
  )
  
  blender_add_lib(bf_intern_moto "${SRC}" "${INC}" "${INC_SYS}")
@@@ -1,4 -1,3 +1,3 @@@
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -41,6 -40,7 +40,6 @@@ add_definitions
  set(INC
        extern
        superlu
 -      ../../extern/colamd/Include
  )
  
  set(INC_SYS
@@@ -49,7 -49,6 +48,7 @@@
  
  set(SRC
        intern/opennl.c
 +      superlu/colamd.c
        superlu/get_perm_c.c
        superlu/heap_relax_snode.c
        superlu/lsame.c
@@@ -84,7 -83,6 +83,7 @@@
        extern/ONL_opennl.h
        superlu/superlu_sys_types.h
        superlu/Cnames.h
 +      superlu/colamd.h
        superlu/ssp_defs.h
        superlu/supermatrix.h
        superlu/util.h
@@@ -1179,7 -1179,31 +1179,7 @@@ class WM_OT_copy_prev_settings(Operator
  
          return {'CANCELLED'}
  
 -class WM_OT_blenderplayer_start(Operator):
 -    '''Launches the Blenderplayer with the current blendfile'''
 -    bl_idname = "wm.blenderplayer_start"
 -    bl_label = "Start"
 -    
 -    import os
 -    blender_bin_path = bpy.app.binary_path
 -    blender_bin_dir = os.path.dirname(blender_bin_path)
 -    ext = os.path.splitext(blender_bin_path)[-1]
 -    player_path = os.path.join(blender_bin_dir, 'blenderplayer' + ext)
 -    
 -    def execute(self, context):
 -        import sys
 -        import subprocess
 -        import os
 -
 -        if sys.platform == 'darwin':
 -            self.player_path = os.path.join(self.blender_bin_dir, '../../../blenderplayer.app/Contents/MacOS/blenderplayer')
 -      
 -        filepath = bpy.app.tempdir + "game.blend"
 -        bpy.ops.wm.save_as_mainfile(filepath=filepath, check_existing=False, copy=True)
 -        subprocess.call([self.player_path, filepath])
 -        return {'FINISHED'}
  
 -        
  class WM_OT_keyconfig_test(Operator):
      "Test keyconfig for conflicts"
      bl_idname = "wm.keyconfig_test"
@@@ -1451,7 -1475,7 +1451,7 @@@ class WM_OT_operator_cheat_sheet(Operat
  class WM_OT_addon_enable(Operator):
      "Enable an addon"
      bl_idname = "wm.addon_enable"
-     bl_label = "Enable Add-On"
+     bl_label = "Enable Addon"
  
      module = StringProperty(
              name="Module",
  class WM_OT_addon_disable(Operator):
      "Disable an addon"
      bl_idname = "wm.addon_disable"
-     bl_label = "Disable Add-On"
+     bl_label = "Disable Addon"
  
      module = StringProperty(
              name="Module",
  class WM_OT_addon_install(Operator):
      "Install an addon"
      bl_idname = "wm.addon_install"
-     bl_label = "Install Add-On..."
+     bl_label = "Install Addon..."
  
      overwrite = BoolProperty(
              name="Overwrite",
  class WM_OT_addon_remove(Operator):
      "Disable an addon"
      bl_idname = "wm.addon_remove"
-     bl_label = "Remove Add-On"
+     bl_label = "Remove Addon"
  
      module = StringProperty(
              name="Module",
  
  
  class WM_OT_addon_expand(Operator):
-     "Display more information on this add-on"
+     "Display more information on this addon"
      bl_idname = "wm.addon_expand"
      bl_label = ""
  
@@@ -41,6 -41,7 +41,6 @@@ def particle_panel_enabled(context, psy
  
  def particle_panel_poll(cls, context):
      psys = context.particle_system
 -    engine = context.scene.render.engine
      settings = 0
  
      if psys:
@@@ -51,7 -52,7 +51,7 @@@
      if not settings:
          return False
  
 -    return settings.is_fluid == False and (engine in cls.COMPAT_ENGINES)
 +    return settings.is_fluid == False
  
  
  def particle_get_settings(context):
@@@ -75,14 -76,21 +75,14 @@@ class ParticleButtonsPanel()
  class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
      bl_label = ""
      bl_options = {'HIDE_HEADER'}
 -    COMPAT_ENGINES = {'BLENDER_RENDER'}
 +    COMPAT_ENGINES = {'BLENDER_RENDER'}
  
      @classmethod
      def poll(cls, context):
 -        engine = context.scene.render.engine
 -        return (context.particle_system or context.object or context.space_data.pin_id)# and (engine in cls.COMPAT_ENGINES)
 +        return (context.particle_system or context.object or context.space_data.pin_id)
  
      def draw(self, context):
          layout = self.layout
 -        
 -        if context.scene.render.engine == "BLENDER_GAME":
 -            layout.label("The Blender particle system is")
 -            layout.label("not available for use in the")
 -            layout.label("Blender Game Engine")
 -            return
  
          ob = context.object
          psys = context.particle_system
              #row.label(text="Render")
  
              if part.is_fluid:
-                 layout.label(text=str(part.count) + " fluid particles for this frame")
+                 layout.label(text="{} fluid particles for this frame".format(str(part.count)))
                  return
  
              row = col.row()
@@@ -252,11 -260,12 +252,11 @@@ class PARTICLE_PT_hair_dynamics(Particl
      @classmethod
      def poll(cls, context):
          psys = context.particle_system
 -        engine = context.scene.render.engine
          if psys is None:
              return False
          if psys.settings is None:
              return False
 -        return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES)
 +        return psys.settings.type == 'HAIR'
  
      def draw_header(self, context):
          #cloth = context.cloth.collision_settings
@@@ -317,7 -326,7 +317,7 @@@ class PARTICLE_PT_cache(ParticleButtons
          phystype = psys.settings.physics_type
          if phystype == 'NO' or phystype == 'KEYED':
              return False
 -        return (psys.settings.type in {'EMITTER', 'REACTOR'} or (psys.settings.type == 'HAIR' and (psys.use_hair_dynamics or psys.point_cache.is_baked))) and engine in cls.COMPAT_ENGINES
 +        return (psys.settings.type in {'EMITTER', 'REACTOR'} or (psys.settings.type == 'HAIR' and (psys.use_hair_dynamics or psys.point_cache.is_baked)))
  
      def draw(self, context):
          psys = context.particle_system
@@@ -501,7 -510,7 +501,7 @@@ class PARTICLE_PT_physics(ParticleButto
                  col.label(text="Fluid properties:")
                  col.prop(fluid, "stiffness", text="Stiffness")
                  col.prop(fluid, "linear_viscosity", text="Viscosity")
-                 col.prop(fluid, "buoyancy", text="Buoancy", slider=True)
+                 col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
  
                  col = split.column()
                  col.label(text="Advanced:")
@@@ -660,12 -669,13 +660,12 @@@ class PARTICLE_PT_boidbrain(ParticleBut
      def poll(cls, context):
          psys = context.particle_system
          settings = particle_get_settings(context)
 -        engine = context.scene.render.engine
  
          if settings is None:
              return False
          if psys is not None and psys.point_cache.use_external:
              return False
 -        return settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES
 +        return settings.physics_type == 'BOIDS'
  
      def draw(self, context):
          layout = self.layout
@@@ -759,7 -769,11 +759,7 @@@ class PARTICLE_PT_render(ParticleButton
      @classmethod
      def poll(cls, context):
          settings = particle_get_settings(context)
 -        engine = context.scene.render.engine
 -        if settings is None:
 -            return False
 -
 -        return engine in cls.COMPAT_ENGINES
 +        return settings is not None
  
      def draw(self, context):
          layout = self.layout
@@@ -944,7 -958,10 +944,7 @@@ class PARTICLE_PT_draw(ParticleButtonsP
      @classmethod
      def poll(cls, context):
          settings = particle_get_settings(context)
 -        engine = context.scene.render.engine
 -        if settings is None:
 -            return False
 -        return engine in cls.COMPAT_ENGINES
 +        return settings is not None
  
      def draw(self, context):
          layout = self.layout
@@@ -1151,7 -1168,7 +1151,7 @@@ class PARTICLE_PT_force_fields(Particle
  
  
  class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
-     bl_label = "Vertexgroups"
+     bl_label = "Vertex Groups"
      bl_options = {'DEFAULT_CLOSED'}
      COMPAT_ENGINES = {'BLENDER_RENDER'}
  
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -96,6 -94,7 +94,6 @@@ static const char *locales[] = 
        "korean", "ko_KR",
        "nepali", "ne_NP",
        "persian", "fa_PE",
 -      "indonesian", "id_ID"
  };
  
  void BLF_lang_init(void)
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -326,14 -324,6 +324,14 @@@ struct DerivedMesh 
                                                                                                                           float t),
                                                                  void *userData);
  
 +      /* Draw all faces with materials
 +       *  o setMaterial is called for every different material nr
 +       *  o setFace is called to verify if a face must be hidden
 +       */
 +      void (*drawMappedFacesMat)(DerivedMesh *dm,
 +              void (*setMaterial)(void *userData, int, void *attribs),
 +              int (*setFace)(void *userData, int index), void *userData);
 +
        /* Release reference to the DerivedMesh. This function decides internally
         * if the DerivedMesh will be freed, or cached for later use. */
        void (*release)(DerivedMesh *dm);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -122,12 -120,6 +120,12 @@@ void     DAG_ids_flush_update(struct Main *
  void  DAG_id_tag_update(struct ID *id, short flag);
                /* flush all tagged updates */
  void  DAG_ids_flush_tagged(struct Main *bmain);
 +              /* check and clear ID recalc flags */
 +void  DAG_ids_check_recalc(struct Main *bmain);
 +void  DAG_ids_clear_recalc(struct Main *bmain);
 +              /* test if any of this id type is tagged for update */
 +void  DAG_id_type_tag(struct Main *bmain, short idtype);
 +int           DAG_id_type_tagged(struct Main *bmain, short idtype);
  
                /* (re)-create dependency graph for armature pose */
  void  DAG_pose_sort(struct Object *ob);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -215,10 -213,12 +213,10 @@@ struct FCurve *rna_get_fcurve(struct Po
  int binarysearch_bezt_index(struct BezTriple array[], float frame, int arraylen, short *replace);
  
  /* get the time extents for F-Curve */
 -void calc_fcurve_range(struct FCurve *fcu, float *min, float *max,
 -                       const short do_sel_only, const short do_min_length);
 +void calc_fcurve_range(struct FCurve *fcu, float *min, float *max, const short selOnly);
  
  /* get the bounding-box extents for F-Curve */
 -void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
 -                        const short do_sel_only);
 +void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, const short selOnly);
  
  /* .............. */
  
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$ 
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -63,7 -61,9 +61,7 @@@ int           BKE_imtype_is_movie(int imtype)
  struct anim *openanim(char * name, int flags, int streamindex);
  
  void  image_de_interlace(struct Image *ima, int odd);
 -
 -void  make_local_image(struct Image *ima);
 -
 +      
  void  tag_image_time(struct Image *ima);
  void  free_old_images(void);
  
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$ 
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -52,6 -50,7 +50,6 @@@ void *copy_libblock(void *rt)
  void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action);
  
  void id_lib_extern(struct ID *id);
 -void BKE_library_filepath_set(struct Library *lib, const char *filepath);
  void id_us_plus(struct ID *id);
  void id_us_min(struct ID *id);
  int id_make_local(struct ID *id, int test);
@@@ -60,6 -59,7 +58,6 @@@ int id_copy(struct ID *id, struct ID **
  int id_unlink(struct ID *id, int test);
  
  int new_id(struct ListBase *lb, struct ID *id, const char *name);
 -void id_clear_lib_data(struct ListBase *lb, struct ID *id);
  
  struct ListBase *which_libbase(struct Main *mainlib, short type);
  
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -85,7 -83,6 +83,7 @@@ typedef struct bNodeSocketTemplate 
        float val1, val2, val3, val4;   /* default alloc value for inputs */
        float min, max;
        PropertySubType subtype;
 +      int flag;
        
        /* after this line is used internal only */
        struct bNodeSocket *sock;               /* used to hold verified socket */
@@@ -133,7 -130,7 +131,7 @@@ typedef struct bNodeType 
        char name[32];
        float width, minwidth, maxwidth;
        float height, minheight, maxheight;
 -      short nclass, flag;
 +      short nclass, flag, compatibility;
        
        /* templates for static sockets */
        bNodeSocketTemplate *inputs, *outputs;
  #define NODE_CLASS_PARTICLES          25
  #define NODE_CLASS_TRANSFORM          30
  #define NODE_CLASS_COMBINE                    31
 +#define NODE_CLASS_SHADER                     40
  #define NODE_CLASS_LAYOUT                     100
  
 +/* nodetype->compatibility */
 +#define NODE_OLD_SHADING      1
 +#define NODE_NEW_SHADING      2
 +
  /* enum values for input/output */
  #define SOCK_IN               1
  #define SOCK_OUT      2
@@@ -351,7 -343,6 +349,7 @@@ struct bNode       *nodeGetActive(struct bNod
  struct bNode  *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
  int                           nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
  void                  nodeClearActiveID(struct bNodeTree *ntree, short idtype);
 +struct bNode  *nodeGetActiveTexture(struct bNodeTree *ntree);
  
  void                  nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
  int                           nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
@@@ -397,7 -388,6 +395,7 @@@ void                       node_type_exec_new(struct bNodeT
                                                                   void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **));
  void                  node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out));
  void                  node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out));
 +void                  node_type_compatibility(struct bNodeType *ntype, short compatibility);
  
  /* ************** COMMON NODES *************** */
  
@@@ -442,7 -432,7 +440,7 @@@ struct ShadeResult
  #define SH_NODE_RGBTOBW               105
  #define SH_NODE_TEXTURE               106
  #define SH_NODE_NORMAL                107
 -#define SH_NODE_GEOMETRY      108
 +#define SH_NODE_GEOM          108
  #define SH_NODE_MAPPING               109
  #define SH_NODE_CURVE_VEC     110
  #define SH_NODE_CURVE_RGB     111
  #define SH_NODE_HUE_SAT               122
  #define NODE_DYNAMIC          123
  
 +#define SH_NODE_OUTPUT_MATERIAL                       124
 +#define SH_NODE_OUTPUT_WORLD                  125
 +#define SH_NODE_OUTPUT_LAMP                           126
 +#define SH_NODE_FRESNEL                                       127
 +#define SH_NODE_MIX_SHADER                            128
 +#define SH_NODE_ATTRIBUTE                             129
 +#define SH_NODE_BACKGROUND                            130
 +#define SH_NODE_BSDF_ANISOTROPIC              131
 +#define SH_NODE_BSDF_DIFFUSE                  132
 +#define SH_NODE_BSDF_GLOSSY                           133
 +#define SH_NODE_BSDF_GLASS                            134
 +#define SH_NODE_BSDF_TRANSLUCENT              137
 +#define SH_NODE_BSDF_TRANSPARENT              138
 +#define SH_NODE_BSDF_VELVET                           139
 +#define SH_NODE_EMISSION                              140
 +#define SH_NODE_GEOMETRY                              141
 +#define SH_NODE_LIGHT_PATH                            142
 +#define SH_NODE_TEX_IMAGE                             143
 +#define SH_NODE_TEX_NOISE                             144
 +#define SH_NODE_TEX_SKY                                       145
 +#define SH_NODE_TEX_BLEND                             146
 +#define SH_NODE_TEX_VORONOI                           147
 +#define SH_NODE_TEX_MAGIC                             148
 +#define SH_NODE_TEX_MARBLE                            149
 +#define SH_NODE_TEX_CLOUDS                            150
 +#define SH_NODE_TEX_WOOD                              151
 +#define SH_NODE_TEX_MUSGRAVE                  152
 +#define SH_NODE_TEX_STUCCI                            153
 +#define SH_NODE_TEX_DISTNOISE                 154
 +#define SH_NODE_TEX_COORD                             155
 +#define SH_NODE_ADD_SHADER                            156
 +#define SH_NODE_TEX_ENVIRONMENT                       157
 +#define SH_NODE_OUTPUT_TEXTURE                        158
 +#define SH_NODE_HOLDOUT                                       159
 +#define SH_NODE_BLEND_WEIGHT                  160
 +#define SH_NODE_VOLUME_TRANSPARENT            161
 +#define SH_NODE_VOLUME_ISOTROPIC              162
 +
  /* custom defines options for Material node */
  #define SH_NODE_MAT_DIFF   1
  #define SH_NODE_MAT_SPEC   2
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$ 
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -90,8 -88,6 +88,8 @@@ int scene_check_setscene(struct Main *b
  float BKE_curframe(struct Scene *scene);
  
  void scene_update_tagged(struct Main *bmain, struct Scene *sce);
 +void scene_clear_tagged(struct Main *bmain, struct Scene *sce);
 +
  void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay);
  
  void scene_add_render_layer(struct Scene *sce);
@@@ -102,8 -98,6 +100,8 @@@ int get_render_child_particle_number(st
  int get_render_shadow_samples(struct RenderData *r, int samples);
  float get_render_aosss_error(struct RenderData *r, float error);
  
 +int scene_use_new_shading_nodes(struct Scene *scene);
 +
  #ifdef __cplusplus
  }
  #endif
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -217,9 -215,7 +215,9 @@@ typedef enum 
        SEQ_STRIPELEM_IBUF_ENDSTILL
  } seq_stripelem_ibuf_t;
  
 +void seq_stripelem_cache_init(void);
  void seq_stripelem_cache_destruct(void);
 +
  void seq_stripelem_cache_cleanup(void);
  
  /* returned ImBuf is properly refed and has to be freed */
@@@ -1,4 -1,3 +1,3 @@@
- # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
  #
  # ***** END GPL LICENSE BLOCK *****
  
 +if(WITH_CODEC_FFMPEG)
 +      # FFMPEG gives warnigns which are hard to avoid across multiple versions.
 +      remove_strict_flags()
 +endif()
 +
  set(INC 
        .
        ../avi
@@@ -305,6 -299,10 +304,6 @@@ if(WITH_CODEC_FFMPEG
                ${FFMPEG_INCLUDE_DIRS}
        )
        add_definitions(-DWITH_FFMPEG)
 -
 -      remove_strict_flags_file(
 -              intern/writeffmpeg.c
 -      )
  endif()
  
  if(WITH_PYTHON)
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -1125,140 -1123,6 +1123,140 @@@ static void emDM_drawFacesGLSL(DerivedM
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
  }
  
 +static void emDM_drawMappedFacesMat(DerivedMesh *dm,
 +                         void (*setMaterial)(void *userData, int, void *attribs),
 +                         int (*setFace)(void *userData, int index), void *userData) 
 +{
 +      EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
 +      EditMesh *em= emdm->em;
 +      float (*vertexCos)[3]= emdm->vertexCos;
 +      float (*vertexNos)[3]= emdm->vertexNos;
 +      EditVert *eve;
 +      EditFace *efa;
 +      DMVertexAttribs attribs= {{{0}}};
 +      GPUVertexAttribs gattribs;
 +      int i, b, matnr, new_matnr;
 +
 +      matnr = -1;
 +
 +      /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
 +      glShadeModel(GL_SMOOTH);
 +
 +      for (i=0,eve=em->verts.first; eve; eve= eve->next)
 +              eve->tmp.l = (intptr_t) i++;
 +
 +#define PASSATTRIB(efa, eve, vert) {                                                                                  \
 +      if(attribs.totorco) {                                                                                                           \
 +              float *orco = attribs.orco.array[eve->tmp.l];                                                   \
 +              if(attribs.orco.glTexco)                                                                                                \
 +                      glTexCoord3fv(orco);                                                                                            \
 +              else                                                                                                                                    \
 +                      glVertexAttrib3fvARB(attribs.orco.glIndex, orco);                                       \
 +      }                                                                                                                                                       \
 +      for(b = 0; b < attribs.tottface; b++) {                                                                         \
 +              MTFace *_tf = (MTFace*)((char*)efa->data + attribs.tface[b].emOffset);  \
 +              if(attribs.tface[b].glTexco)                                                                                    \
 +                      glTexCoord2fv(_tf->uv[vert]);                                                                           \
 +              else                                                                                                                                    \
 +                      glVertexAttrib2fvARB(attribs.tface[b].glIndex, _tf->uv[vert]);          \
 +      }                                                                                                                                                       \
 +      for(b = 0; b < attribs.totmcol; b++) {                                                                          \
 +              MCol *cp = (MCol*)((char*)efa->data + attribs.mcol[b].emOffset);                \
 +              GLubyte col[4];                                                                                                                 \
 +              col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;                             \
 +              glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col);                                    \
 +      }                                                                                                                                                       \
 +      if(attribs.tottang) {                                                                                                           \
 +              float *tang = attribs.tang.array[i*4 + vert];                                                   \
 +              glVertexAttrib4fvARB(attribs.tang.glIndex, tang);                                               \
 +      }                                                                                                                                                       \
 +}
 +
 +      for (i=0,efa= em->faces.first; efa; i++,efa= efa->next) {
 +              int drawSmooth= (efa->flag & ME_SMOOTH);
 +
 +              /* face hiding */
 +              if(setFace && !setFace(userData, i))
 +                      continue;
 +
 +              /* material */
 +              new_matnr = efa->mat_nr + 1;
 +              if(new_matnr != matnr) {
 +                      setMaterial(userData, matnr = new_matnr, &gattribs);
 +                      DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
 +              }
 +
 +              /* face */
 +              glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
 +              if (!drawSmooth) {
 +                      if(vertexCos) glNormal3fv(emdm->faceNos[i]);
 +                      else glNormal3fv(efa->n);
 +
 +                      PASSATTRIB(efa, efa->v1, 0);
 +                      if(vertexCos) glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
 +                      else glVertex3fv(efa->v1->co);
 +
 +                      PASSATTRIB(efa, efa->v2, 1);
 +                      if(vertexCos) glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
 +                      else glVertex3fv(efa->v2->co);
 +
 +                      PASSATTRIB(efa, efa->v3, 2);
 +                      if(vertexCos) glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
 +                      else glVertex3fv(efa->v3->co);
 +
 +                      if(efa->v4) {
 +                              PASSATTRIB(efa, efa->v4, 3);
 +                              if(vertexCos) glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
 +                              else glVertex3fv(efa->v4->co);
 +                      }
 +              } else {
 +                      PASSATTRIB(efa, efa->v1, 0);
 +                      if(vertexCos) {
 +                              glNormal3fv(vertexNos[(int) efa->v1->tmp.l]);
 +                              glVertex3fv(vertexCos[(int) efa->v1->tmp.l]);
 +                      }
 +                      else {
 +                              glNormal3fv(efa->v1->no);
 +                              glVertex3fv(efa->v1->co);
 +                      }
 +
 +                      PASSATTRIB(efa, efa->v2, 1);
 +                      if(vertexCos) {
 +                              glNormal3fv(vertexNos[(int) efa->v2->tmp.l]);
 +                              glVertex3fv(vertexCos[(int) efa->v2->tmp.l]);
 +                      }
 +                      else {
 +                              glNormal3fv(efa->v2->no);
 +                              glVertex3fv(efa->v2->co);
 +                      }
 +
 +                      PASSATTRIB(efa, efa->v3, 2);
 +                      if(vertexCos) {
 +                              glNormal3fv(vertexNos[(int) efa->v3->tmp.l]);
 +                              glVertex3fv(vertexCos[(int) efa->v3->tmp.l]);
 +                      }
 +                      else {
 +                              glNormal3fv(efa->v3->no);
 +                              glVertex3fv(efa->v3->co);
 +                      }
 +
 +                      if(efa->v4) {
 +                              PASSATTRIB(efa, efa->v4, 3);
 +                              if(vertexCos) {
 +                                      glNormal3fv(vertexNos[(int) efa->v4->tmp.l]);
 +                                      glVertex3fv(vertexCos[(int) efa->v4->tmp.l]);
 +                              }
 +                              else {
 +                                      glNormal3fv(efa->v4->no);
 +                                      glVertex3fv(efa->v4->co);
 +                              }
 +                      }
 +              }
 +              glEnd();
 +      }
 +#undef PASSATTRIB
 +}
 +
  static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
  {
        EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
@@@ -1565,7 -1429,6 +1563,7 @@@ DerivedMesh *editmesh_get_derived(EditM
        emdm->dm.drawMappedFacesGLSL = emDM_drawMappedFacesGLSL;
        emdm->dm.drawFacesTex = emDM_drawFacesTex;
        emdm->dm.drawFacesGLSL = emDM_drawFacesGLSL;
 +      emdm->dm.drawMappedFacesMat = emDM_drawMappedFacesMat;
        emdm->dm.drawUVEdges = emDM_drawUVEdges;
  
        emdm->dm.release = emDM_release;
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -139,19 -137,14 +137,19 @@@ void make_local_action(bAction *act
        
        // XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default
        if ((act->id.flag & LIB_FAKEUSER) && (act->id.us<=1)) {
 -              id_clear_lib_data(&bmain->action, (ID *)act);
 +              act->id.lib= NULL;
 +              act->id.flag= LIB_LOCAL;
 +              new_id(&bmain->action, (ID *)act, NULL);
                return;
        }
        
        BKE_animdata_main_cb(bmain, make_localact_init_cb, &mlac);
        
        if (mlac.local && mlac.lib==0) {
 -              id_clear_lib_data(&bmain->action, (ID *)act);
 +              act->id.lib= NULL;
 +              act->id.flag= LIB_LOCAL;
 +              //make_local_action_channels(act);
 +              new_id(&bmain->action, (ID *)act, NULL);
        }
        else if (mlac.local && mlac.lib) {
                mlac.actn= copy_action(act);
@@@ -883,7 -876,7 +881,7 @@@ void calc_action_range(const bAction *a
                                
                                /* get extents for this curve */
                                // TODO: allow enabling/disabling this?
 -                              calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE);
 +                              calc_fcurve_range(fcu, &nmin, &nmax, FALSE);
                                
                                /* compare to the running tally */
                                min= MIN2(min, nmin);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
  #include "BLI_utildefines.h"
  
  #include "DNA_anim_types.h"
 +#include "DNA_lamp_types.h"
  #include "DNA_material_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_texture_types.h"
 +#include "DNA_world_types.h"
  
  #include "BKE_animsys.h"
  #include "BKE_action.h"
@@@ -2295,7 -2291,7 +2293,7 @@@ void BKE_animsys_evaluate_all_animatio
        EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM);
        
        /* lamps */
 -      EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM);
 +      EVAL_ANIM_NODETREE_IDS(main->lamp.first, Lamp, ADT_RECALC_ANIM);
        
        /* materials */
        EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM);
        EVAL_ANIM_IDS(main->object.first, 0); 
        
        /* worlds */
 -      EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM);
 +      EVAL_ANIM_NODETREE_IDS(main->world.first, World, ADT_RECALC_ANIM);
        
        /* scenes */
        EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -143,9 -141,7 +141,9 @@@ void make_local_armature(bArmature *arm
  
        if (arm->id.lib==NULL) return;
        if (arm->id.us==1) {
 -              id_clear_lib_data(&bmain->armature, (ID *)arm);
 +              arm->id.lib= NULL;
 +              arm->id.flag= LIB_LOCAL;
 +              new_id(&bmain->armature, (ID*)arm, NULL);
                return;
        }
  
        }
  
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->armature, (ID *)arm);
 +              arm->id.lib= NULL;
 +              arm->id.flag= LIB_LOCAL;
 +              new_id(&bmain->armature, (ID *)arm, NULL);
        }
        else if(local && lib) {
                bArmature *armn= copy_armature(arm);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -63,6 -61,7 +61,6 @@@
  #include "BLI_callbacks.h"
  
  #include "IMB_imbuf.h"
 -#include "IMB_moviecache.h"
  
  #include "BKE_blender.h"
  #include "BKE_context.h"
@@@ -113,6 -112,7 +111,6 @@@ void free_blender(void
        BLI_cb_finalize();
  
        seq_stripelem_cache_destruct();
 -      IMB_moviecache_destruct();
        
        free_nodesystem();      
  }
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -183,6 -181,7 +181,6 @@@ void free_brush(Brush *brush
  static void extern_local_brush(Brush *brush)
  {
        id_lib_extern((ID *)brush->mtex.tex);
 -      id_lib_extern((ID *)brush->clone.image);
  }
  
  void make_local_brush(Brush *brush)
        if(brush->id.lib==NULL) return;
  
        if(brush->clone.image) {
 -              /* special case: ima always local immediately. Clone image should only
 -                 have one user anyway. */
 -              id_clear_lib_data(&bmain->brush, (ID *)brush->clone.image);
 +              /* special case: ima always local immediately */
 +              brush->clone.image->id.lib= NULL;
 +              brush->clone.image->id.flag= LIB_LOCAL;
 +              new_id(&bmain->brush, (ID *)brush->clone.image, NULL);
                extern_local_brush(brush);
        }
  
        }
  
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->brush, (ID *)brush);
 +              brush->id.lib= NULL;
 +              brush->id.flag= LIB_LOCAL;
 +              new_id(&bmain->brush, (ID *)brush, NULL);
                extern_local_brush(brush);
  
                /* enable fake user by default */
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -1353,85 -1351,6 +1351,85 @@@ static void cdDM_drawFacesGLSL(DerivedM
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
  }
  
 +static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
 +      void (*setMaterial)(void *userData, int, void *attribs),
 +      int (*setFace)(void *userData, int index), void *userData)
 +{
 +      CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
 +      GPUVertexAttribs gattribs;
 +      DMVertexAttribs attribs;
 +      MVert *mvert = cddm->mvert;
 +      MFace *mf = cddm->mface;
 +      float (*nors)[3] = dm->getFaceDataArray(dm, CD_NORMAL);
 +      int a, matnr, new_matnr;
 +      int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX);
 +
 +      cdDM_update_normals_from_pbvh(dm);
 +
 +      matnr = -1;
 +
 +      glShadeModel(GL_SMOOTH);
 +
 +      memset(&attribs, 0, sizeof(attribs));
 +
 +      glBegin(GL_QUADS);
 +
 +      for(a = 0; a < dm->numFaceData; a++, mf++) {
 +              const int smoothnormal = (mf->flag & ME_SMOOTH);
 +
 +              /* material */
 +              new_matnr = mf->mat_nr + 1;
 +
 +              if(new_matnr != matnr) {
 +                      glEnd();
 +
 +                      setMaterial(userData, matnr = new_matnr, &gattribs);
 +                      DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
 +
 +                      glBegin(GL_QUADS);
 +              }
 +
 +              /* skipping faces */
 +              if(setFace) {
 +                      orig = (index)? index[a]: a;
 +
 +                      if(orig != ORIGINDEX_NONE && !setFace(userData, orig))
 +                              continue;
 +              }
 +
 +              /* smooth normal */
 +              if(!smoothnormal) {
 +                      if(nors) {
 +                              glNormal3fv(nors[a]);
 +                      }
 +                      else {
 +                              /* TODO ideally a normal layer should always be available */
 +                              float nor[3];
 +
 +                              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);
 +
 +                              glNormal3fv(nor);
 +                      }
 +              }
 +
 +              /* vertices */
 +              cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v1, 0, smoothnormal);
 +              cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v2, 1, smoothnormal);
 +              cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
 +
 +              if(mf->v4)
 +                      cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v4, 3, smoothnormal);
 +              else
 +                      cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
 +      }
 +      glEnd();
 +
 +      glShadeModel(GL_FLAT);
 +}
 +
  static void cdDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
  {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
@@@ -1602,7 -1521,6 +1600,7 @@@ static CDDerivedMesh *cdDM_create(cons
        dm->drawMappedFaces = cdDM_drawMappedFaces;
        dm->drawMappedFacesTex = cdDM_drawMappedFacesTex;
        dm->drawMappedFacesGLSL = cdDM_drawMappedFacesGLSL;
 +      dm->drawMappedFacesMat = cdDM_drawMappedFacesMat;
  
        dm->foreachMappedVert = cdDM_foreachMappedVert;
        dm->foreachMappedEdge = cdDM_foreachMappedEdge;
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -257,10 -255,7 +255,10 @@@ void make_local_curve(Curve *cu
        if(cu->id.lib==NULL) return;
  
        if(cu->id.us==1) {
 -              id_clear_lib_data(&bmain->curve, (ID *)cu);
 +              cu->id.lib= NULL;
 +              cu->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->curve, (ID *)cu, NULL);
                extern_local_curve(cu);
                return;
        }
        }
  
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->curve, (ID *)cu);
 +              cu->id.lib= NULL;
 +              cu->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->curve, (ID *)cu, NULL);
                extern_local_curve(cu);
        }
        else if(local && lib) {
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -1763,22 -1761,9 +1761,22 @@@ void DAG_scene_sort(Main *bmain, Scene 
        sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */
  }
  
 +static void lib_id_recalc_tag(Main *bmain, ID *id)
 +{
 +      id->flag |= LIB_ID_RECALC;
 +      bmain->id_tag_update[id->name[0]] = 1;
 +}
 +
 +static void lib_id_recalc_data_tag(Main *bmain, ID *id)
 +{
 +      id->flag |= LIB_ID_RECALC_DATA;
 +      bmain->id_tag_update[id->name[0]] = 1;
 +}
 +
  /* node was checked to have lasttime != curtime and is if type ID_OB */
  static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
  {
 +      Main *bmain= G.main;
        DagAdjList *itA;
        Object *ob, *obc;
        int oldflag, changed=0;
                                                if(itA->type & DAG_RL_OB_OB) {
                                                        //printf("ob %s changes ob %s\n", ob->id.name, obc->id.name);
                                                        obc->recalc |= OB_RECALC_OB;
 +                                                      lib_id_recalc_tag(bmain, &obc->id);
                                                }
                                                if(itA->type & DAG_RL_OB_DATA) {
                                                        //printf("ob %s changes obdata %s\n", ob->id.name, obc->id.name);
                                                        obc->recalc |= OB_RECALC_DATA;
 +                                                      lib_id_recalc_data_tag(bmain, &obc->id);
                                                }
                                        }
                                        if(ob->recalc & OB_RECALC_DATA) {
                                                if(itA->type & DAG_RL_DATA_OB) {
                                                        //printf("obdata %s changes ob %s\n", ob->id.name, obc->id.name);
                                                        obc->recalc |= OB_RECALC_OB;
 +                                                      lib_id_recalc_tag(bmain, &obc->id);
                                                }
                                                if(itA->type & DAG_RL_DATA_DATA) {
                                                        //printf("obdata %s changes obdata %s\n", ob->id.name, obc->id.name);
                                                        obc->recalc |= OB_RECALC_DATA;
 +                                                      lib_id_recalc_data_tag(bmain, &obc->id);
                                                }
                                        }
                                        if(oldflag!=obc->recalc) changed= 1;
                                        if(itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) {
                                                // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name);
                                                obc->recalc |= OB_RECALC_DATA;
 +                                              lib_id_recalc_data_tag(bmain, &obc->id);
                                        }
                                }
                        }
@@@ -1892,7 -1872,6 +1890,7 @@@ static unsigned int flush_layer_node(Sc
  /* node was checked to have lasttime != curtime , and is of type ID_OB */
  static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset)
  {
 +      Main *bmain= G.main;
        DagAdjList *itA;
        Object *ob;
        
                                ob= (Object*)(itA->node->ob);
  
                                if(reset || (ob->recalc & OB_RECALC_ALL)) {
 -                                      if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
 +                                      if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) {
                                                ob->recalc |= OB_RECALC_DATA;
 +                                              lib_id_recalc_data_tag(bmain, &ob->id);
 +                                      }
  
                                        flush_pointcache_reset(scene, itA->node, curtime, 1);
                                }
@@@ -2024,10 -2001,8 +2022,10 @@@ void DAG_scene_flush_update(Main *bmain
                                ob= (Object*)(itA->node->ob);
  
                                if(ob->recalc & OB_RECALC_ALL) {
 -                                      if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH))
 +                                      if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) {
                                                ob->recalc |= OB_RECALC_DATA;
 +                                              lib_id_recalc_data_tag(bmain, &ob->id);
 +                                      }
  
                                        flush_pointcache_reset(sce, itA->node, lasttime, 1);
                                }
@@@ -2229,12 -2204,6 +2227,12 @@@ static void dag_object_time_update_flag
                        }
                }
        }               
 +
 +      if(ob->recalc & OB_RECALC_OB)
 +              lib_id_recalc_tag(G.main, &ob->id);
 +      if(ob->recalc & OB_RECALC_DATA)
 +              lib_id_recalc_data_tag(G.main, &ob->id);
 +
  }
  /* flag all objects that need recalc, for changes in time for example */
  /* do_time: make this optional because undo resets objects to their animated locations without this */
@@@ -2393,9 -2362,6 +2391,9 @@@ void DAG_on_visible_update(Main *bmain
                DAG_scene_update_flags(bmain, scene, lay, do_time);
                scene->lay_updated |= lay;
        }
 +
 +      /* hack to get objects updating on layer changes */
 +      DAG_id_type_tag(bmain, ID_OB);
  }
  
  static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUSED(ob), ID **idpoin)
@@@ -2442,7 -2408,6 +2440,7 @@@ static void dag_id_flush_update(Scene *
                        for(obt=bmain->object.first; obt; obt= obt->id.next) {
                                if(!(ob && obt == ob) && obt->data == id) {
                                        obt->recalc |= OB_RECALC_DATA;
 +                                      lib_id_recalc_data_tag(bmain, &obt->id);
                                        BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
                                }
                        }
                                data.is_dependent= 0;
  
                                modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data);
 -                              if (data.is_dependent)
 +                              if (data.is_dependent) {
                                        obt->recalc |= OB_RECALC_DATA;
 +                                      lib_id_recalc_data_tag(bmain, &obt->id);
 +                              }
  
                                /* particle settings can use the texture as well */
                                if(obt->particlesystem.first) {
                                                        mtex = *mtexp;
                                                        if(mtex && mtex->tex == (Tex*)id) {
                                                                obt->recalc |= OB_RECALC_DATA;
 -                                                              
 +                                                              lib_id_recalc_data_tag(bmain, &obt->id);
 +
                                                                if(mtex->mapto & PAMAP_INIT)
                                                                        psys->recalc |= PSYS_RECALC_RESET;
                                                                if(mtex->mapto & PAMAP_CHILD)
                                Key *key= ob_get_key(obt);
                                if(!(ob && obt == ob) && ((ID *)key == id)) {
                                        obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA);
 +                                      lib_id_recalc_tag(bmain, &obt->id);
 +                                      lib_id_recalc_data_tag(bmain, &obt->id);
                                        BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
                                }
                        }
@@@ -2519,7 -2479,7 +2517,7 @@@ void DAG_ids_flush_tagged(Main *bmain
        ListBase *lbarray[MAX_LIBARRAY];
        Scene *sce;
        unsigned int lay;
 -      int a, have_tag = 0;
 +      int a, do_flush = 0;
  
        dag_current_scene_layers(bmain, &sce, &lay);
  
                   looping over all ID's in case there are no tags */
                if(id && bmain->id_tag_update[id->name[0]]) {
                        for(; id; id=id->next) {
 -                              if(id->flag & LIB_ID_RECALC) {
 +                              if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) {
                                        dag_id_flush_update(sce, id);
 -                                      id->flag &= ~LIB_ID_RECALC;
 +                                      do_flush = 1;
                                }
                        }
 +              }
 +      }
 +
 +      /* flush changes to other objects */
 +      if(do_flush)
 +              DAG_scene_flush_update(bmain, sce, lay, 0);
 +}
 +
 +void DAG_ids_check_recalc(Main *bmain)
 +{
 +      ListBase *lbarray[MAX_LIBARRAY];
 +      int a;
 +
 +      /* loop over all ID types */
 +      a  = set_listbasepointers(bmain, lbarray);
 +
 +      while(a--) {
 +              ListBase *lb = lbarray[a];
 +              ID *id = lb->first;
  
 -                      have_tag = 1;
 +              /* we tag based on first ID type character to avoid 
 +                 looping over all ID's in case there are no tags */
 +              if(id && bmain->id_tag_update[id->name[0]]) {
 +                      /* do editors update */
 +                      dag_editors_update(bmain, NULL);
 +                      return;
                }
        }
 +}
  
 -      if(have_tag) {
 -              /* clear tags */
 -              memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update));
  
 -              /* flush changes to other objects */
 -              DAG_scene_flush_update(bmain, sce, lay, 0);
 +void DAG_ids_clear_recalc(Main *bmain)
 +{
 +      ListBase *lbarray[MAX_LIBARRAY];
 +      int a;
 +
 +      /* loop over all ID types */
 +      a  = set_listbasepointers(bmain, lbarray);
 +
 +      while(a--) {
 +              ListBase *lb = lbarray[a];
 +              ID *id = lb->first;
 +
 +              /* we tag based on first ID type character to avoid 
 +                 looping over all ID's in case there are no tags */
 +              if(id && bmain->id_tag_update[id->name[0]]) {
 +                      for(; id; id=id->next)
 +                              if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA))
 +                                      id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
 +              }
        }
 +
 +      memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update));
  }
  
  void DAG_id_tag_update(ID *id, short flag)
        if(id==NULL) return;
        
        /* tag ID for update */
 -      id->flag |= LIB_ID_RECALC;
 -      bmain->id_tag_update[id->name[0]] = 1;
 +      if(flag) {
 +              if(flag & OB_RECALC_OB)
 +                      lib_id_recalc_tag(bmain, id);
 +              if(flag & (OB_RECALC_DATA|PSYS_RECALC))
 +                      lib_id_recalc_data_tag(bmain, id);
 +      }
 +      else
 +              lib_id_recalc_tag(bmain, id);
  
        /* flag is for objects and particle systems */
        if(flag) {
        }
  }
  
 +void DAG_id_type_tag(struct Main *bmain, short idtype)
 +{
 +      bmain->id_tag_update[((char*)&idtype)[0]] = 1;
 +}
 +
 +int DAG_id_type_tagged(Main *bmain, short idtype)
 +{
 +      return bmain->id_tag_update[((char*)&idtype)[0]];
 +}
 +
  #if 0 // UNUSED
  /* recursively descends tree, each node only checked once */
  /* node is checked to be of type object */
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -435,7 -433,8 +433,7 @@@ int binarysearch_bezt_index (BezTriple 
  /* ...................................... */
  
  /* helper for calc_fcurve_* functions -> find first and last BezTriple to be used */
 -static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last,
 -                                      const short do_sel_only)
 +static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last, const short selOnly)
  {
        /* init outputs */
        *first = NULL;
                return;
        
        /* only include selected items? */
 -      if (do_sel_only) {
 +      if (selOnly) {
                BezTriple *bezt;
                unsigned int i;
                
  
  
  /* Calculate the extents of F-Curve's data */
 -void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
 -                         const short do_sel_only)
 +void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, const short selOnly)
  {
        float xminv=999999999.0f, xmaxv=-999999999.0f;
        float yminv=999999999.0f, ymaxv=-999999999.0f;
 -      short foundvert= FALSE;
 +      short foundvert=0;
        unsigned int i;
        
        if (fcu->totvert) {
                        
                        if (xmin || xmax) {
                                /* get endpoint keyframes */
 -                              get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
 +                              get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, selOnly);
                                
                                if (bezt_first) {
                                        BLI_assert(bezt_last != NULL);
                                BezTriple *bezt;
                                
                                for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
 -                                      if ((do_sel_only == 0) || BEZSELECTED(bezt)) {
 +                                      if ((selOnly == 0) || BEZSELECTED(bezt)) {
                                                if (bezt->vec[1][1] < yminv)
                                                        yminv= bezt->vec[1][1];
                                                if (bezt->vec[1][1] > ymaxv)
                                                        ymaxv= bezt->vec[1][1];
 -                                              foundvert= TRUE;
                                        }
                                }
                        }
                                                yminv= fpt->vec[1];
                                        if (fpt->vec[1] > ymaxv)
                                                ymaxv= fpt->vec[1];
 -
 -                                      foundvert= TRUE;
                                }
                        }
                }
 +              
 +              foundvert=1;
        }
        
        if (foundvert) {
  }
  
  /* Calculate the extents of F-Curve's keyframes */
 -void calc_fcurve_range (FCurve *fcu, float *start, float *end,
 -                        const short do_sel_only, const short do_min_length)
 +void calc_fcurve_range (FCurve *fcu, float *start, float *end, const short selOnly)
  {
        float min=999999999.0f, max=-999999999.0f;
 -      short foundvert= FALSE;
 +      short foundvert=0;
  
        if (fcu->totvert) {
                if (fcu->bezt) {
                        BezTriple *bezt_first= NULL, *bezt_last= NULL;
                        
                        /* get endpoint keyframes */
 -                      get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
 -
 +                      get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, selOnly);
 +                      
                        if (bezt_first) {
                                BLI_assert(bezt_last != NULL);
 -
 +                              
                                min= MIN2(min, bezt_first->vec[1][0]);
                                max= MAX2(max, bezt_last->vec[1][0]);
 -
 -                              foundvert= TRUE;
                        }
                }
                else if (fcu->fpt) {
                        min= MIN2(min, fcu->fpt[0].vec[0]);
                        max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]);
 -
 -                      foundvert= TRUE;
                }
                
 +              foundvert=1;
        }
        
 -      if (foundvert == FALSE) {
 -              min= max= 0.0f;
 +      /* minimum length is 1 frame */
 +      if (foundvert) {
 +              if (min == max) max += 1.0f;
 +              *start= min;
 +              *end= max;
        }
 -
 -      if (do_min_length) {
 -              /* minimum length is 1 frame */
 -              if (min == max) {
 -                      max += 1.0f;
 -              }
 +      else {
 +              *start= 0.0f;
 +              *end= 1.0f;
        }
 -
 -      *start= min;
 -      *end= max;
  }
  
  /* ----------------- Status Checks -------------------------- */
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
  #include "DNA_camera_types.h"
  #include "DNA_sequence_types.h"
  #include "DNA_userdef_types.h"
 -#include "DNA_brush_types.h"
 -#include "DNA_mesh_types.h"
 -#include "DNA_meshdata_types.h"
  
  #include "BLI_blenlib.h"
  #include "BLI_threads.h"
  #include "BLI_utildefines.h"
 -#include "BLI_bpath.h"
  
  #include "BKE_bmfont.h"
  #include "BKE_global.h"
@@@ -315,6 -317,132 +313,6 @@@ Image *copy_image(Image *ima
        return nima;
  }
  
 -static void extern_local_image(Image *UNUSED(ima))
 -{
 -      /* Nothing to do: images don't link to other IDs. This function exists to
 -         match id_make_local pattern. */
 -}
 -
 -void make_local_image(struct Image *ima) {
 -      Main *bmain= G.main;
 -      Tex *tex;
 -      Brush *brush;
 -      Mesh *me;
 -      int local=0, lib=0;
 -
 -      /* - only lib users: do nothing
 -       * - only local users: set flag
 -       * - mixed: make copy
 -       */
 -
 -      if(ima->id.lib==NULL) return;
 -
 -      /* Can't take short cut here: must check meshes at least because of bogus
 -         texface ID refs. - z0r */
 -#if(0)
 -      if(ima->id.us==1) {
 -              id_clear_lib_data(&bmain->image, (ID *)ima);
 -              extern_local_image(ima);
 -              return;
 -      }
 -#endif
 -
 -      for(tex= bmain->tex.first; tex; tex= tex->id.next) {
 -              if(tex->ima == ima) {
 -                      if(tex->id.lib) lib= 1;
 -                      else local= 1;
 -              }
 -      }
 -      for(brush= bmain->brush.first; brush; brush= brush->id.next) {
 -              if(brush->clone.image == ima) {
 -                      if(brush->id.lib) lib= 1;
 -                      else local= 1;
 -              }
 -      }
 -      for(me= bmain->mesh.first; me; me= me->id.next) {
 -              if(me->mtface) {
 -                      MTFace *tface;
 -                      int a, i;
 -
 -                      for(i=0; i<me->fdata.totlayer; i++) {
 -                              if(me->fdata.layers[i].type == CD_MTFACE) {
 -                                      tface= (MTFace*)me->fdata.layers[i].data;
 -
 -                                      for(a=0; a<me->totface; a++, tface++) {
 -                                              if(tface->tpage == ima) {
 -                                                      if(me->id.lib) lib=1;
 -                                                      else local= 1;
 -                                              }
 -                                      }
 -                              }
 -                      }
 -              }
 -      }
 -
 -      if(local && lib==0) {
 -              id_clear_lib_data(&bmain->image, (ID *)ima);
 -              extern_local_image(ima);
 -      }
 -      else if(local && lib) {
 -              Image *iman= copy_image(ima);
 -              iman->id.us= 0;
 -
 -              /* Remap paths of new ID using old library as base. */
 -              bpath_traverse_id((ID *)iman, bpath_relocate_visitor,
 -                                   ((ID *)ima)->lib->filepath);
 -
 -              tex= bmain->tex.first;
 -              while(tex) {
 -                      if(tex->id.lib==NULL) {
 -                              if(tex->ima==ima) {
 -                                      tex->ima = iman;
 -                                      iman->id.us++;
 -                                      ima->id.us--;
 -                              }
 -                      }
 -                      tex= tex->id.next;
 -              }
 -              brush= bmain->brush.first;
 -              while(brush) {
 -                      if(brush->id.lib==NULL) {
 -                              if(brush->clone.image==ima) {
 -                                      brush->clone.image = iman;
 -                                      iman->id.us++;
 -                                      ima->id.us--;
 -                              }
 -                      }
 -                      brush= brush->id.next;
 -              }
 -              /* Transfer references in texfaces. Texfaces don't add to image ID
 -                 user count *unless* there are no other users. See
 -                 readfile.c:lib_link_mtface. */
 -              me= bmain->mesh.first;
 -              while(me) {
 -                      if(me->mtface) {
 -                              MTFace *tface;
 -                              int a, i;
 -
 -                              for(i=0; i<me->fdata.totlayer; i++) {
 -                                      if(me->fdata.layers[i].type == CD_MTFACE) {
 -                                              tface= (MTFace*)me->fdata.layers[i].data;
 -
 -                                              for(a=0; a<me->totface; a++, tface++) { 
 -                                                      if(tface->tpage == ima) {
 -                                                              tface->tpage = iman;
 -                                                              if(iman->id.us == 0) {
 -                                                                      tface->tpage->id.us= 1;
 -                                                              }
 -                                                              id_lib_extern((ID*)iman);
 -                                                      }
 -                                              }
 -                                      }
 -                              }
 -                      }
 -                      me= me->id.next;
 -              }
 -      }
 -}
 -
  void BKE_image_merge(Image *dest, Image *source)
  {
        ImBuf *ibuf;
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -257,9 -255,7 +255,9 @@@ void make_local_lattice(Lattice *lt
        
        if(lt->id.lib==NULL) return;
        if(lt->id.us==1) {
 -              id_clear_lib_data(&bmain->latt, (ID *)lt);
 +              lt->id.lib= NULL;
 +              lt->id.flag= LIB_LOCAL;
 +              new_id(&bmain->latt, (ID *)lt, NULL);
                return;
        }
        
        }
        
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->latt, (ID *)lt);
 +              lt->id.lib= NULL;
 +              lt->id.flag= LIB_LOCAL;
 +              new_id(&bmain->latt, (ID *)lt, NULL);
        }
        else if(local && lib) {
                Lattice *ltn= copy_lattice(lt);
@@@ -1,6 -1,4 +1,4 @@@
- /* 
-  * $Id$
-  * 
+ /*
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -76,7 -74,7 +74,7 @@@
  #include "BLI_blenlib.h"
  #include "BLI_dynstr.h"
  #include "BLI_utildefines.h"
 -#include "BLI_bpath.h"
 +
  
  #include "BKE_animsys.h"
  #include "BKE_context.h"
  #include "BKE_gpencil.h"
  #include "BKE_fcurve.h"
  #include "BKE_speaker.h"
 -#include "BKE_utildefines.h"
  
  #include "RNA_access.h"
  
@@@ -196,7 -195,8 +194,7 @@@ int id_make_local(ID *id, int test
                        if(!test) make_local_texture((Tex*)id);
                        return 1;
                case ID_IM:
 -                      if(!test) make_local_image((Image*)id);
 -                      return 1;
 +                      return 0; /* not implemented */
                case ID_LT:
                        if(!test) {
                                make_local_lattice((Lattice*)id);
@@@ -1248,6 -1248,16 +1246,6 @@@ int new_id(ListBase *lb, ID *id, const 
        return result;
  }
  
 -/* Pull an ID out of a library (make it local). Only call this for IDs that
 -   don't have other library users. */
 -void id_clear_lib_data(ListBase *lb, ID *id)
 -{
 -      bpath_traverse_id(id, bpath_relocate_visitor, id->lib->filepath);
 -      id->lib= NULL;
 -      id->flag= LIB_LOCAL;
 -      new_id(lb, id, NULL);
 -}
 -
  /* next to indirect usage in read/writefile also in editobject.c scene.c */
  void clear_id_newpoins(void)
  {
@@@ -1463,3 -1473,21 +1461,3 @@@ void name_uiprefix_id(char *name, ID *i
  
        strcpy(name+3, id->name+2);
  }
 -
 -void BKE_library_filepath_set(Library *lib, const char *filepath)
 -{
 -      BLI_strncpy(lib->name, filepath, sizeof(lib->name));
 -      BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
 -
 -      /* not essential but set filepath is an absolute copy of value which
 -       * is more useful if its kept in sync */
 -      if (strncmp(lib->filepath, "//", 2) == 0) {
 -              /* note that the file may be unsaved, in this case, setting the
 -               * filepath on an indirectly linked path is not allowed from the
 -               * outliner, and its not really supported but allow from here for now
 -               * since making local could cause this to be directly linked - campbell
 -               */
 -              const char *basepath= lib->parent ? lib->parent->filepath : G.main->name;
 -              BLI_path_abs(lib->filepath, basepath);
 -      }
 -}
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -296,15 -294,16 +294,15 @@@ void make_local_material(Material *ma
                */
        
        if(ma->id.lib==NULL) return;
 -
 -      /* One local user; set flag and return. */
        if(ma->id.us==1) {
 -              id_clear_lib_data(&bmain->mat, (ID *)ma);
 +              ma->id.lib= NULL;
 +              ma->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->mat, (ID *)ma, NULL);
                extern_local_material(ma);
                return;
        }
 -
 -      /* Check which other IDs reference this one to determine if it's used by
 -         lib or local */
 +      
        /* test objects */
        ob= bmain->object.first;
        while(ob) {
                }
                mb= mb->id.next;
        }
 -
 -      /* Only local users. */
 +      
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->mat, (ID *)ma);
 +              ma->id.lib= NULL;
 +              ma->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->mat, (ID *)ma, NULL);
                extern_local_material(ma);
        }
 -      /* Both user and local, so copy. */
        else if(local && lib) {
                
                man= copy_material(ma);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -158,9 -156,7 +156,9 @@@ void make_local_mball(MetaBall *mb
        
        if(mb->id.lib==NULL) return;
        if(mb->id.us==1) {
 -              id_clear_lib_data(&bmain->mball, (ID *)mb);
 +              mb->id.lib= NULL;
 +              mb->id.flag= LIB_LOCAL;
 +              new_id(&bmain->mball, (ID *)mb, NULL);
                extern_local_mball(mb);
                
                return;
        }
        
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->mball, (ID *)mb);
 +              mb->id.lib= NULL;
 +              mb->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->mball, (ID *)mb, NULL);
                extern_local_mball(mb);
        }
        else if(local && lib) {
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -195,6 -193,7 +193,6 @@@ Mesh *add_mesh(const char *name
        me->smoothresh= 30;
        me->texflag= AUTOSPACE;
        me->flag= ME_TWOSIDED;
 -      me->bb= unit_boundbox();
        me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
        
        return me;
@@@ -242,39 -241,26 +240,39 @@@ Mesh *copy_mesh(Mesh *me
        return men;
  }
  
 -static void expand_local_mesh(Mesh *me)
 +static void make_local_tface(Main *bmain, Mesh *me)
  {
 -      id_lib_extern((ID *)me->texcomesh);
 -
 -      if(me->mtface) {
 -              MTFace *tface;
 -              int a, i;
 -
 -              for(i=0; i<me->fdata.totlayer; i++) {
 -                      if(me->fdata.layers[i].type == CD_MTFACE) {
 -                              tface= (MTFace*)me->fdata.layers[i].data;
 -
 -                              for(a=0; a<me->totface; a++, tface++) {
 -                                      if(tface->tpage) {
 -                                              id_lib_extern((ID *)tface->tpage);
 +      MTFace *tface;
 +      Image *ima;
 +      int a, i;
 +      
 +      for(i=0; i<me->fdata.totlayer; i++) {
 +              if(me->fdata.layers[i].type == CD_MTFACE) {
 +                      tface= (MTFace*)me->fdata.layers[i].data;
 +                      
 +                      for(a=0; a<me->totface; a++, tface++) {
 +                              /* special case: ima always local immediately */
 +                              if(tface->tpage) {
 +                                      ima= tface->tpage;
 +                                      if(ima->id.lib) {
 +                                              ima->id.lib= NULL;
 +                                              ima->id.flag= LIB_LOCAL;
 +                                              new_id(&bmain->image, (ID *)ima, NULL);
                                        }
                                }
                        }
                }
        }
 +}
 +
 +static void expand_local_mesh(Main *bmain, Mesh *me)
 +{
 +      id_lib_extern((ID *)me->texcomesh);
 +
 +      if(me->mtface) {
 +              /* why is this an exception? - should not really make local when extern'ing - campbell */
 +              make_local_tface(bmain, me);
 +      }
  
        if(me->mat) {
                extern_local_matarar(me->mat, me->totcol);
@@@ -294,11 -280,8 +292,11 @@@ void make_local_mesh(Mesh *me
  
        if(me->id.lib==NULL) return;
        if(me->id.us==1) {
 -              id_clear_lib_data(&bmain->mesh, (ID *)me);
 -              expand_local_mesh(me);
 +              me->id.lib= NULL;
 +              me->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->mesh, (ID *)me, NULL);
 +              expand_local_mesh(bmain, me);
                return;
        }
  
        }
  
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->mesh, (ID *)me);
 -              expand_local_mesh(me);
 +              me->id.lib= NULL;
 +              me->id.flag= LIB_LOCAL;
 +
 +              new_id(&bmain->mesh, (ID *)me, NULL);
 +              expand_local_mesh(bmain, me);
        }
        else if(local && lib) {
                Mesh *men= copy_mesh(me);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -117,9 -115,10 +115,9 @@@ static int search_face_cmp(const void *
  
  }
  
 -#define PRINT if(do_verbose) printf
 -
  int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totvert, MEdge *medges, unsigned int totedge, MFace *mfaces, unsigned int totface, const short do_verbose, const short do_fixes)
  {
 +#     define PRINT if(do_verbose) printf
  #     define REMOVE_EDGE_TAG(_med) { _med->v2= _med->v1; do_edge_free= 1; }
  #     define REMOVE_FACE_TAG(_mf) { _mf->v3=0; do_face_free= 1; }
  
  
        PRINT("BKE_mesh_validate: finished\n\n");
  
 +#      undef PRINT
  #      undef REMOVE_EDGE_TAG
  #      undef REMOVE_FACE_TAG
  
        return (do_face_free || do_edge_free || do_edge_recalc);
  }
  
 -static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes)
 -{
 -      int i= 0, has_fixes= 0;
 -
 -      while(i<data->totlayer) {
 -              CustomDataLayer *layer= &data->layers[i];
 -              int mask= 1 << layer->type;
 -              int ok= 1;
 -
 -              if((mask&CD_MASK_MESH)==0) {
 -                      PRINT("CustomDataLayer type %d which isn't in CD_MASK_MESH is stored in Mehs structure\n", layer->type);
 -
 -                      if(do_fixes) {
 -                              CustomData_free_layer(data, layer->type, 0, i);
 -                              ok= 0;
 -                              has_fixes= 1;
 -                      }
 -              }
 -
 -              if(ok)
 -                      i++;
 -      }
 -
 -      return has_fixes;
 -}
 -
 -#undef PRINT
 -
 -int BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, CustomData *fdata, short do_verbose, const short do_fixes)
 -{
 -      int vfixed= 0, efixed= 0, ffixed= 0;
 -
 -      vfixed= mesh_validate_customdata(vdata, do_verbose, do_fixes);
 -      efixed= mesh_validate_customdata(edata, do_verbose, do_fixes);
 -      ffixed= mesh_validate_customdata(fdata, do_verbose, do_fixes);
 -
 -      return vfixed || efixed || ffixed;
 -}
 -
  int BKE_mesh_validate(Mesh *me, int do_verbose)
  {
 -      int layers_fixed= 0, arrays_fixed= 0;
 -
        if(do_verbose) {
                printf("MESH: %s\n", me->id.name+2);
        }
 -
 -      layers_fixed= BKE_mesh_validate_all_customdata(&me->vdata, &me->edata, &me->fdata, do_verbose, TRUE);
 -      arrays_fixed= BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, do_verbose, TRUE);
 -
 -      return layers_fixed || arrays_fixed;
 +      return BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, do_verbose, TRUE);
  }
  
  int BKE_mesh_validate_dm(DerivedMesh *dm)
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
  #include <string.h>
  #include <limits.h>
  
 +#include "DNA_action_types.h"
  #include "DNA_anim_types.h"
  #include "DNA_node_types.h"
 +#include "DNA_node_types.h"
  #include "DNA_scene_types.h"
 -#include "DNA_action_types.h"
  
  #include "BLI_string.h"
  #include "BLI_math.h"
@@@ -1042,6 -1039,7 +1040,6 @@@ static void ntreeMakeLocal_LinkNew(voi
  
  void ntreeMakeLocal(bNodeTree *ntree)
  {
 -      Main *bmain= G.main;
        bNodeTreeType *treetype= ntreeGetType(ntree->type);
        MakeLocalCallData cd;
        
        
        if(ntree->id.lib==NULL) return;
        if(ntree->id.us==1) {
 -              id_clear_lib_data(&bmain->nodetree, (ID *)ntree);
 +              ntree->id.lib= NULL;
 +              ntree->id.flag= LIB_LOCAL;
 +              new_id(NULL, (ID *)ntree, NULL);
                return;
        }
        
        
        /* if all users are local, we simply make tree local */
        if(cd.local && cd.lib==0) {
 -              id_clear_lib_data(&bmain->nodetree, (ID *)ntree);
 +              ntree->id.lib= NULL;
 +              ntree->id.flag= LIB_LOCAL;
 +              new_id(NULL, (ID *)ntree, NULL);
        }
        else if(cd.local && cd.lib) {
                /* this is the mixed case, we copy the tree and assign it to local users */
                
                newtree->id.us= 0;
                
 -
                cd.new_id = &newtree->id;
                treetype->foreach_nodetree(G.main, &cd, &ntreeMakeLocal_LinkNew);
        }
@@@ -1318,15 -1313,11 +1316,15 @@@ void nodeSetActive(bNodeTree *ntree, bN
                        if(GS(node->id->name) == GS(tnode->id->name))
                                tnode->flag &= ~NODE_ACTIVE_ID;
                }
 +              if(node->typeinfo->nclass == NODE_CLASS_TEXTURE)
 +                      tnode->flag &= ~NODE_ACTIVE_TEXTURE;
        }
        
        node->flag |= NODE_ACTIVE;
        if(node->id)
                node->flag |= NODE_ACTIVE_ID;
 +      if(node->typeinfo->nclass == NODE_CLASS_TEXTURE)
 +              node->flag |= NODE_ACTIVE_TEXTURE;
  }
  
  /* use flags are not persistant yet, groups might need different tagging, so we do it each time
@@@ -1760,10 -1751,6 +1758,10 @@@ void node_type_gpu_ext(struct bNodeTyp
        ntype->gpuextfunc = gpuextfunc;
  }
  
 +void node_type_compatibility(struct bNodeType *ntype, short compatibility)
 +{
 +      ntype->compatibility = compatibility;
 +}
  
  static bNodeType *is_nodetype_registered(ListBase *typelist, int type) 
  {
@@@ -1867,20 -1854,15 +1865,20 @@@ static void registerCompositNodes(ListB
  static void registerShaderNodes(ListBase *ntypelist) 
  {
        register_node_type_frame(ntypelist);
 -      
 +
        register_node_type_sh_group(ntypelist);
 -//    register_node_type_sh_forloop(ntypelist);
 -//    register_node_type_sh_whileloop(ntypelist);
 -      
 +      //register_node_type_sh_forloop(ntypelist);
 +      //register_node_type_sh_whileloop(ntypelist);
 +
        register_node_type_sh_output(ntypelist);
 +      register_node_type_sh_material(ntypelist);
 +      register_node_type_sh_camera(ntypelist);
 +      register_node_type_sh_value(ntypelist);
 +      register_node_type_sh_rgb(ntypelist);
        register_node_type_sh_mix_rgb(ntypelist);
        register_node_type_sh_valtorgb(ntypelist);
        register_node_type_sh_rgbtobw(ntypelist);
 +      register_node_type_sh_texture(ntypelist);
        register_node_type_sh_normal(ntypelist);
        register_node_type_sh_geom(ntypelist);
        register_node_type_sh_mapping(ntypelist);
        register_node_type_sh_math(ntypelist);
        register_node_type_sh_vect_math(ntypelist);
        register_node_type_sh_squeeze(ntypelist);
 -      register_node_type_sh_camera(ntypelist);
 -      register_node_type_sh_material(ntypelist);
 +      //register_node_type_sh_dynamic(ntypelist);
        register_node_type_sh_material_ext(ntypelist);
 -      register_node_type_sh_value(ntypelist);
 -      register_node_type_sh_rgb(ntypelist);
 -      register_node_type_sh_texture(ntypelist);
 -//    register_node_type_sh_dynamic(ntypelist);
        register_node_type_sh_invert(ntypelist);
        register_node_type_sh_seprgb(ntypelist);
        register_node_type_sh_combrgb(ntypelist);
        register_node_type_sh_hue_sat(ntypelist);
 +
 +      register_node_type_sh_attribute(ntypelist);
 +      register_node_type_sh_geometry(ntypelist);
 +      register_node_type_sh_light_path(ntypelist);
 +      register_node_type_sh_fresnel(ntypelist);
 +      register_node_type_sh_blend_weight(ntypelist);
 +      register_node_type_sh_tex_coord(ntypelist);
 +
 +      register_node_type_sh_background(ntypelist);
 +      register_node_type_sh_bsdf_diffuse(ntypelist);
 +      register_node_type_sh_bsdf_glossy(ntypelist);
 +      register_node_type_sh_bsdf_glass(ntypelist);
 +      //register_node_type_sh_bsdf_anisotropic(ntypelist);
 +      register_node_type_sh_bsdf_translucent(ntypelist);
 +      register_node_type_sh_bsdf_transparent(ntypelist);
 +      register_node_type_sh_bsdf_velvet(ntypelist);
 +      register_node_type_sh_emission(ntypelist);
 +      register_node_type_sh_holdout(ntypelist);
 +      register_node_type_sh_volume_transparent(ntypelist);
 +      register_node_type_sh_volume_isotropic(ntypelist);
 +      register_node_type_sh_mix_shader(ntypelist);
 +      register_node_type_sh_add_shader(ntypelist);
 +
 +      register_node_type_sh_output_lamp(ntypelist);
 +      register_node_type_sh_output_material(ntypelist);
 +      //register_node_type_sh_output_texture(ntypelist);
 +      register_node_type_sh_output_world(ntypelist);
 +
 +      register_node_type_sh_tex_image(ntypelist);
 +      register_node_type_sh_tex_environment(ntypelist);
 +      register_node_type_sh_tex_sky(ntypelist);
 +      register_node_type_sh_tex_voronoi(ntypelist);
 +      register_node_type_sh_tex_blend(ntypelist);
 +      register_node_type_sh_tex_magic(ntypelist);
 +      register_node_type_sh_tex_marble(ntypelist);
 +      register_node_type_sh_tex_clouds(ntypelist);
 +      register_node_type_sh_tex_wood(ntypelist);
 +      register_node_type_sh_tex_stucci(ntypelist);
 +      register_node_type_sh_tex_noise(ntypelist);
 +      register_node_type_sh_tex_distnoise(ntypelist);
 +      register_node_type_sh_tex_musgrave(ntypelist);
  }
  
  static void registerTextureNodes(ListBase *ntypelist)
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -87,7 -85,6 +85,7 @@@
  #include "BKE_mesh.h"
  #include "BKE_mball.h"
  #include "BKE_modifier.h"
 +#include "BKE_node.h"
  #include "BKE_object.h"
  #include "BKE_paint.h"
  #include "BKE_particle.h"
@@@ -759,9 -756,7 +757,9 @@@ void make_local_camera(Camera *cam
        
        if(cam->id.lib==NULL) return;
        if(cam->id.us==1) {
 -              id_clear_lib_data(&bmain->camera, (ID *)cam);
 +              cam->id.lib= NULL;
 +              cam->id.flag= LIB_LOCAL;
 +              new_id(&bmain->camera, (ID *)cam, NULL);
                return;
        }
        
        }
        
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->camera, (ID *)cam);
 +              cam->id.lib= NULL;
 +              cam->id.flag= LIB_LOCAL;
 +              new_id(&bmain->camera, (ID *)cam, NULL);
        }
        else if(local && lib) {
                Camera *camn= copy_camera(cam);
@@@ -879,9 -872,6 +877,9 @@@ Lamp *copy_lamp(Lamp *la
        }
        
        lan->curfalloff = curvemapping_copy(la->curfalloff);
 +
 +      if(la->nodetree)
 +              lan->nodetree= ntreeCopyTree(la->nodetree);
        
        if(la->preview)
                lan->preview = BKE_previewimg_copy(la->preview);
@@@ -908,9 -898,6 +906,9 @@@ Lamp *localize_lamp(Lamp *la
        
        lan->curfalloff = curvemapping_copy(la->curfalloff);
  
 +      if(la->nodetree)
 +              lan->nodetree= ntreeLocalize(la->nodetree);
 +      
        lan->preview= NULL;
        
        return lan;
@@@ -930,9 -917,7 +928,9 @@@ void make_local_lamp(Lamp *la
        
        if(la->id.lib==NULL) return;
        if(la->id.us==1) {
 -              id_clear_lib_data(&bmain->lamp, (ID *)la);
 +              la->id.lib= NULL;
 +              la->id.flag= LIB_LOCAL;
 +              new_id(&bmain->lamp, (ID *)la, NULL);
                return;
        }
        
        }
        
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->lamp, (ID *)la);
 +              la->id.lib= NULL;
 +              la->id.flag= LIB_LOCAL;
 +              new_id(&bmain->lamp, (ID *)la, NULL);
        }
        else if(local && lib) {
                lan= copy_lamp(la);
@@@ -988,12 -971,6 +986,12 @@@ void free_lamp(Lamp *la
        BKE_free_animdata((ID *)la);
  
        curvemapping_free(la->curfalloff);
 +
 +      /* is no lib link block, but lamp extension */
 +      if(la->nodetree) {
 +              ntreeFreeTree(la->nodetree);
 +              MEM_freeN(la->nodetree);
 +      }
        
        BKE_previewimg_free(&la->preview);
        BKE_icon_delete(&la->id);
@@@ -1106,6 -1083,7 +1104,6 @@@ Object *add_only_object(int type, cons
        /* ob->pad3 == Contact Processing Threshold */
        ob->m_contactProcessingThreshold = 1.;
        ob->obstacleRad = 1.;
 -      ob->col_group = ob->col_mask = 1;
        
        /* NT fluid sim defaults */
        ob->fluidsimFlag = 0;
@@@ -1483,9 -1461,8 +1481,9 @@@ void make_local_object(Object *ob
        ob->proxy= ob->proxy_from= NULL;
        
        if(ob->id.us==1) {
 -              id_clear_lib_data(&bmain->object, (ID *)ob);
 -              extern_local_object(ob);
 +              ob->id.lib= NULL;
 +              ob->id.flag= LIB_LOCAL;
 +              new_id(&bmain->object, (ID *)ob, NULL);
        }
        else {
                for(sce= bmain->scene.first; sce && ELEM(0, lib, local); sce= sce->id.next) {
                }
  
                if(local && lib==0) {
 -                      id_clear_lib_data(&bmain->object, (ID *)ob);
 -                      extern_local_object(ob);
 +                      ob->id.lib= NULL;
 +                      ob->id.flag= LIB_LOCAL;
 +                      new_id(&bmain->object, (ID *)ob, NULL);
                }
                else if(local && lib) {
                        Object *obn= copy_object(ob);
                        }
                }
        }
 +      
 +      extern_local_object(ob);
  }
  
  /*
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -3612,9 -3610,7 +3610,9 @@@ void make_local_particlesettings(Partic
        
        if(part->id.lib==0) return;
        if(part->id.us==1) {
 -              id_clear_lib_data(&bmain->particle, (ID *)part);
 +              part->id.lib= 0;
 +              part->id.flag= LIB_LOCAL;
 +              new_id(&bmain->particle, (ID *)part, 0);
                expand_local_particlesettings(part);
                return;
        }
        }
        
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->particle, (ID *)part);
 +              part->id.lib= 0;
 +              part->id.flag= LIB_LOCAL;
 +              new_id(&bmain->particle, (ID *)part, 0);
                expand_local_particlesettings(part);
        }
        else if(local && lib) {
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -74,8 -72,6 +72,8 @@@
  
  #include "BKE_sound.h"
  
 +#include "RE_engine.h"
 +
  //XXX #include "BIF_previewrender.h"
  //XXX #include "BIF_editseq.h"
  
@@@ -1013,17 -1009,10 +1011,17 @@@ void scene_update_tagged(Main *bmain, S
        if (scene->physics_settings.quick_cache_step)
                BKE_ptcache_quick_cache_all(bmain, scene);
  
 +      DAG_ids_check_recalc(bmain);
 +
        /* in the future this should handle updates for all datablocks, not
           only objects and scenes. - brecht */
  }
  
 +void scene_clear_tagged(Main *bmain, Scene *UNUSED(scene))
 +{
 +      DAG_ids_clear_recalc(bmain);
 +}
 +
  /* applies changes right away, does all sets too */
  void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
  {
@@@ -1138,10 -1127,3 +1136,10 @@@ Base *_setlooper_base_step(Scene **sce_
  
        return NULL;
  }
 +
 +int scene_use_new_shading_nodes(Scene *scene)
 +{
 +      RenderEngineType *type= RE_engines_find(scene->r.engine);
 +      return (type->flag & RE_USE_SHADING_NODES);
 +}
 +
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -19,6 -17,8 +17,6 @@@
   *
   * Peter Schlaile <peter [at] schlaile [dot] de> 2010
   *
 - * Contributor(s): Sergey Sharybin
 - *
   * ***** END GPL LICENSE BLOCK *****
   */
  
  
  
  #include <stddef.h>
 -
 -#include "BLO_sys_types.h"    /* for intptr_t */
 +#include <stdlib.h>
 +#include <string.h>
 +#include <math.h>
  
  #include "MEM_guardedalloc.h"
 +#include "MEM_CacheLimiterC-Api.h"
  
  #include "DNA_sequence_types.h"
  #include "BKE_sequencer.h"
 +#include "BLI_utildefines.h"
 +#include "BLI_ghash.h"
 +#include "BLI_mempool.h"
 +#include <pthread.h>
  
 -#include "IMB_moviecache.h"
 +#include "IMB_imbuf.h"
 +#include "IMB_imbuf_types.h"
  
  typedef struct seqCacheKey 
  {
        seq_stripelem_ibuf_t type;
  } seqCacheKey;
  
 -static struct MovieCache *moviecache = NULL;
 -
 -static unsigned int seqcache_hashhash(const void *key_)
 +typedef struct seqCacheEntry
 +{
 +      ImBuf * ibuf;
 +      MEM_CacheLimiterHandleC * c_handle;
 +} seqCacheEntry;
 +
 +static GHash * hash = NULL;
 +static MEM_CacheLimiterC * limitor = NULL;
 +static struct BLI_mempool * entrypool = NULL;
 +static struct BLI_mempool * keypool = NULL;
 +static int ibufs_in  = 0;
 +static int ibufs_rem = 0;
 +
 +static unsigned int HashHash(const void *key_)
  {
        const seqCacheKey *key = (seqCacheKey*) key_;
        unsigned int rval = seq_hash_render_data(&key->context);
@@@ -78,7 -60,7 +76,7 @@@
        return rval;
  }
  
 -static int seqcache_hashcmp(const void *a_, const void *b_)
 +static int HashCmp(const void *a_, const void *b_)
  {
        const seqCacheKey * a = (seqCacheKey*) a_;
        const seqCacheKey * b = (seqCacheKey*) b_;
        return seq_cmp_render_data(&a->context, &b->context);
  }
  
 +static void HashKeyFree(void *key)
 +{
 +      BLI_mempool_free(keypool, key);
 +}
 +
 +static void HashValFree(void *val)
 +{
 +      seqCacheEntry* e = (seqCacheEntry*) val;
 +
 +      if (e->ibuf) {
 +              /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf, 
 +                 e->ibuf->refcounter); */
 +              IMB_freeImBuf(e->ibuf);
 +              MEM_CacheLimiter_unmanage(e->c_handle);
 +              ibufs_rem++;
 +      }
 +
 +      e->ibuf = NULL;
 +      e->c_handle = NULL;
 +
 +      BLI_mempool_free(entrypool, e);
 +}
 +
 +static void IMB_seq_cache_destructor(void * p)
 +{
 +      seqCacheEntry* e = (seqCacheEntry*) p;
 +      
 +      if (e && e->ibuf) {
 +              /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf,
 +                 e->ibuf->refcounter); */
 +              IMB_freeImBuf(e->ibuf);
 +              ibufs_rem++;
 +
 +              e->ibuf = NULL;
 +              e->c_handle = NULL;
 +      }
 +}
 +
 +void seq_stripelem_cache_init(void)
 +{
 +      hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash");
 +      limitor = new_MEM_CacheLimiter( IMB_seq_cache_destructor );
 +
 +      entrypool = BLI_mempool_create(sizeof(seqCacheEntry), 64, 64, 0);
 +      keypool = BLI_mempool_create(sizeof(seqCacheKey), 64, 64, 0);
 +}
 +
  void seq_stripelem_cache_destruct(void)
  {
 -      if(moviecache)
 -              IMB_moviecache_free(moviecache);
 +      if (!entrypool) {
 +              return;
 +      }
 +      BLI_ghash_free(hash, HashKeyFree, HashValFree);
 +      delete_MEM_CacheLimiter(limitor);
 +      BLI_mempool_destroy(entrypool);
 +      BLI_mempool_destroy(keypool);
  }
  
  void seq_stripelem_cache_cleanup(void)
  {
 -      if(moviecache) {
 -              IMB_moviecache_free(moviecache);
 -              moviecache = IMB_moviecache_create(sizeof(seqCacheKey), seqcache_hashhash,
 -                              seqcache_hashcmp, NULL);
 +      if (!entrypool) {
 +              seq_stripelem_cache_init();
        }
 +
 +      /* fprintf(stderr, "Stats before cleanup: in: %d rem: %d\n",
 +         ibufs_in, ibufs_rem); */
 +
 +      BLI_ghash_free(hash, HashKeyFree, HashValFree);
 +      hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash");
 +
 +      /* fprintf(stderr, "Stats after cleanup: in: %d rem: %d\n",
 +         ibufs_in, ibufs_rem); */
 +
  }
  
  struct ImBuf * seq_stripelem_cache_get(
        SeqRenderData context, struct Sequence * seq, 
        float cfra, seq_stripelem_ibuf_t type)
  {
 +      seqCacheKey key;
 +      seqCacheEntry * e;
  
 -      if(moviecache && seq) {
 -              seqCacheKey key;
 -
 -              key.seq = seq;
 -              key.context = context;
 -              key.cfra = cfra - seq->start;
 -              key.type = type;
 +      if (!seq) {
 +              return NULL;
 +      }
  
 -              return IMB_moviecache_get(moviecache, &key);
 +      if (!entrypool) {
 +              seq_stripelem_cache_init();
        }
  
 +      key.seq = seq;
 +      key.context = context;
 +      key.cfra = cfra - seq->start;
 +      key.type = type;
 +      
 +      e = (seqCacheEntry*) BLI_ghash_lookup(hash, &key);
 +
 +      if (e && e->ibuf) {
 +              IMB_refImBuf(e->ibuf);
 +
 +              MEM_CacheLimiter_touch(e->c_handle);
 +              return e->ibuf;
 +      }
        return NULL;
  }
  
@@@ -217,39 -127,21 +215,39 @@@ void seq_stripelem_cache_put
        SeqRenderData context, struct Sequence * seq, 
        float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i)
  {
 -      seqCacheKey key;
 +      seqCacheKey * key;
 +      seqCacheEntry * e;
  
        if (!i) {
                return;
        }
  
 -      if(!moviecache) {
 -              moviecache = IMB_moviecache_create(sizeof(seqCacheKey), seqcache_hashhash,
 -                              seqcache_hashcmp, NULL);
 +      ibufs_in++;
 +
 +      if (!entrypool) {
 +              seq_stripelem_cache_init();
        }
  
 -      key.seq = seq;
 -      key.context = context;
 -      key.cfra = cfra - seq->start;
 -      key.type = type;
 +      key = (seqCacheKey*) BLI_mempool_alloc(keypool);
 +
 +      key->seq = seq;
 +      key->context = context;
 +      key->cfra = cfra - seq->start;
 +      key->type = type;
 +
 +      IMB_refImBuf(i);
 +
 +      e = (seqCacheEntry*) BLI_mempool_alloc(entrypool);
 +
 +      e->ibuf = i;
 +      e->c_handle = NULL;
 +
 +      BLI_ghash_remove(hash, key, HashKeyFree, HashValFree);
 +      BLI_ghash_insert(hash, key, e);
 +
 +      e->c_handle = MEM_CacheLimiter_insert(limitor, e);
  
 -      IMB_moviecache_put(moviecache, &key, i);
 +      MEM_CacheLimiter_ref(e->c_handle);
 +      MEM_CacheLimiter_enforce_limits(limitor);
 +      MEM_CacheLimiter_unref(e->c_handle);
  }
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -1326,6 -1324,10 +1324,6 @@@ static void seq_proxy_build_frame(SeqRe
        quality = seq->strip->proxy->quality;
        ibuf->ftype= JPG | quality;
  
 -      /* unsupported feature only confuses other s/w */
 -      if(ibuf->depth==32)
 -              ibuf->depth= 24;
 -
        BLI_make_existing_file(name);
        
        ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
@@@ -2503,9 -2505,6 +2501,9 @@@ static void *seq_prefetch_thread(void 
  
                for (e = prefetch_done.first; e; e = e->next) {
                        if (s_last > e->monoton_cfra) {
 +                              if (e->ibuf) {
 +                                      IMB_cache_limiter_unref(e->ibuf);
 +                              }
                                BLI_remlink(&prefetch_done, e);
                                MEM_freeN(e);
                        }
@@@ -2583,9 -2582,6 +2581,9 @@@ static void seq_stop_threads(
        }
  
        for (e = prefetch_done.first; e; e = e->next) {
 +              if (e->ibuf) {
 +                      IMB_cache_limiter_unref(e->ibuf);
 +              }
                BLI_remlink(&prefetch_done, e);
                MEM_freeN(e);
        }
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -89,9 -87,7 +87,9 @@@ void make_local_speaker(Speaker *spk
  
        if(spk->id.lib==NULL) return;
        if(spk->id.us==1) {
 -              id_clear_lib_data(&bmain->speaker, (ID *)spk);
 +              spk->id.lib= NULL;
 +              spk->id.flag= LIB_LOCAL;
 +              new_id(&bmain->speaker, (ID *)spk, NULL);
                return;
        }
  
        }
  
        if(local && lib==0) {
 -              id_clear_lib_data(&bmain->speaker, (ID *)spk);
 +              spk->id.lib= NULL;
 +              spk->id.flag= LIB_LOCAL;
 +              new_id(&bmain->speaker, (ID *)spk, NULL);
        }
        else if(local && lib) {
                Speaker *spkn= copy_speaker(spk);
@@@ -1,6 -1,4 +1,4 @@@
  /*
-  * $Id$
-  *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * This program is free software; you can redistribute it and/or
@@@ -1513,155 -1511,6 +1511,155 @@@ static void ccgDM_drawFacesGLSL(Derived
        dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
  }
  
 +      /* Only used by non-editmesh types */
 +static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) {
 +      CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
 +      CCGSubSurf *ss = ccgdm->ss;
 +      CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
 +      GPUVertexAttribs gattribs;
 +      DMVertexAttribs attribs= {{{NULL}}};
 +      int gridSize = ccgSubSurf_getGridSize(ss);
 +      int gridFaces = gridSize - 1;
 +      int edgeSize = ccgSubSurf_getEdgeSize(ss);
 +      char *faceFlags = ccgdm->faceFlags;
 +      int a, b, i, numVerts, matnr, new_matnr, totface;
 +
 +      ccgdm_pbvh_update(ccgdm);
 +
 +      matnr = -1;
 +
 +#define PASSATTRIB(dx, dy, vert) {                                                                                            \
 +      if(attribs.totorco) {                                                                                                           \
 +              index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize);                 \
 +              if(attribs.orco.glTexco)                                                                                                \
 +                      glTexCoord3fv(attribs.orco.array[index]);                                                       \
 +              else                                                                                                                                    \
 +                      glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]);  \
 +      }                                                                                                                                                       \
 +      for(b = 0; b < attribs.tottface; b++) {                                                                         \
 +              MTFace *tf = &attribs.tface[b].array[a];                                                                \
 +              if(attribs.tface[b].glTexco)                                                                                    \
 +                      glTexCoord2fv(tf->uv[vert]);                                                                            \
 +              else                                                                                                                                    \
 +                      glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]);           \
 +      }                                                                                                                                                       \
 +      for(b = 0; b < attribs.totmcol; b++) {                                                                          \
 +              MCol *cp = &attribs.mcol[b].array[a*4 + vert];                                                  \
 +              GLubyte col[4];                                                                                                                 \
 +              col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;                             \
 +              glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col);                                    \
 +      }                                                                                                                                                       \
 +      if(attribs.tottang) {                                                                                                           \
 +              float *tang = attribs.tang.array[a*4 + vert];                                                   \
 +              glVertexAttrib4fvARB(attribs.tang.glIndex, tang);                                               \
 +      }                                                                                                                                                       \
 +}
 +
 +      totface = ccgSubSurf_getNumFaces(ss);
 +      for(a = 0, i = 0; i < totface; i++) {
 +              CCGFace *f = ccgdm->faceMap[i].face;
 +              int S, x, y, drawSmooth;
 +              int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(ss, f));
 +              int origIndex = ccgDM_getFaceMapIndex(ss, f);
 +              
 +              numVerts = ccgSubSurf_getFaceNumVerts(f);
 +
 +              /* get flags */
 +              if(faceFlags) {
 +                      drawSmooth = (faceFlags[index*2] & ME_SMOOTH);
 +                      new_matnr= faceFlags[index*2 + 1] + 1;
 +              }
 +              else {
 +                      drawSmooth = 1;
 +                      new_matnr= 1;
 +              }
 +
 +              /* material */
 +              if(new_matnr != matnr) {
 +                      setMaterial(userData, matnr = new_matnr, &gattribs);
 +                      DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
 +              }
 +
 +              /* face hiding */
 +              if((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
 +                      a += gridFaces*gridFaces*numVerts;
 +                      continue;
 +              }
 +
 +              /* draw face*/
 +              glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT);
 +              for (S=0; S<numVerts; S++) {
 +                      DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
 +                      DMGridData *vda, *vdb;
 +
 +                      if (drawSmooth) {
 +                              for (y=0; y<gridFaces; y++) {
 +                                      glBegin(GL_QUAD_STRIP);
 +                                      for (x=0; x<gridFaces; x++) {
 +                                              vda = &faceGridData[(y+0)*gridSize + x];
 +                                              vdb = &faceGridData[(y+1)*gridSize + x];
 +                                              
 +                                              PASSATTRIB(0, 0, 0);
 +                                              glNormal3fv(vda->no);
 +                                              glVertex3fv(vda->co);
 +
 +                                              PASSATTRIB(0, 1, 1);
 +                                              glNormal3fv(vdb->no);
 +            &nb