Cycles: svn merge -r41467:41531 ^/trunk/blender
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 4 Nov 2011 20:21:40 +0000 (20:21 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 4 Nov 2011 20:21:40 +0000 (20:21 +0000)
1  2 
CMakeLists.txt
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/nodes/shader/nodes/node_shader_geom.c
source/blenderplayer/bad_level_call_stubs/stubs.c

diff --combined CMakeLists.txt
index 3ca7085c107e6e65f0f06dd39a91584234178686,0e06f39e7187267081979e683737820a6e2aa42a..0230fb34d0c7a58cdf336467cdd17122f508ba93
@@@ -105,7 -105,6 +105,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
@@@ -158,6 -157,8 +158,8 @@@ endif(
  if(UNIX AND NOT APPLE)
        option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)"   ON)
        option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
+       option(WITH_XDG_USER_DIRS    "Build with XDG Base Directory Specification (only config and documents for now)" OFF)
+       mark_as_advanced(WITH_XDG_USER_DIRS)
  else()
        # not an option for other OS's
        set(WITH_BUILTIN_GLEW ON)
@@@ -209,15 -210,6 +211,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)
@@@ -289,16 -281,6 +291,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
@@@ -506,47 -488,6 +508,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++")
  
@@@ -833,33 -774,6 +835,33 @@@ elseif(WIN32
                        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
                        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()
@@@ -1195,22 -1087,6 +1197,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")
@@@ -1530,7 -1406,6 +1532,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)
index ce53ec3ac9b7e228658a0d3dc8b1b5a418efefbc,8f60929135103cb934248755f4bc3f294b6673c1..4f87c194790f629c3ffa0899a6abcf6b2ec3f40b
@@@ -1314,18 -1314,14 +1314,18 @@@ 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
+ /* use flags are not persistent yet, groups might need different tagging, so we do it each time
     when we need to get this info */
  void ntreeSocketUseFlags(bNodeTree *ntree)
  {
@@@ -1865,18 -1861,13 +1865,18 @@@ static void registerShaderNodes(ListBas
        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)
index 7ba0a642cdd7fe64f922d58705c7ad48a42724a5,a9de75dc7d08df2c07fb74a6d2702e05222392df..93ff8ee08fc8bd37a6e4fbee28e9eac652e7c217
@@@ -990,18 -990,22 +990,24 @@@ static void scene_update_tagged_recursi
  /* this is called in main loop, doing tagged updates before redraw */
  void scene_update_tagged(Main *bmain, Scene *scene)
  {
+       /* keep this first */
+       BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
+       /* flush recalc flags to dependencies */
        DAG_ids_flush_tagged(bmain);
  
 +      BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
 +
        scene->physics_settings.quick_cache_step= 0;
  
        /* update all objects: drivers, matrices, displists, etc. flags set
-          by depgraph or manual, no layer check here, gets correct flushed */
+          by depgraph or manual, no layer check here, gets correct flushed
  
+          in the future this should handle updates for all datablocks, not
+          only objects and scenes. - brecht */
        scene_update_tagged_recursive(bmain, scene, scene);
  
-       /* recalc scene animation data here (for sequencer) */
+       /* extra call here to recalc scene animation (for sequencer) */
        {
                AnimData *adt= BKE_animdata_from_id(&scene->id);
                float ctime = BKE_curframe(scene);
                        BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0);
        }
        
+       /* quick point cache updates */
        if (scene->physics_settings.quick_cache_step)
                BKE_ptcache_quick_cache_all(bmain, scene);
  
+       /* notify editors about recalc */
        DAG_ids_check_recalc(bmain);
  
+       /* keep this last */
        BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST);
-       /* 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))
@@@ -1033,7 -1037,8 +1039,8 @@@ void scene_update_for_newframe(Main *bm
        Scene *sce_iter;
  
        /* keep this first */
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_PRE);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
  
        sound_set_cfra(sce->r.cfra);
        
                        DAG_scene_sort(bmain, sce_iter);
        }
  
+       /* flush recalc flags to dependencies, if we were only changing a frame
+          this would not be necessary, but if a user or a script has modified
+          some datablock before scene_update_tagged was called, we need the flush */
+       DAG_ids_flush_tagged(bmain);
  
        /* Following 2 functions are recursive
         * so dont call within 'scene_update_tagged_recursive' */
        DAG_scene_update_flags(bmain, sce, lay, TRUE);   // only stuff that moves or needs display still
  
 +      BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_SCENE_UPDATE_PRE);
 +
        /* All 'standard' (i.e. without any dependencies) animation is handled here,
         * with an 'local' to 'macro' order of evaluation. This should ensure that
         * settings stored nestled within a hierarchy (i.e. settings in a Texture block
        scene_update_tagged_recursive(bmain, sce, sce);
  
        /* keep this last */
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_SCENE_UPDATE_POST);
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_POST);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST);
  
        DAG_ids_clear_recalc(bmain);
  }
index c8b6c030d616d9450b69dda60ab41920b560f89e,986e0e2b55287bffe6560e521f69ac216f79dc3d..b6a371707bbb84d73c61f0274b1d1c477afb59cc
@@@ -1511,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);
 +                                              glVertex3fv(vdb->co);
 +
 +                                              if(x != gridFaces-1)
 +                                                      a++;
 +                                      }
 +
 +                                      vda = &faceGridData[(y+0)*gridSize + x];
 +                                      vdb = &faceGridData[(y+1)*gridSize + x];
 +
 +                                      PASSATTRIB(0, 0, 3);
 +                                      glNormal3fv(vda->no);
 +                                      glVertex3fv(vda->co);
 +
 +                                      PASSATTRIB(0, 1, 2);
 +                                      glNormal3fv(vdb->no);
 +                                      glVertex3fv(vdb->co);
 +
 +                                      glEnd();
 +
 +                                      a++;
 +                              }
 +                      } else {
 +                              glBegin(GL_QUADS);
 +                              for (y=0; y<gridFaces; y++) {
 +                                      for (x=0; x<gridFaces; x++) {
 +                                              float *aco = faceGridData[(y+0)*gridSize + x].co;
 +                                              float *bco = faceGridData[(y+0)*gridSize + x + 1].co;
 +                                              float *cco = faceGridData[(y+1)*gridSize + x + 1].co;
 +                                              float *dco = faceGridData[(y+1)*gridSize + x].co;
 +
 +                                              ccgDM_glNormalFast(aco, bco, cco, dco);
 +
 +                                              PASSATTRIB(0, 1, 1);
 +                                              glVertex3fv(dco);
 +                                              PASSATTRIB(1, 1, 2);
 +                                              glVertex3fv(cco);
 +                                              PASSATTRIB(1, 0, 3);
 +                                              glVertex3fv(bco);
 +                                              PASSATTRIB(0, 0, 0);
 +                                              glVertex3fv(aco);
 +                                              
 +                                              a++;
 +                                      }
 +                              }
 +                              glEnd();
 +                      }
 +              }
 +      }
 +
 +#undef PASSATTRIB
 +
 +      ccgFaceIterator_free(fi);
 +}
 +
 +
  static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), unsigned char *col1, unsigned char *col2) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
@@@ -1747,6 -1598,9 +1747,9 @@@ static void ccgDM_drawFacesTex_common(D
        if(!mcol)
                mcol = dm->getFaceDataArray(dm, CD_MCOL);
  
+       if(!mcol)
+               mcol = dm->getFaceDataArray(dm, CD_TEXTURE_MCOL);
        totface = ccgSubSurf_getNumFaces(ss);
        for(i = 0; i < totface; i++) {
                CCGFace *f = ccgdm->faceMap[i].face;
@@@ -2528,7 -2382,6 +2531,7 @@@ static CCGDerivedMesh *getCCGDerivedMes
        ccgdm->dm.drawMappedFaces = ccgDM_drawMappedFaces;
        ccgdm->dm.drawMappedFacesTex = ccgDM_drawMappedFacesTex;
        ccgdm->dm.drawMappedFacesGLSL = ccgDM_drawMappedFacesGLSL;
 +      ccgdm->dm.drawMappedFacesMat = ccgDM_drawMappedFacesMat;
        ccgdm->dm.drawUVEdges = ccgDM_drawUVEdges;
  
        ccgdm->dm.drawMappedEdgesInterp = ccgDM_drawMappedEdgesInterp;
index 5c59ae20c7b7ca113feeef0278ce1ef3437f6576,678d0e1406f4ebbbc521cd59f909b1d91a69a607..c0d52747d568006de04e62aaa1fabe8d27cb2daa
@@@ -2055,103 -2055,9 +2055,103 @@@ static void lib_link_nodetree(FileData 
        }
  }
  
 +static void ntree_tmp_cycles_emission_version_patch(FileData *fd, Library *lib, bNodeTree *ntree)
 +{
 +      bNode *node;
 +      bNodeSocket *sock;
 +      bNodeSocketValueFloat *valfloat;
 +
 +      for(node=ntree->nodes.first; node; node=node->next) {
 +              if(node->type == SH_NODE_EMISSION) {
 +                      for(sock=node->inputs.first; sock; sock=sock->next) {
 +                              if(strcmp(sock->name, "Strength") == 0) {
 +                                      valfloat= sock->default_value;
 +                                      valfloat->value /= M_PI;
 +                              }
 +                      }
 +              }
 +              else if(node->type == NODE_GROUP) {
 +                      bNodeTree *ntree= newlibadr(fd, lib, node->id);
 +
 +                      if(ntree)
 +                              ntree_tmp_cycles_emission_version_patch(fd, lib, ntree);
 +              }
 +      }
 +}
 +
 +static void ntree_tmp_cycles_version_patch(bNodeTree *ntree)
 +{
 +      bNode *node;
 +      bNodeSocket *sock;
 +
 +      for(node=ntree->nodes.first; node; node=node->next) {
 +              if(node->type == SH_NODE_FRESNEL) {
 +
 +                      for(sock=node->inputs.first; sock; sock=sock->next) {
 +                              if(strcmp(sock->name, "Fresnel") == 0) {
 +                                      bNodeSocket *osock;
 +
 +                                      node->type = SH_NODE_BLEND_WEIGHT;
 +                                      strcpy(sock->name, "Blend");
 +
 +                                      for(osock=node->outputs.first; osock; osock=osock->next)
 +                                              if(strcmp(osock->name, "Fac") == 0)
 +                                                      strcpy(osock->name, "Fresnel");
 +                              }
 +                      }
 +              }
 +              else {
 +                      for(sock=node->inputs.first; sock; sock=sock->next) {
 +                              if(strcmp(sock->name, "Closure1") == 0)
 +                                      strcpy(sock->name, "Shader1");
 +                              if(strcmp(sock->name, "Closure2") == 0)
 +                                      strcpy(sock->name, "Shader2");
 +
 +                              if(strcmp(sock->name, "Color1") == 0)
 +                                      strcpy(sock->name, "Color");
 +                              if(strcmp(sock->name, "Color2") == 0)
 +                                      strcpy(sock->name, "Color");
 +
 +                              if(strcmp(sock->name, "Vector1") == 0)
 +                                      strcpy(sock->name, "Vector");
 +                              if(strcmp(sock->name, "Vector2") == 0)
 +                                      strcpy(sock->name, "Vector");
 +
 +                              if(strcmp(sock->name, "Value1") == 0)
 +                                      strcpy(sock->name, "Value");
 +                              if(strcmp(sock->name, "Value2") == 0)
 +                                      strcpy(sock->name, "Value");
 +
 +                              if(strcmp(sock->name, "Shader1") == 0)
 +                                      strcpy(sock->name, "Shader");
 +                              if(strcmp(sock->name, "Shader2") == 0)
 +                                      strcpy(sock->name, "Shader");
 +
 +                              if(node->type == SH_NODE_OUTPUT_MATERIAL ||
 +                                 node->type == SH_NODE_OUTPUT_WORLD ||
 +                                 node->type == SH_NODE_OUTPUT_LAMP) {
 +                                      if(strcmp(sock->name, "Shader") == 0)
 +                                              strcpy(sock->name, "Surface");
 +                              }
 +
 +                              if(strcmp(sock->name, "Fresnel") == 0) {
 +                                      strcpy(sock->name, "IOR");
 +                                      sock->ns.vec[0] = 1.0f/MAX2(1.0f - sock->ns.vec[0], 1e-5f);
 +                              }
 +                      }
 +
 +                      for(sock=node->outputs.first; sock; sock=sock->next)
 +                              if(strcmp(sock->name, "Closure") == 0)
 +                                      strcpy(sock->name, "Shader");
 +              }
 +      }
 +}
 +
  static void lib_nodetree_init_types_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
  {
        bNode *node;
 +
 +      ntree_tmp_cycles_version_patch(ntree);
        
        ntreeInitTypes(ntree);
        
@@@ -5613,7 -5519,6 +5613,7 @@@ static void direct_link_screen(FileDat
                        else if(sl->spacetype==SPACE_BUTS) {
                                SpaceButs *sbuts= (SpaceButs *)sl;
                                sbuts->path= NULL;
 +                              sbuts->texuser= NULL;
                        }
                        else if(sl->spacetype==SPACE_CONSOLE) {
                                SpaceConsole *sconsole= (SpaceConsole *)sl;
@@@ -5944,7 -5849,7 +5944,7 @@@ static BHead *read_libblock(FileData *f
        if(id->flag & LIB_FAKEUSER) id->us= 1;
        else id->us= 0;
        id->icon_id = 0;
 -      id->flag &= ~LIB_ID_RECALC;
 +      id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
  
        /* this case cannot be direct_linked: it's just the ID part */
        if(bhead->code==ID_ID) {
@@@ -7142,40 -7047,13 +7142,40 @@@ static void do_versions_nodetree_defaul
                do_versions_socket_default_value(sock);
  }
  
 +static void do_versions_nodetree_clear_dynamic_sockets(bNodeTree *ntree)
 +{
 +      /* conflict with cycles flag .. */
 +      bNodeSocket *sock;
 +
 +      for (sock=ntree->inputs.first; sock; sock=sock->next) {
 +              if (sock->flag & SOCK_DYNAMIC) {
 +                      sock->flag &= ~SOCK_DYNAMIC;
 +                      sock->flag |= SOCK_COLLAPSED;
 +              }
 +      }
 +      for (sock=ntree->outputs.first; sock; sock=sock->next) {
 +              if (sock->flag & SOCK_DYNAMIC) {
 +                      sock->flag &= ~SOCK_DYNAMIC;
 +                      sock->flag |= SOCK_COLLAPSED;
 +              }
 +      }
 +}
 +
  static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree)
  {
        bNodeSocket *sock;
 -      for (sock=ntree->inputs.first; sock; sock=sock->next)
 -              sock->flag |= SOCK_DYNAMIC;
 -      for (sock=ntree->outputs.first; sock; sock=sock->next)
 -              sock->flag |= SOCK_DYNAMIC;
 +      for (sock=ntree->inputs.first; sock; sock=sock->next) {
 +              if(sock->flag & SOCK_DYNAMIC)
 +                      sock->flag |= SOCK_COLLAPSED;
 +              else
 +                      sock->flag |= SOCK_DYNAMIC;
 +      }
 +      for (sock=ntree->outputs.first; sock; sock=sock->next) {
 +              if(sock->flag & SOCK_DYNAMIC)
 +                      sock->flag |= SOCK_COLLAPSED;
 +              else
 +                      sock->flag |= SOCK_DYNAMIC;
 +      }
  }
  
  void convert_tface_mt(FileData *fd, Main *main)
@@@ -12121,42 -11999,24 +12121,42 @@@ static void do_versions(FileData *fd, L
                        /* Convert default socket values from bNodeStack */
                        Scene *sce;
                        Material *mat;
 +                      Lamp *la;
                        Tex *tex;
                        bNodeTree *ntree;
 +                      World *wo;
 +
                        for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
                                do_versions_nodetree_default_value(ntree);
                                ntree->update |= NTREE_UPDATE;
                        }
                        for (sce=main->scene.first; sce; sce=sce->id.next)
                                if (sce->nodetree) {
 +                              do_versions_nodetree_clear_dynamic_sockets(sce->nodetree);
                                do_versions_nodetree_default_value(sce->nodetree);
                                sce->nodetree->update |= NTREE_UPDATE;
                        }
                        for (mat=main->mat.first; mat; mat=mat->id.next)
                                if (mat->nodetree) {
 +                              do_versions_nodetree_clear_dynamic_sockets(mat->nodetree);
                                do_versions_nodetree_default_value(mat->nodetree);
                                mat->nodetree->update |= NTREE_UPDATE;
                        }
 +                      for (la=main->lamp.first; la; la=la->id.next)
 +                              if (la->nodetree) {
 +                              do_versions_nodetree_clear_dynamic_sockets(la->nodetree);
 +                              do_versions_nodetree_default_value(la->nodetree);
 +                              la->nodetree->update |= NTREE_UPDATE;
 +                      }
 +                      for (wo=main->world.first; wo; wo=wo->id.next)
 +                              if (wo->nodetree) {
 +                              do_versions_nodetree_clear_dynamic_sockets(wo->nodetree);
 +                              do_versions_nodetree_default_value(wo->nodetree);
 +                              wo->nodetree->update |= NTREE_UPDATE;
 +                      }
                        for (tex=main->tex.first; tex; tex=tex->id.next)
                                if (tex->nodetree) {
 +                              do_versions_nodetree_clear_dynamic_sockets(tex->nodetree);
                                do_versions_nodetree_default_value(tex->nodetree);
                                tex->nodetree->update |= NTREE_UPDATE;
                        }
  
        }
  
-       /* put compatibility code here until next subversion bump */
-       {
 +      if(main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 5)) {
 +              Scene *sce;
 +              Base *base;
 +              Material *ma;
 +
 +              /* compatibility tweak */
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      if(strcmp(sce->r.engine, "CYCLES") == 0) {
 +                              for(base = sce->base.first; base; base=base->next) {
 +                                      Object *ob= newlibadr(fd, lib, base->object);
 +
 +                                      if(ob && ob->type == OB_LAMP) {
 +                                              Lamp *la= newlibadr(fd, lib, ob->data);
 +                                              if(la)
 +                                                      la->area_size= 0.0f;
 +                                      }
 +                              }
 +                      }
 +              }
 +
 +              for(ma = main->mat.first; ma; ma= ma->id.next)
 +                      if(ma->nodetree)
 +                              ntree_tmp_cycles_emission_version_patch(fd, lib, ma->nodetree);
 +      }
 +
+       if (main->versionfile < 260){
                {
                        /* set default alpha value of Image outputs in image and render layer nodes to 0 */
                        Scene *sce;
                                }
                        }
                }
+       }
+       if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)){
+               Object *ob;
+               for (ob= main->object.first; ob; ob= ob->id.next) {
+                       ob->collision_boundtype= ob->boundtype;
+               }
+               {
+                       Camera *cam;
+                       for(cam= main->camera.first; cam; cam= cam->id.next) {
+                               if (cam->sensor_x < 0.01)
+                                       cam->sensor_x = DEFAULT_SENSOR_WIDTH;
+                               if (cam->sensor_y < 0.01)
+                                       cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
+                       }
+               }
+       }
+       /* put compatibility code here until next subversion bump */
+       {
+               
        }
  
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
index 99412853ab9e91f55c4c3f03c35e1a4c8b336d89,6b6003fb098ae646be22a1ad6dc9102eb5de76b2..dc6a647cadad506400ca0a553fccb247f5cf1aa3
@@@ -57,6 -57,7 +57,7 @@@
  #include "IMB_imbuf_types.h"
  
  #include "DNA_brush_types.h"
+ #include "DNA_camera_types.h"
  #include "DNA_mesh_types.h"
  #include "DNA_meshdata_types.h"
  #include "DNA_node_types.h"
@@@ -77,7 -78,6 +78,7 @@@
  #include "BKE_object.h"
  #include "BKE_paint.h"
  #include "BKE_report.h"
 +#include "BKE_scene.h"
  
  #include "BIF_gl.h"
  #include "BIF_glutil.h"
@@@ -87,7 -87,6 +88,7 @@@
  #include "ED_image.h"
  #include "ED_screen.h"
  #include "ED_sculpt.h"
 +#include "ED_uvedit.h"
  #include "ED_view3d.h"
  
  #include "WM_api.h"
@@@ -480,40 -479,6 +481,40 @@@ static void image_undo_free(ListBase *l
                MEM_freeN(tile->rect);
  }
  
 +/* get active image for face depending on old/new shading system */
 +
 +static Image *imapaint_face_image(const ImagePaintState *s, int face_index)
 +{
 +      Image *ima;
 +
 +      if(scene_use_new_shading_nodes(s->scene)) {
 +              MFace *mf = s->me->mface+face_index;
 +              ED_object_get_active_image(s->ob, mf->mat_nr, &ima, NULL);
 +      }
 +      else {
 +              MTFace *tf = s->me->mtface+face_index;
 +              ima = tf->tpage;
 +      }
 +
 +      return ima;
 +}
 +
 +static Image *project_paint_face_image(const ProjPaintState *ps, int face_index)
 +{
 +      Image *ima;
 +
 +      if(scene_use_new_shading_nodes(ps->scene)) {
 +              MFace *mf = ps->dm_mface+face_index;
 +              ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL);
 +      }
 +      else {
 +              MTFace *tf = ps->dm_mtface+face_index;
 +              ima = tf->tpage;
 +      }
 +
 +      return ima;
 +}
 +
  /* fast projection bucket array lookup, use the safe version for bound checking  */
  static int project_bucket_offset(const ProjPaintState *ps, const float projCoSS[2])
  {
@@@ -686,7 -651,6 +687,7 @@@ static int project_paint_PickColor(cons
        int side;
        int face_index;
        MTFace *tf;
 +      Image *ima;
        ImBuf *ibuf;
        int xi, yi;
        
        else { /* QUAD */
                interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[2], tf->uv[3], w);
        }
 -      
 -      ibuf = tf->tpage->ibufs.first; /* we must have got the imbuf before getting here */
 +
 +      ima = project_paint_face_image(ps, face_index);
 +      ibuf = ima->ibufs.first; /* we must have got the imbuf before getting here */
        if (!ibuf) return 0;
        
        if (interp) {
@@@ -1071,9 -1034,6 +1072,9 @@@ static int check_seam(const ProjPaintSt
                        
                        /* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */
                        if (i2_fidx != -1) {
 +                              Image *tpage = project_paint_face_image(ps, face_index);
 +                              Image *orig_tpage = project_paint_face_image(ps, orig_face);
 +
                                /* This IS an adjacent face!, now lets check if the UVs are ok */
                                tf = ps->dm_mtface + face_index;
                                
                                *orig_fidx = (i1_fidx < i2_fidx) ? i1_fidx : i2_fidx;
                                
                                /* first test if they have the same image */
 -                              if (    (orig_tf->tpage == tf->tpage) &&
 +                              if (    (orig_tpage == tpage) &&
                                                cmp_uv(orig_tf->uv[orig_i1_fidx], tf->uv[i1_fidx]) &&
                                                cmp_uv(orig_tf->uv[orig_i2_fidx], tf->uv[i2_fidx]) )
                                {
@@@ -1329,10 -1289,9 +1330,10 @@@ static float project_paint_uvpixel_mask
        if (ps->do_layer_stencil) {
                /* another UV layers image is masking this one's */
                ImBuf *ibuf_other;
 +              Image *other_tpage = project_paint_face_image(ps, face_index);
                const MTFace *tf_other = ps->dm_mtface_stencil + face_index;
                
 -              if (tf_other->tpage && (ibuf_other = BKE_image_get_ibuf(tf_other->tpage, NULL))) {
 +              if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) {
                        /* BKE_image_get_ibuf - TODO - this may be slow */
                        unsigned char rgba_ub[4];
                        float rgba_f[4];
@@@ -1486,10 -1445,9 +1487,10 @@@ static ProjPixel *project_paint_uvpixel
        if (ps->tool==PAINT_TOOL_CLONE) {
                if (ps->dm_mtface_clone) {
                        ImBuf *ibuf_other;
 +                      Image *other_tpage = project_paint_face_image(ps, face_index);
                        const MTFace *tf_other = ps->dm_mtface_clone + face_index;
                        
 -                      if (tf_other->tpage && (ibuf_other = BKE_image_get_ibuf(tf_other->tpage, NULL))) {
 +                      if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) {
                                /* BKE_image_get_ibuf - TODO - this may be slow */
                                
                                if (ibuf->rect_float) {
@@@ -2707,8 -2665,11 +2708,8 @@@ static void project_bucket_init(const P
        LinkNode *node;
        int face_index, image_index=0;
        ImBuf *ibuf = NULL;
 +      Image *tpage_last = NULL, *tpage;
        Image *ima = NULL;
 -      MTFace *tf;
 -      
 -      Image *tpage_last = NULL;
 -      
  
        if (ps->image_tot==1) {
                /* Simple loop, no context switching */
                        face_index = GET_INT_FROM_POINTER(node->link);
                                
                        /* Image context switching */
 -                      tf = ps->dm_mtface+face_index;
 -                      if (tpage_last != tf->tpage) {
 -                              tpage_last = tf->tpage;
 +                      tpage = project_paint_face_image(ps, face_index);
 +                      if (tpage_last != tpage) {
 +                              tpage_last = tpage;
  
                                for (image_index=0; image_index < ps->image_tot; image_index++) {
                                        if (ps->projImages[image_index].ima == tpage_last) {
@@@ -2896,7 -2857,7 +2897,7 @@@ static void project_paint_begin(ProjPai
        LinkNode *node;
        
        ProjPaintImage *projIma;
 -      Image *tpage_last = NULL;
 +      Image *tpage_last = NULL, *tpage;
        
        /* Face vars */
        MFace *mf;
                                Object *camera= ps->scene->camera;
  
                                /* dont actually use these */
-                               float _viewdx, _viewdy, _ycor, _lens=0.0f;
+                               float _viewdx, _viewdy, _ycor, _lens=0.0f, _sensor_x=DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
+                               short _sensor_fit= CAMERA_SENSOR_FIT_AUTO;
                                rctf _viewplane;
  
                                /* viewmat & viewinv */
                                object_camera_mode(&ps->scene->r, camera);
                                object_camera_matrix(&ps->scene->r, camera, ps->winx, ps->winy, 0,
                                                winmat, &_viewplane, &ps->clipsta, &ps->clipend,
-                                               &_lens, &_ycor, &_viewdx, &_viewdy);
+                                               &_lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_ycor, &_viewdx, &_viewdy);
  
                                ps->is_ortho= (ps->scene->r.mode & R_ORTHO) ? 1 : 0;
                        }
                }
  #endif
                
 -              if (tf->tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) {
 +              tpage = project_paint_face_image(ps, face_index);
 +
 +              if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) {
                        
                        float *v1coSS, *v2coSS, *v3coSS, *v4coSS=NULL;
                        
                                }
                        }
                        
 -                      if (tpage_last != tf->tpage) {
 +                      if (tpage_last != tpage) {
                                
 -                              image_index = BLI_linklist_index(image_LinkList, tf->tpage);
 +                              image_index = BLI_linklist_index(image_LinkList, tpage);
                                
 -                              if (image_index==-1 && BKE_image_get_ibuf(tf->tpage, NULL)) { /* MemArena dosnt have an append func */
 -                                      BLI_linklist_append(&image_LinkList, tf->tpage);
 +                              if (image_index==-1 && BKE_image_get_ibuf(tpage, NULL)) { /* MemArena dosnt have an append func */
 +                                      BLI_linklist_append(&image_LinkList, tpage);
                                        image_index = ps->image_tot;
                                        ps->image_tot++;
                                }
                                
 -                              tpage_last = tf->tpage;
 +                              tpage_last = tpage;
                        }
                        
                        if (image_index != -1) {
@@@ -4502,7 -4462,7 +4504,7 @@@ static int imapaint_paint_stroke(ViewCo
                ) {
                        ImBuf *ibuf;
                        
 -                      newimage = (s->me->mtface+newfaceindex)->tpage;
 +                      newimage = imapaint_face_image(s, newfaceindex);
                        ibuf= BKE_image_get_ibuf(newimage, s->sima? &s->sima->iuser: NULL);
  
                        if(ibuf && ibuf->rect)
index d2b97597cb88c7a09e3b02857889a1296abc5994,db8d9b1ddf17d2f7522ce9d03e2e62846839cb0a..533d2555b26dad65c4bc1dc1ab747f20d69d615f
@@@ -95,14 -95,6 +95,14 @@@ static void node_sync_cb(bContext *UNUS
        }
  }
  
 +static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
 +                                                        bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
 +                                                        const char *UNUSED(name), int x, int y, int width)
 +{
 +      uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
 +}
 +
 +
  static void node_socket_button_default(const bContext *C, uiBlock *block,
                                                                bNodeTree *ntree, bNode *node, bNodeSocket *sock,
                                                                const char *name, int x, int y, int width)
@@@ -850,6 -842,11 +850,11 @@@ static void node_draw_group(const bCont
        }
  }
  
+ void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
+ {
+       uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
+ }
  static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
  {
        uiItemR(layout, ptr, "max_iterations", 0, NULL, 0);
@@@ -875,7 -872,7 +880,7 @@@ static void node_common_set_butfunc(bNo
  {
        switch(ntype->type) {
                case NODE_GROUP:
//                    ntype->uifunc= node_common_buts_group;
                      ntype->uifunc= node_uifunc_group;
                        ntype->drawfunc= node_draw_group;
                        ntype->drawupdatefunc= node_update_group;
                        break;
@@@ -943,7 -940,7 +948,7 @@@ static void node_shader_buts_mapping(ui
  {
        uiLayout *row;
        
 -      uiItemL(layout, "Location:", ICON_NONE);
 +      uiItemL(layout, "Translation:", ICON_NONE);
        row= uiLayoutRow(layout, 1);
        uiItemR(row, ptr, "location", 0, "", ICON_NONE);
        
        row= uiLayoutRow(layout, 1);
        uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
        
 +#if 0
        row= uiLayoutRow(layout, 1);
        uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
        uiItemR(row, ptr, "min", 0, "", ICON_NONE);
        row= uiLayoutRow(layout, 1);
        uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
        uiItemR(row, ptr, "max", 0, "", ICON_NONE);
 -      
 +#endif        
  }
  
  static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@@ -990,103 -986,6 +995,103 @@@ static void node_shader_buts_geometry(u
        }
  }
  
 +/*static void node_layout_prop(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname)
 +{
 +      if(C && CTX_wm_space_node(C)) {
 +              uiItemR(layout, ptr, propname, 0, NULL, ICON_NONE);
 +      }
 +      else {
 +              uiLayout *split = uiLayoutSplit(layout, 0.35f, 0);
 +              PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 +
 +              uiItemL(uiLayoutColumn(split, 0), RNA_property_ui_name(prop), ICON_NONE);
 +              uiItemR(uiLayoutColumn(split, 0), ptr, propname, 0, "", ICON_NONE);
 +      }
 +}*/
 +
 +static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "attribute_name", 0, "Name", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
 +{
 +      //uiItemR(layout, ptr, "image", 0, "", ICON_NONE);
 +      uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
 +      uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_blend(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "progression", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "axis", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_clouds(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_distnoise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_distortion", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_marble(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "marble_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
 +      uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_stucci(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "stucci_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "distance_metric", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_tex_wood(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "wood_type", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
 +}
 +
 +static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
 +}
 +
  static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
  { 
        Main *bmain= CTX_data_main(C);
@@@ -1170,52 -1069,9 +1175,52 @@@ static void node_shader_set_butfunc(bNo
                case SH_NODE_VECT_MATH: 
                        ntype->uifunc= node_shader_buts_vect_math;
                        break; 
 -              case SH_NODE_GEOMETRY:
 +              case SH_NODE_GEOM:
                        ntype->uifunc= node_shader_buts_geometry;
                        break;
 +              case SH_NODE_ATTRIBUTE:
 +                      ntype->uifunc= node_shader_buts_attribute;
 +                      break;
 +              case SH_NODE_TEX_SKY:
 +                      ntype->uifunc= node_shader_buts_tex_sky;
 +                      break;
 +              case SH_NODE_TEX_IMAGE:
 +                      ntype->uifunc= node_shader_buts_tex_image;
 +                      break;
 +              case SH_NODE_TEX_ENVIRONMENT:
 +                      ntype->uifunc= node_shader_buts_tex_image;
 +                      break;
 +              case SH_NODE_TEX_BLEND:
 +                      ntype->uifunc= node_shader_buts_tex_blend;
 +                      break;
 +              case SH_NODE_TEX_CLOUDS:
 +                      ntype->uifunc= node_shader_buts_tex_clouds;
 +                      break;
 +              case SH_NODE_TEX_DISTNOISE:
 +                      ntype->uifunc= node_shader_buts_tex_distnoise;
 +                      break;
 +              case SH_NODE_TEX_MAGIC:
 +                      ntype->uifunc= node_shader_buts_tex_magic;
 +                      break;
 +              case SH_NODE_TEX_MARBLE:
 +                      ntype->uifunc= node_shader_buts_tex_marble;
 +                      break;
 +              case SH_NODE_TEX_MUSGRAVE:
 +                      ntype->uifunc= node_shader_buts_tex_musgrave;
 +                      break;
 +              case SH_NODE_TEX_STUCCI:
 +                      ntype->uifunc= node_shader_buts_tex_stucci;
 +                      break;
 +              case SH_NODE_TEX_VORONOI:
 +                      ntype->uifunc= node_shader_buts_tex_voronoi;
 +                      break;
 +              case SH_NODE_TEX_WOOD:
 +                      ntype->uifunc= node_shader_buts_tex_wood;
 +                      break;
 +              case SH_NODE_BSDF_GLOSSY:
 +              case SH_NODE_BSDF_GLASS:
 +                      ntype->uifunc= node_shader_buts_glossy;
 +                      break;
                case NODE_DYNAMIC:
                        ntype->uifunc= node_shader_buts_dynamic;
                        break;
@@@ -2185,9 -2041,6 +2190,9 @@@ void ED_init_node_butfuncs(void
                        case SOCK_RGBA:
                                stype->buttonfunc = node_socket_button_color;
                                break;
 +                      case SOCK_SHADER:
 +                              stype->buttonfunc = node_socket_button_label;
 +                              break;
                        default:
                                stype->buttonfunc = NULL;
                        }
index 832c4795f150c808d0e4f21a9d312b1363ccf0a0,6a8e850a4eacff35b7db63d47f323f64b7878763..41c48a1af582718384ef3b3a3429ed75d59f2a7c
@@@ -73,7 -73,6 +73,7 @@@
  #include "BKE_paint.h"
  #include "BKE_particle.h"
  #include "BKE_pointcache.h"
 +#include "BKE_scene.h"
  #include "BKE_unit.h"
  
  #include "smoke_API.h"
  
  /* this condition has been made more complex since editmode can draw textures */
  #define CHECK_OB_DRAWTEXTURE(vd, dt) \
 -      ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \
 +      ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt>OB_SOLID) || \
        (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX))
  
- static void draw_bounding_volume(Scene *scene, Object *ob);
+ static void draw_bounding_volume(Scene *scene, Object *ob, short type);
  
  static void drawcube_size(float size);
  static void drawcircle_size(float size);
@@@ -215,8 -214,6 +215,8 @@@ int draw_glsl_material(Scene *scene, Ob
                return 0;
        if(ob==OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
                return 0;
 +      if(scene_use_new_shading_nodes(scene))
 +              return 0;
        
        return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID);
  }
@@@ -2706,7 -2703,7 +2706,7 @@@ static void draw_mesh_fancy(Scene *scen
  
        if(dt==OB_BOUNDBOX) {
                if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
-                       draw_bounding_volume(scene, ob);
+                       draw_bounding_volume(scene, ob, ob->boundtype);
        }
        else if(hasHaloMat || (totface==0 && totedge==0)) {
                glPointSize(1.5);
@@@ -5511,7 -5508,7 +5511,7 @@@ static void draw_bb_quadric(BoundBox *b
        gluDeleteQuadric(qobj); 
  }
  
- static void draw_bounding_volume(Scene *scene, Object *ob)
+ static void draw_bounding_volume(Scene *scene, Object *ob, short type)
  {
        BoundBox *bb= NULL;
        
        
        if(bb==NULL) return;
        
-       if(ob->boundtype==OB_BOUND_BOX) draw_box(bb->vec);
-       else draw_bb_quadric(bb, ob->boundtype);
+       if(type==OB_BOUND_BOX) draw_box(bb->vec);
+       else draw_bb_quadric(bb, type);
        
  }
  
@@@ -6104,7 -6101,7 +6104,7 @@@ void draw_object(Scene *scene, ARegion 
                        }
                        else if(dt==OB_BOUNDBOX) {
                                if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
-                                       draw_bounding_volume(scene, ob);
+                                       draw_bounding_volume(scene, ob, ob->boundtype);
                        }
                        else if(ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb))
                                empty_object= drawDispList(scene, v3d, rv3d, base, dt);
                        }
                        else if(dt==OB_BOUNDBOX) {
                                if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
-                                       draw_bounding_volume(scene, ob);
+                                       draw_bounding_volume(scene, ob, ob->boundtype);
                        }
                        else if(ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
                                empty_object= drawDispList(scene, v3d, rv3d, base, dt);
                                drawmball(scene, v3d, rv3d, base, dt);
                        else if(dt==OB_BOUNDBOX) {
                                if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
-                                       draw_bounding_volume(scene, ob);
+                                       draw_bounding_volume(scene, ob, ob->boundtype);
                        }
                        else 
                                empty_object= drawmball(scene, v3d, rv3d, base, dt);
                        }
                }
  
+               if(ob->gameflag & OB_BOUNDS) {
+                       if(ob->boundtype!=ob->collision_boundtype || (dtx & OB_BOUNDBOX)==0) {
+                               setlinestyle(2);
+                               draw_bounding_volume(scene, ob, ob->collision_boundtype);
+                               setlinestyle(0);
+                       }
+               }
                /* draw extra: after normal draw because of makeDispList */
                if(dtx && (G.f & G_RENDER_OGL)==0) {
  
                                drawaxes(1.0f, OB_ARROWS);
                        }
                        if(dtx & OB_BOUNDBOX) {
-                               if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
-                                       draw_bounding_volume(scene, ob);
+                               draw_bounding_volume(scene, ob, ob->boundtype);
                        }
                        if(dtx & OB_TEXSPACE) drawtexspace(ob);
                        if(dtx & OB_DRAWNAME) {
index 3d2558699eff5dbf761701f0b94f69aa94c2e762,aa69e7121e0d35aec6fba55236aa7100a671b229..a8cb436a942802af0b2152fffc7e69df76d437ed
@@@ -921,17 -921,34 +921,34 @@@ static void draw_selected_name(Scene *s
        BLF_draw_default(offset,  10, 0.0f, info, sizeof(info)-1);
  }
  
- void view3d_viewborder_size_get(Scene *scene, ARegion *ar, float size_r[2])
+ void view3d_viewborder_size_get(Scene *scene, Object *camob, ARegion *ar, float size_r[2])
  {
-       float winmax= MAX2(ar->winx, ar->winy);
        float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
-       
-       if(aspect > 1.0f) {
-               size_r[0]= winmax;
-               size_r[1]= winmax/aspect;
-       } else {
-               size_r[0]= winmax*aspect;
-               size_r[1]= winmax;
+       short sensor_fit= CAMERA_SENSOR_FIT_AUTO;
+       if(camob && camob->type==OB_CAMERA) {
+               Camera *cam= (Camera *)camob->data;
+               sensor_fit= cam->sensor_fit;
+       }
+       if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) {
+               float winmax= MAX2(ar->winx, ar->winy);
+               if(aspect > 1.0f) {
+                       size_r[0]= winmax;
+                       size_r[1]= winmax/aspect;
+               } else {
+                       size_r[0]= winmax*aspect;
+                       size_r[1]= winmax;
+               }
+       }
+       else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
+               size_r[0]= ar->winx;
+               size_r[1]= ar->winx/aspect;
+       }
+       else {
+               size_r[0]= ar->winy*aspect;
+               size_r[1]= ar->winy;
        }
  }
  
@@@ -941,7 -958,7 +958,7 @@@ void ED_view3d_calc_camera_border(Scen
        float size[2];
        float dx= 0.0f, dy= 0.0f;
        
-       view3d_viewborder_size_get(scene, ar, size);
+       view3d_viewborder_size_get(scene, v3d->camera, ar, size);
  
        size[0]= size[0]*zoomfac;
        size[1]= size[1]*zoomfac;
@@@ -1208,6 -1225,21 +1225,21 @@@ static void drawviewborder(Scene *scene
                        uiSetRoundBox(UI_CNR_ALL);
                        uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
                }
+               if (ca && (ca->flag & CAM_SHOWSENSOR)) {
+                       /* assume fixed sensor width for now */
+                       /* float sensor_aspect = ca->sensor_x / ca->sensor_y; */ /* UNUSED */
+                       float sensor_scale = (x2i-x1i) / ca->sensor_x;
+                       float sensor_height = sensor_scale * ca->sensor_y;
+                       float ymid = y1i + (y2i-y1i)/2.f;
+                       float sy1= ymid - sensor_height/2.f;
+                       float sy2= ymid + sensor_height/2.f;
+                       UI_ThemeColorShade(TH_WIRE, 100);
+                       uiDrawBox(GL_LINE_LOOP, x1i, sy1, x2i, sy2, 2.0f);
+               }
        }
  
        setlinestyle(0);
@@@ -2158,18 -2190,11 +2190,18 @@@ CustomDataMask ED_view3d_datamask(Scen
  {
        CustomDataMask mask= 0;
  
 -      if((v3d->drawtype == OB_TEXTURE) || ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) {
 +      if(ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) || ((v3d->drawtype == OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) {
                mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
  
 -              if(scene->gm.matmode == GAME_MAT_GLSL)
 -                      mask |= CD_MASK_ORCO;
 +              if(scene_use_new_shading_nodes(scene)) {
 +                      /* todo: use orco in textured draw mode */
 +                      if(v3d->drawtype == OB_MATERIAL)
 +                              mask |= CD_MASK_ORCO;
 +              }
 +              else {
 +                      if(scene->gm.matmode == GAME_MAT_GLSL)
 +                              mask |= CD_MASK_ORCO;
 +              }
        }
  
        return mask;
@@@ -2403,10 -2428,12 +2435,12 @@@ ImBuf *ED_view3d_draw_offscreen_imbuf(S
        /* render 3d view */
        if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
                float winmat[4][4];
-               float _clipsta, _clipend, _lens, _yco, _dx, _dy;
+               float _clipsta, _clipend, _lens, _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
+               short _sensor_fit= CAMERA_SENSOR_FIT_AUTO;
                rctf _viewplane;
  
-               object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens, &_yco, &_dx, &_dy);
+               object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens,
+                       &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy);
  
                ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
        }
@@@ -2461,9 -2488,10 +2495,10 @@@ ImBuf *ED_view3d_draw_offscreen_imbuf_s
        invert_m4_m4(rv3d.viewmat, rv3d.viewinv);
  
        {
-               float _yco, _dx, _dy;
+               float _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT;
+               short _sensor_fit= CAMERA_SENSOR_FIT_AUTO;
                rctf _viewplane;
-               object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_yco, &_dx, &_dy);
+               object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy);
        }
  
        mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
index be8fe64c753551d79055d177359324594a46dbdd,dedc25092c1c3951212a4b2ded1b59dc1445ec91..88fbdc99f821312d1344de8bb965feba0fd9bdcc
@@@ -138,8 -138,8 +138,9 @@@ void register_node_type_sh_geom(ListBas
  {
        static bNodeType ntype;
  
 -      node_type_base(&ntype, SH_NODE_GEOMETRY, "Geometry", NODE_CLASS_INPUT, NODE_OPTIONS);
 +      node_type_base(&ntype, SH_NODE_GEOM, "Geometry", NODE_CLASS_INPUT, NODE_OPTIONS);
 +      node_type_compatibility(&ntype, NODE_OLD_SHADING);
+       node_type_compatibility(&ntype, NODE_OLD_SHADING);
        node_type_socket_templates(&ntype, NULL, sh_node_geom_out);
        node_type_size(&ntype, 120, 80, 160);
        node_type_init(&ntype, node_shader_init_geometry);
index 80a49ed5ff5491d824d28a3052e00679feb74e75,812844398b8b4d850c3cad6b5682d613bc0e5016..a478affe518d4632d25c5fa9ad8dbb2f2210a0af
@@@ -41,7 -41,6 +41,7 @@@ struct ARegionType
  struct Base;
  struct Brush;
  struct bNodeTree;
 +struct bNodeSocket;
  struct CSG_FaceIteratorDescriptor;
  struct CSG_VertexIteratorDescriptor;
  struct ColorBand;
@@@ -368,10 -367,6 +368,10 @@@ void uiTemplateHistogram(struct uiLayou
  void uiTemplateReportsBanner(struct uiLayout *layout, struct bContext *C, struct wmOperator *op){}
  void uiTemplateWaveform(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand){}
  void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, char* property, int expand){}
 +void uiTemplateNodeLink(struct uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) {}
 +void uiTemplateNodeView(struct uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) {}
 +void uiTemplateTextureUser(struct uiLayout *layout, struct bContext *C) {}
 +void uiTemplateTextureShow(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop) {}
  void uiTemplateKeymapItemProperties(struct uiLayout *layout, struct PointerRNA *ptr){}
  
  /* rna render */
@@@ -394,7 -389,7 +394,7 @@@ void RE_engines_exit() {
  void RE_engine_report(struct RenderEngine *engine, int type, const char *msg) {}
  ListBase R_engines = {NULL, NULL};
  void RE_engine_free(struct RenderEngine *engine) {}
- struct RenderEngineType *RE_engines_find(const char *idname) {}
+ struct RenderEngineType *RE_engines_find(const char *idname) { return NULL; }
  
  /* python */
  struct wmOperatorType *WM_operatortype_find(const char *idname, int quiet){return (struct wmOperatorType *) NULL;}