accident when merge. revert to r37405
authorXiao Xiangquan <xiaoxiangquan@gmail.com>
Sat, 11 Jun 2011 18:15:46 +0000 (18:15 +0000)
committerXiao Xiangquan <xiaoxiangquan@gmail.com>
Sat, 11 Jun 2011 18:15:46 +0000 (18:15 +0000)
37 files changed:
1  2 
build_files/cmake/FindPythonLibsUnix.cmake
build_files/cmake/macros.cmake
release/scripts/modules/console/complete_namespace.py
release/scripts/modules/console_python.py
release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/properties_data_metaball.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_render.py
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/scene.c
source/blender/editors/include/ED_particle.h
source/blender/editors/interface/interface_intern.h
source/blender/editors/object/object_add.c
source/blender/editors/object/object_shapekey.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/render/render_view.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pixelshading.c
source/blenderplayer/CMakeLists.txt
source/creator/CMakeLists.txt
source/creator/creator.c

@@@ -53,17 -53,17 +53,8 @@@ if(NOT DEFINED PYTHON_INCLUDE_DIRS
        if(NOT _Found_PYTHON_H)
                message(FATAL_ERROR "Python.h not found")
        endif()
--      
--      unset(_Found_PYTHON_H)
--      unset(_Python_HEADER)
--      unset(_CURRENT_ABI_FLAGS)
--      unset(_CURRENT_PATH)
--      
  endif()
  
--unset(_Python_ABI_FLAGS)
--unset(_Python_PATHS)
--
  #=============================================================================
  # now the python versions are found
  
@@@ -5,43 -5,47 +5,29 @@@
  # use it instead of include_directories()
  macro(blender_include_dirs
        includes)
--      set(_ALL_INCS "")
--      foreach(_INC ${ARGV})
--              get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
--              list(APPEND _ALL_INCS ${_ABS_INC})
 -      endforeach()
 -      include_directories(${_ALL_INCS})
 -      unset(_INC)
 -      unset(_ABS_INC)
 -      unset(_ALL_INCS)
 -endmacro()
 -macro(blender_include_dirs_sys
 -      includes)
 -      set(_ALL_INCS "")
 -      foreach(_INC ${ARGV})
 -              get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
 -              list(APPEND _ALL_INCS ${_ABS_INC})
++      foreach(inc ${ARGV})
++              get_filename_component(abs_inc ${inc} ABSOLUTE)
++              list(APPEND all_incs ${abs_inc})
        endforeach()
-       include_directories(${_ALL_INCS})
 -      include_directories(SYSTEM ${_ALL_INCS})
--      unset(_INC)
--      unset(_ABS_INC)
--      unset(_ALL_INCS)
++      include_directories(${all_incs})
  endmacro()
  
-       set(_ALL_INCS "")
-       foreach(_INC ${ARGV})
-               get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
-               list(APPEND _ALL_INCS ${_ABS_INC})
-       include_directories(SYSTEM ${_ALL_INCS})
-       unset(_INC)
-       unset(_ABS_INC)
-       unset(_ALL_INCS)
 +
  macro(blender_source_group
        sources)
  
        # Group by location on disk
        source_group("Source Files" FILES CMakeLists.txt)
  
--      foreach(_SRC ${sources})
--              get_filename_component(_SRC_EXT ${_SRC} EXT)
--              if(${_SRC_EXT} MATCHES ".h" OR ${_SRC_EXT} MATCHES ".hpp")
--                      source_group("Header Files" FILES ${_SRC})
++      foreach(SRC ${sources})
++              get_filename_component(SRC_EXT ${SRC} EXT)
++              if(${SRC_EXT} MATCHES ".h" OR ${SRC_EXT} MATCHES ".hpp")
++                      source_group("Header Files" FILES ${SRC})
                else()
--                      source_group("Source Files" FILES ${_SRC})
++                      source_group("Source Files" FILES ${SRC})
                endif()
        endforeach()
--
--      unset(_SRC)
--      unset(_SRC_EXT)
  endmacro()
  
  
@@@ -197,11 -205,11 +183,10 @@@ macro(setup_liblink
        endif()
        if(WITH_IMAGE_OPENEXR)
                if(WIN32 AND NOT UNIX)
--                      foreach(_LOOP_VAR ${OPENEXR_LIB})
--                              target_link_libraries(${target} debug ${_LOOP_VAR}_d)
--                              target_link_libraries(${target} optimized ${_LOOP_VAR})
++                      foreach(loop_var ${OPENEXR_LIB})
++                              target_link_libraries(${target} debug ${loop_var}_d)
++                              target_link_libraries(${target} optimized ${loop_var})
                        endforeach()
--                      unset(_LOOP_VAR)
                else()
                        target_link_libraries(${target} ${OPENEXR_LIB})
                endif()
        endif()
        if(WITH_OPENCOLLADA)
                if(WIN32 AND NOT UNIX)
--                      foreach(_LOOP_VAR ${OPENCOLLADA_LIB})
--                              target_link_libraries(${target} debug ${_LOOP_VAR}_d)
--                              target_link_libraries(${target} optimized ${_LOOP_VAR})
++                      foreach(loop_var ${OPENCOLLADA_LIB})
++                              target_link_libraries(${target} debug ${loop_var}_d)
++                              target_link_libraries(${target} optimized ${loop_var})
                        endforeach()
--                      unset(_LOOP_VAR)
                        target_link_libraries(${target} debug ${PCRE_LIB}_d)
                        target_link_libraries(${target} optimized ${PCRE_LIB})
                        if(EXPAT_LIB)
@@@ -475,13 -483,13 +459,4 @@@ macro(blender_project_hack_post
  
        unset(_reset_standard_cflags_rel)
        unset(_reset_standard_cxxflags_rel)
--
--      # --------------------------------------------------
--      # workaround for omission in cmake 2.8.4's GNU.cmake
--      if(CMAKE_COMPILER_IS_GNUCC)
--              if(NOT DARWIN)
--                      set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
--              endif()
--      endif()
--
  endmacro()
@@@ -37,11 -37,11 +37,6 @@@ def is_dict(obj)
      return hasattr(obj, 'keys') and hasattr(getattr(obj, 'keys'), '__call__')
  
  
--def is_struct_seq(obj):
--    """Returns whether obj is a structured sequence subclass: sys.float_info"""
--    return isinstance(obj, tuple) and hasattr(obj, 'n_fields')
--
--
  def complete_names(word, namespace):
      """Complete variable names or attributes
  
@@@ -179,7 -179,7 +174,7 @@@ def complete(word, namespace, private=T
          if type(obj) in (bool, float, int, str):
              return []
          # an extra char '[', '(' or '.' will be added
--        if hasattr(obj, '__getitem__') and not is_struct_seq(obj):
++        if hasattr(obj, '__getitem__'):
              # list or dictionary
              matches = complete_indices(word, namespace, obj)
          elif hasattr(obj, '__call__'):
@@@ -80,7 -80,7 +80,7 @@@ def get_console(console_id)
      if console_data:
          console, stdout, stderr = console_data
  
--        # XXX, bug in python 3.1.2, 3.2 ? (worked in 3.1.1)
++        # XXX, bug in python 3.1.2 ? (worked in 3.1.1)
          # seems there is no way to clear StringIO objects for writing, have to make new ones each time.
          import io
          stdout = io.StringIO()
@@@ -99,9 -99,9 +99,8 @@@ class DATA_PT_normals(MeshButtonsPanel
          split.prop(mesh, "show_double_sided")
  
  
--class DATA_PT_texture_space(MeshButtonsPanel, bpy.types.Panel):
--    bl_label = "Texture Space"
--    bl_options = {'DEFAULT_CLOSED'}
++class DATA_PT_settings(MeshButtonsPanel, bpy.types.Panel):
++    bl_label = "Settings"
      COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
  
      def draw(self, context):
          mesh = context.mesh
  
          layout.prop(mesh, "texture_mesh")
--
--        layout.separator()
--
          layout.prop(mesh, "use_auto_texspace")
--        row = layout.row()
--        row.column().prop(mesh, "texspace_location", text="Location")
--        row.column().prop(mesh, "texspace_size", text="Size")
++
  
  class DATA_PT_vertex_groups(MeshButtonsPanel, bpy.types.Panel):
      bl_label = "Vertex Groups"
@@@ -70,10 -70,10 +70,6 @@@ class DATA_PT_metaball(DataButtonsPanel
  
          layout.label(text="Update:")
          layout.prop(mball, "update_method", expand=True)
--        
--        row = layout.row()
--        row.column().prop(mball, "texspace_location")
--        row.column().prop(mball, "texspace_size")
  
  
  class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel):
@@@ -483,10 -483,10 +483,11 @@@ class DATA_PT_modifiers(ModifierButtons
          col.label(text="Mode:")
          col.prop(md, "wrap_method", text="")
  
++        split = layout.split(percentage=0.25)
++
++        col = split.column()
++
          if md.wrap_method == 'PROJECT':
--            split = layout.split(percentage=0.25)
--            
--            col = split.column()
              col.label(text="Axis:")
              col.prop(md, "use_project_x")
              col.prop(md, "use_project_y")
              col.prop(md, "use_positive_direction")
  
              col = split.column()
++
              col.label(text="Cull Faces:")
              col.prop(md, "cull_face", expand=True)
  
@@@ -254,7 -376,7 +254,8 @@@ class RENDER_PT_post_processing(RenderB
          col.prop(rd, "use_compositing")
          col.prop(rd, "use_sequencer")
  
--        split.prop(rd, "dither_intensity", text="Dither", slider=True)
++        col = split.column()
++        col.prop(rd, "dither_intensity", text="Dither", slider=True)
  
          layout.separator()
  
@@@ -180,6 -180,6 +180,7 @@@ static void clean_paths(Main *main
        BLI_bpathIterator_free(bpi);
  
        for(scene= main->scene.first; scene; scene= scene->id.next) {
++              BLI_clean(scene->r.backbuf);
                BLI_clean(scene->r.pic);
        }
  }
@@@ -475,7 -476,7 +475,8 @@@ Scene *add_scene(const char *name
        sce->audio.doppler_factor = 1.0;
        sce->audio.speed_of_sound = 343.3;
  
--      BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic));
++      strcpy(sce->r.backbuf, "//backbuf");
++      strcpy(sce->r.pic, U.renderdir);
  
        BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
        sce->r.osa= 8;
@@@ -71,9 -71,9 +71,8 @@@ void PE_undo_push(struct Scene *scene, 
  void PE_undo_step(struct Scene *scene, int step);
  void PE_undo(struct Scene *scene);
  void PE_redo(struct Scene *scene);
++void PE_undo_menu(struct Scene *scene, struct Object *ob);
  int PE_undo_valid(struct Scene *scene);
--void PE_undo_number(struct Scene *scene, int nr);
--char *PE_undo_get_name(struct Scene *scene, int nr, int *active);
  
  #endif /* ED_PARTICLE_H */
  
@@@ -45,7 -45,7 +45,6 @@@ struct uiHandleButtonData
  struct wmEvent;
  struct wmOperatorType;
  struct wmWindow;
--struct wmTimer;
  struct uiStyle;
  struct uiWidgetColors;
  struct uiLayout;
@@@ -108,8 -108,8 +107,8 @@@ typedef enum 
  #define UI_PANEL_MINY 70
  
  /* uiBut->flag */
--#define UI_SELECT             1       /* use when the button is pressed */
--#define UI_SCROLLED           2       /* temp hidden, scrolled away */
++#define UI_SELECT             1 /* use when the button is pressed */
++/*#define UI_MOUSE_OVER       2*/  /*UNUSED, free flag*/
  #define UI_ACTIVE             4
  #define UI_HAS_ICON           8
  #define UI_TEXTINPUT  16
  /* warn: rest of uiBut->flag in UI_interface.h */
  
  /* internal panel drawing defines */
--#define PNL_GRID      (UI_UNIT_Y / 5) /* 4 default */
--#define PNL_HEADER  UI_UNIT_Y         /* 20 default */
++#define PNL_GRID      4
++#define PNL_HEADER  20
  
  /* panel->flag */
  #define PNL_SELECT    1
@@@ -370,7 -370,7 +369,7 @@@ extern void ui_convert_to_unit_alt_name
  extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
  extern int ui_get_but_string_max_length(uiBut *but);
  
--extern void ui_set_but_default(struct bContext *C, short all);
++extern void ui_set_but_default(struct bContext *C, uiBut *but, short all);
  
  extern void ui_set_but_soft_range(uiBut *but, double value);
  
@@@ -396,8 -396,8 +395,6 @@@ struct uiPopupBlockHandle 
        void (*popup_func)(struct bContext *C, void *arg, int event);
        void (*cancel_func)(void *arg);
        void *popup_arg;
--      
--      struct wmTimer *scrolltimer;
  
        /* for operator popups */
        struct wmOperatorType *optype;
@@@ -419,11 -419,11 +416,9 @@@ void ui_block_func_ICONTEXTROW(struct b
  struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
  void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
  
--uiBut *ui_popup_menu_memory(struct uiBlock *block, struct uiBut *but);
--
--float *ui_block_hsv_get(struct uiBlock *block);
--void ui_popup_block_scrolltest(struct uiBlock *block);
++uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but);
  
++float *ui_block_hsv_get(uiBlock *block);
  
  /* searchbox for string button */
  ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
@@@ -486,11 -486,11 +481,6 @@@ void ui_widget_color_init(struct ThemeU
  void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
  void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
  
--extern unsigned char checker_stipple_sml[];
--/* used for transp checkers */
--#define UI_TRANSP_DARK 100
--#define UI_TRANSP_LIGHT 160
--
  /* interface_style.c */
  void uiStyleInit(void);
  
@@@ -174,14 -174,14 +174,14 @@@ void ED_object_add_generic_props(wmOper
        PropertyRNA *prop;
        
        /* note: this property gets hidden for add-camera operator */
--      RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view");
++      RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view.");
  
        if(do_editmode) {
--              prop= RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode", "Enter editmode when adding this object");
++              prop= RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode", "Enter editmode when adding this object.");
                RNA_def_property_flag(prop, PROP_HIDDEN);
        }
        
--      RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location for the newly added object", -FLT_MAX, FLT_MAX);
++      RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location for the newly added object.", -FLT_MAX, FLT_MAX);
        RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -FLT_MAX, FLT_MAX);
        
        prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", "");
@@@ -637,7 -637,7 +637,7 @@@ static int object_armature_add_exec(bCo
        else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
        
        if(obedit==NULL) {
--              BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature");
++              BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature.");
                return OPERATOR_CANCELLED;
        }
        
@@@ -1382,7 -1382,7 +1382,7 @@@ static int convert_exec(bContext *C, wm
  void OBJECT_OT_convert(wmOperatorType *ot)
  {
        /* identifiers */
--      ot->name= "Convert to";
++      ot->name= "Convert";
        ot->description = "Convert selected objects to another type";
        ot->idname= "OBJECT_OT_convert";
        
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
  
        /* properties */
--      ot->prop= RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to");
--      RNA_def_boolean(ot->srna, "keep_original", 0, "Keep Original", "Keep original objects instead of replacing them");
++      ot->prop= RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to.");
++      RNA_def_boolean(ot->srna, "keep_original", 0, "Keep Original", "Keep original objects instead of replacing them.");
  }
  
  /**************************** Duplicate ************************/
@@@ -1716,7 -1716,7 +1716,7 @@@ void OBJECT_OT_duplicate(wmOperatorTyp
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* to give to transform */
--      RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
++      RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data.");
        prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
        RNA_def_property_flag(prop, PROP_HIDDEN);
  }
@@@ -1786,8 -1786,8 +1786,8 @@@ void OBJECT_OT_add_named(wmOperatorTyp
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
--      RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
--      RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add");
++      RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data.");
++      RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add.");
  }
  
  
@@@ -1812,11 -1812,11 +1812,11 @@@ static int join_exec(bContext *C, wmOpe
        Object *ob= CTX_data_active_object(C);
  
        if(scene->obedit) {
--              BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode");
++              BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode.");
                return OPERATOR_CANCELLED;
        }
        else if(object_data_is_libdata(ob)) {
--              BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
++              BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata.");
                return OPERATOR_CANCELLED;
        }
  
@@@ -1865,11 -1865,11 +1865,11 @@@ static int join_shapes_exec(bContext *C
        Object *ob= CTX_data_active_object(C);
        
        if(scene->obedit) {
--              BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode");
++              BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode.");
                return OPERATOR_CANCELLED;
        }
        else if(object_data_is_libdata(ob)) {
--              BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
++              BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata.");
                return OPERATOR_CANCELLED;
        }
        
@@@ -203,9 -203,9 +203,9 @@@ static int object_shape_key_mirror(bCon
                                                fp1= ((float *)kb->data) + i1*3;
                                                fp2= ((float *)kb->data) + i2*3;
  
--                                              copy_v3_v3(tvec,        fp1);
--                                              copy_v3_v3(fp1, fp2);
--                                              copy_v3_v3(fp2, tvec);
++                                              VECCOPY(tvec,   fp1);
++                                              VECCOPY(fp1,    fp2);
++                                              VECCOPY(fp2,    tvec);
  
                                                /* flip x axis */
                                                fp1[0] = -fp1[0];
  
                        mesh_octree_table(ob, NULL, NULL, 'e');
                }
--              else if (ob->type == OB_LATTICE) {
--                      Lattice *lt= ob->data;
--                      int i1, i2;
--                      float *fp1, *fp2;
--                      int u, v, w;
--                      /* half but found up odd value */
--                      const int pntsu_half = (((lt->pntsu / 2) + (lt->pntsu % 2))) ;
--
--                      /* currently editmode isnt supported by mesh so
--                       * ignore here for now too */
--
--                      /* if(lt->editlatt) lt= lt->editlatt->latt; */
--
--                      for(w=0; w<lt->pntsw; w++) {
--                              for(v=0; v<lt->pntsv; v++) {
--                                      for(u=0; u<pntsu_half; u++) {
--                                              int u_inv= (lt->pntsu - 1) - u;
--                                              float tvec[3];
--                                              if(u == u_inv) {
--                                                      i1= LT_INDEX(lt, u, v, w);
--                                                      fp1= ((float *)kb->data) + i1*3;
--                                                      fp1[0]= -fp1[0];
--                                              }
--                                              else {
--                                                      i1= LT_INDEX(lt, u, v, w);
--                                                      i2= LT_INDEX(lt, u_inv, v, w);
--
--                                                      fp1= ((float *)kb->data) + i1*3;
--                                                      fp2= ((float *)kb->data) + i2*3;
--
--                                                      copy_v3_v3(tvec, fp1);
--                                                      copy_v3_v3(fp1, fp2);
--                                                      copy_v3_v3(fp2, tvec);
--                                                      fp1[0]= -fp1[0];
--                                                      fp2[0]= -fp2[0];
--                                              }
--                                      }
--                              }
--                      }
--              }
++              /* todo, other types? */
  
                MEM_freeN(tag_elem);
        }
@@@ -77,7 -77,7 +77,6 @@@
  static void vgroup_remap_update_users(Object *ob, int *map);
  static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup);
  static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg);
--static void vgroup_delete_all(Object *ob);
  
  static Lattice *vgroup_edit_lattice(Object *ob)
  {
@@@ -139,30 -139,30 +138,22 @@@ void ED_vgroup_delete(Object *ob, bDefo
                vgroup_delete_object_mode(ob, dg);
  }
  
--int ED_vgroup_data_create(ID *id)
++void ED_vgroup_data_create(ID *id)
  {
        /* create deform verts */
  
        if(GS(id->name)==ID_ME) {
                Mesh *me= (Mesh *)id;
                me->dvert= CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
--              return TRUE;
        }
        else if(GS(id->name)==ID_LT) {
                Lattice *lt= (Lattice *)id;
                lt->dvert= MEM_callocN(sizeof(MDeformVert)*lt->pntsu*lt->pntsv*lt->pntsw, "lattice deformVert");
--              return TRUE;
--      }
--      else {
--              return FALSE;
        }
  }
  
  static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot)
  {
--      *dvert_tot = 0;
--      *dvert_arr = NULL;
--
        if(id) {
                switch(GS(id->name)) {
                        case ID_ME:
                                        int i;
  
                                        if (!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) {
++                                              *dvert_tot = 0;
++                                              *dvert_arr = NULL;
                                                return 0;
                                        }
  
  
                                        return 1;
                                }
--                              else {
++                              else
                                        return 0;
--                              }
                        }
                        case ID_LT:
                        {
                }
        }
  
++      *dvert_arr= NULL;
++      *dvert_tot= 0;
        return 0;
  }
  
@@@ -271,24 -271,24 +265,13 @@@ int ED_vgroup_copy_array(Object *ob, Ob
        int i;
        int totdef_from= BLI_countlist(&ob_from->defbase);
        int totdef= BLI_countlist(&ob->defbase);
--      short new_vgroup= FALSE;
  
        ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from);
        ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
  
--      if((dvert_array == NULL) && (dvert_array_from != NULL) && ED_vgroup_data_create(ob->data)) {
--              ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
--              new_vgroup= TRUE;
--      }
--
        if(ob==ob_from || dvert_tot==0 || (dvert_tot != dvert_tot_from) || dvert_array_from==NULL || dvert_array==NULL) {
                if (dvert_array) MEM_freeN(dvert_array);
                if (dvert_array_from) MEM_freeN(dvert_array_from);
--
--              if(new_vgroup == TRUE) {
--                      /* free the newly added vgroup since it wasn't compatible */
--                      vgroup_delete_all(ob);
--              }
                return 0;
        }
  
@@@ -1032,75 -1032,75 +1015,55 @@@ static void vgroup_clean_all(Object *ob
        if (dvert_array) MEM_freeN(dvert_array);
  }
  
--
--static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
--                            const char sel, const char sel_mirr,
--                            const int *flip_map,
--                            const short mirror_weights, const short flip_vgroups)
--{
--      BLI_assert(sel || sel_mirr);
--
--      if(sel_mirr && sel) {
--              /* swap */
--              if(mirror_weights)
--                      SWAP(MDeformVert, *dvert, *dvert_mirr);
--              if(flip_vgroups) {
--                      defvert_flip(dvert, flip_map);
--                      defvert_flip(dvert_mirr, flip_map);
--              }
--      }
--      else {
--              /* dvert should always be the target */
--              if(sel_mirr) {
--                      SWAP(MDeformVert *, dvert, dvert_mirr);
--              }
--
--              if(mirror_weights)
--                      defvert_copy(dvert, dvert_mirr);
--              if(flip_vgroups) {
--                      defvert_flip(dvert, flip_map);
--              }
--      }
--}
--
--void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_vgroups)
++void ED_vgroup_mirror(Object *ob, int mirror_weights, int flip_vgroups)
  {
--#define VGROUP_MIRR_OP dvert_mirror_op(dvert, dvert_mirr, sel, sel_mirr, flip_map, mirror_weights, flip_vgroups)
--
        EditVert *eve, *eve_mirr;
        MDeformVert *dvert, *dvert_mirr;
--      short sel, sel_mirr;
        int     *flip_map;
  
        if(mirror_weights==0 && flip_vgroups==0)
                return;
  
--      flip_map= defgroup_flip_map(ob, 0);
--
        /* only the active group */
        if(ob->type == OB_MESH) {
                Mesh *me= ob->data;
                EditMesh *em = BKE_mesh_get_editmesh(me);
  
++              EM_cache_x_mirror_vert(ob, em);
  
--              if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) {
--                      MEM_freeN(flip_map);
++              if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT))
                        return;
--              }
  
--              EM_cache_x_mirror_vert(ob, em);
++              flip_map= defgroup_flip_map(ob, 0);
  
                /* Go through the list of editverts and assign them */
                for(eve=em->verts.first; eve; eve=eve->next){
                        if((eve_mirr=eve->tmp.v)) {
--                              sel= eve->f & SELECT;
--                              sel_mirr= eve_mirr->f & SELECT;
--
--                              if((sel || sel_mirr) && (eve != eve_mirr)) {
++                              if((eve_mirr->f & SELECT || eve->f & SELECT) && (eve != eve_mirr)) {
                                        dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
                                        dvert_mirr= CustomData_em_get(&em->vdata, eve_mirr->data, CD_MDEFORMVERT);
                                        if(dvert && dvert_mirr) {
--                                              VGROUP_MIRR_OP;
++                                              if(eve_mirr->f & SELECT && eve->f & SELECT) {
++                                                      /* swap */
++                                                      if(mirror_weights)
++                                                              SWAP(MDeformVert, *dvert, *dvert_mirr);
++                                                      if(flip_vgroups) {
++                                                              defvert_flip(dvert, flip_map);
++                                                              defvert_flip(dvert_mirr, flip_map);
++                                                      }
++                                              }
++                                              else {
++                                                      /* dvert should always be the target */
++                                                      if(eve_mirr->f & SELECT) {
++                                                              SWAP(MDeformVert *, dvert, dvert_mirr);
++                                                      }
++
++                                                      if(mirror_weights)
++                                                              defvert_copy(dvert, dvert_mirr);
++                                                      if(flip_vgroups) {
++                                                              defvert_flip(dvert, flip_map);
++                                                      }
++                                              }
                                        }
                                }
  
                        }
                }
  
--              BKE_mesh_end_editmesh(me, em);
--      }
--      else if (ob->type == OB_LATTICE) {
--              Lattice *lt= ob->data;
--              int i1, i2;
--              int u, v, w;
--              int pntsu_half;
--              /* half but found up odd value */
--
--              if(lt->editlatt) lt= lt->editlatt->latt;
--
--              if(lt->pntsu == 1 || lt->dvert == NULL) {
--                      MEM_freeN(flip_map);
--                      return;
--              }
--
--              /* unlike editmesh we know that by only looping over the first hald of
--               * the 'u' indicies it will cover all points except the middle which is
--               * ok in this case */
--              pntsu_half= lt->pntsu / 2;
--
--              for(w=0; w<lt->pntsw; w++) {
--                      for(v=0; v<lt->pntsv; v++) {
--                              for(u=0; u<pntsu_half; u++) {
--                                      int u_inv= (lt->pntsu - 1) - u;
--                                      if(u != u_inv) {
--                                              BPoint *bp, *bp_mirr;
++              MEM_freeN(flip_map);
  
--                                              i1= LT_INDEX(lt, u, v, w);
--                                              i2= LT_INDEX(lt, u_inv, v, w);
--
--                                              bp= &lt->def[i1];
--                                              bp_mirr= &lt->def[i2];
--
--                                              sel= bp->f1 & SELECT;
--                                              sel_mirr= bp_mirr->f1 & SELECT;
--
--                                              if(sel || sel_mirr) {
--                                                      dvert= &lt->dvert[i1];
--                                                      dvert_mirr= &lt->dvert[i2];
--
--                                                      VGROUP_MIRR_OP;
--                                              }
--                                      }
--                              }
--                      }
--              }
++              BKE_mesh_end_editmesh(me, em);
        }
--
--      MEM_freeN(flip_map);
--
--#undef VGROUP_MIRR_OP
  }
  
  static void vgroup_remap_update_users(Object *ob, int *map)
@@@ -2005,25 -2005,25 +1920,17 @@@ void OBJECT_OT_vertex_group_copy_to_lin
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
  }
  
--static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
++static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *UNUSED(op))
  {
        Object *obact= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
--      int change= 0;
--      int fail= 0;
  
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
        {
--              if(obact != ob) {
--                      if(ED_vgroup_copy_array(ob, obact)) change++;
--                      else                                fail++;
--              }
++              if(obact != ob)
++                      ED_vgroup_copy_array(ob, obact);
        }
        CTX_DATA_END;
  
--      if((change == 0 && fail == 0) || fail) {
--              BKE_reportf(op->reports, RPT_ERROR, "Copy to VGroups to Selected warning done %d, failed %d, object data must have matching indicies", change, fail);
--      }
--
        return OPERATOR_FINISHED;
  }
  
@@@ -3970,6 -3970,6 +3970,18 @@@ int PE_undo_valid(Scene *scene
        return 0;
  }
  
++static void PTCacheUndo_number(Scene *scene, PTCacheEdit *edit, int nr)
++{
++      PTCacheUndo *undo;
++      int a=1;
++      
++      for(undo= edit->undo.first; undo; undo= undo->next, a++) {
++              if(a==nr) break;
++      }
++      edit->curundo= undo;
++      PE_undo_step(scene, 0);
++}
++
  static void PTCacheUndo_clear(PTCacheEdit *edit)
  {
        PTCacheUndo *undo;
@@@ -3995,38 -3995,38 +4007,32 @@@ void PE_redo(Scene *scene
        PE_undo_step(scene, -1);
  }
  
--void PE_undo_number(Scene *scene, int nr)
++void PE_undo_menu(Scene *scene, Object *ob)
  {
--      PTCacheEdit *edit= PE_get_current(scene, OBACT);
++      PTCacheEdit *edit= PE_get_current(scene, ob);
        PTCacheUndo *undo;
--      int a=0;
--      
--      for(undo= edit->undo.first; undo; undo= undo->next, a++) {
--              if(a==nr) break;
--      }
--      edit->curundo= undo;
--      PE_undo_step(scene, 0);
--}
++      DynStr *ds;
++      short event=0;
++      char *menu;
  
--
--/* get name of undo item, return null if no item with this index */
--/* if active pointer, set it to 1 if true */
--char *PE_undo_get_name(Scene *scene, int nr, int *active)
--{
--      PTCacheEdit *edit= PE_get_current(scene, OBACT);
--      PTCacheUndo *undo;
++      if(!edit) return;
        
--      if(active) *active= 0;
++      ds= BLI_dynstr_new();
++
++      BLI_dynstr_append(ds, "Particlemode Undo History %t");
        
--      if(edit) {
--              undo= BLI_findlink(&edit->undo, nr);
--              if(undo) {
--                      if(active && undo==edit->curundo)
--                              *active= 1;
--                      return undo->name;
--              }
++      for(undo= edit->undo.first; undo; undo= undo->next) {
++              BLI_dynstr_append(ds, "|");
++              BLI_dynstr_append(ds, undo->name);
        }
--      return NULL;
++      
++      menu= BLI_dynstr_get_cstring(ds);
++      BLI_dynstr_free(ds);
++      
++// XXX        event= pupmenu_col(menu, 20);
++      MEM_freeN(menu);
++      
++      if(event>0) PTCacheUndo_number(scene, edit, event);
  }
  
  /************************ utilities ******************************/
@@@ -184,7 -184,7 +184,8 @@@ void render_view_open(bContext *C, int 
                        area_was_image = 1;
  
                /* this function returns with changed context */
--              sa= ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
++              ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
++              sa= CTX_wm_area(C);
        }
  
        if(!sa) {
@@@ -3692,26 -3692,26 +3692,14 @@@ static void do_projectpaint_draw(ProjPa
        }
  }
  
--static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask, int use_color_correction) {
++static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask) {
        if (ps->is_texbrush) {
--              /* rgba already holds a texture result here from higher level function */
--              float rgba_br[3];
--              if(use_color_correction){
--                      srgb_to_linearrgb_v3_v3(rgba_br, ps->brush->rgb);
--                      mul_v3_v3(rgba, rgba_br);
--              }
--              else{
--                      mul_v3_v3(rgba, ps->brush->rgb);
--              }
++              rgba[0] *= ps->brush->rgb[0];
++              rgba[1] *= ps->brush->rgb[1];
++              rgba[2] *= ps->brush->rgb[2];
        }
        else {
--              if(use_color_correction){
--                      srgb_to_linearrgb_v3_v3(rgba, ps->brush->rgb);
--              }
--              else {
--                      VECCOPY(rgba, ps->brush->rgb);
--              }
--              rgba[3] = 1.0;
++              VECCOPY(rgba, ps->brush->rgb);
        }
        
        if (ps->is_airbrush==0 && mask < 1.0f) {
@@@ -3748,7 -3748,7 +3736,6 @@@ static void *do_projectpaint_thread(voi
        float falloff;
        int bucket_index;
        int is_floatbuf = 0;
--      int use_color_correction = 0;
        const short tool =  ps->tool;
        rctf bucket_bounds;
        
  
                                                                last_projIma->touch = 1;
                                                                is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
--                                                              use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
                                                        }
  
                                                        last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index;
                                                                else                            do_projectpaint_smear(ps, projPixel, alpha, mask, smearArena, &smearPixels, co);
                                                                break;
                                                        default:
--                                                              if (is_floatbuf)        do_projectpaint_draw_f(ps, projPixel, rgba, alpha, mask, use_color_correction);
++                                                              if (is_floatbuf)        do_projectpaint_draw_f(ps, projPixel, rgba, alpha, mask);
                                                                else                            do_projectpaint_draw(ps, projPixel, rgba, alpha, mask);
                                                                break;
                                                        }
@@@ -4001,7 -4001,7 +3987,7 @@@ static int project_paint_sub_stroke(Pro
        // we may want to use this later 
        // brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0);
        
--      if (brush_painter_paint(painter, project_paint_op, pos, time, pressure, ps, 0)) {
++      if (brush_painter_paint(painter, project_paint_op, pos, time, pressure, ps)) {
                return 1;
        }
        else return 0;
@@@ -4072,6 -4072,6 +4058,7 @@@ static void imapaint_dirty_region(Imag
  static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
  {
        if(ibuf->rect_float)
++              /* TODO - should just update a portion from imapaintpartial! */
                ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
        
        if(ibuf->mipmap[0])
@@@ -4268,8 -4268,8 +4255,8 @@@ static ImBuf *imapaint_lift_clone(ImBu
  
  static void imapaint_convert_brushco(ImBuf *ibufb, float *pos, int *ipos)
  {
--      ipos[0]= (int)floorf((pos[0] - ibufb->x/2) + 1.0f);
--      ipos[1]= (int)floorf((pos[1] - ibufb->y/2) + 1.0f);
++      ipos[0]= (int)(pos[0] - ibufb->x/2);
++      ipos[1]= (int)(pos[1] - ibufb->y/2);
  }
  
  /* dosnt run for projection painting
@@@ -4422,7 -4422,7 +4409,7 @@@ static int imapaint_paint_sub_stroke(Im
  
        brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0);
  
--      if (brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) {
++      if (brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s)) {
                if (update)
                        imapaint_image_update(s->sima, image, ibuf, texpaint);
                return 1;
@@@ -4876,7 -4876,7 +4863,12 @@@ static void paint_apply_event(bContext 
        PointerRNA itemptr;
        float pressure, mousef[2];
        double time;
--      int tablet;
++      int tablet, mouse[2];
++
++      // XXX +1 matches brush location better but
++      // still not exact, find out why and fix ..
++      mouse[0]= event->mval[0] + 1;
++      mouse[1]= event->mval[1] + 1;
  
        time= PIL_check_seconds_timer();
  
                pressure= pop->prev_pressure ? pop->prev_pressure : 1.0f;
  
        if(pop->first) {
--              pop->prevmouse[0]= event->mval[0];
--              pop->prevmouse[1]= event->mval[1];
++              pop->prevmouse[0]= mouse[0];
++              pop->prevmouse[1]= mouse[1];
                pop->starttime= time;
  
                /* special exception here for too high pressure values on first touch in
        /* fill in stroke */
        RNA_collection_add(op->ptr, "stroke", &itemptr);
  
--      mousef[0] = (float)(event->mval[0]);
--      mousef[1] = (float)(event->mval[1]);
++      mousef[0] = (float)(mouse[0]);
++      mousef[1] = (float)(mouse[1]);
        RNA_float_set_array(&itemptr, "mouse", mousef);
        RNA_float_set(&itemptr, "time", (float)(time - pop->starttime));
        RNA_float_set(&itemptr, "pressure", pressure);
@@@ -5020,45 -5020,45 +5012,31 @@@ static int get_imapaint_zoom(bContext *
  
  static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata))
  {
--#define PX_SIZE_FADE_MAX 12.0f
--#define PX_SIZE_FADE_MIN 4.0f
--
        Brush *brush= image_paint_brush(C);
        Paint *paint= paint_get_active(CTX_data_scene(C));
  
--      if(paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
++      if(paint && brush) {
                float zoomx, zoomy;
--              const float size= (float)brush_size(brush);
--              const short use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy);
--              const float pixel_size= MAX2(size * zoomx, size * zoomy);
--              float alpha= 0.5f;
  
--              /* fade out the brush (cheap trick to work around brush interfearing with sampling [#])*/
--              if(pixel_size < PX_SIZE_FADE_MIN) {
++              if(!(paint->flags & PAINT_SHOW_BRUSH))
                        return;
--              }
--              else if (pixel_size < PX_SIZE_FADE_MAX) {
--                      alpha *= (pixel_size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
--              }
  
                glPushMatrix();
  
                glTranslatef((float)x, (float)y, 0.0f);
  
--              if(use_zoom)
++              if(get_imapaint_zoom(C, &zoomx, &zoomy))
                        glScalef(zoomx, zoomy, 1.0f);
  
--              glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha);
++              glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], 0.5f);
                glEnable( GL_LINE_SMOOTH );
                glEnable(GL_BLEND);
--              glutil_draw_lined_arc(0, (float)(M_PI*2.0), size, 40);
++              glutil_draw_lined_arc(0, (float)(M_PI*2.0), (float)brush_size(brush), 40);
                glDisable(GL_BLEND);
                glDisable( GL_LINE_SMOOTH );
  
                glPopMatrix();
        }
--#undef PX_SIZE_FADE_MAX
--#undef PX_SIZE_FADE_MIN
  }
  
  static void toggle_paint_cursor(bContext *C, int enable)
@@@ -65,7 -65,7 +65,6 @@@ int paint_space_stroke_enabled(struct B
  
  int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
  int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
--int paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
  struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
  void *paint_stroke_mode_data(struct PaintStroke *stroke);
  void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
@@@ -916,19 -916,19 +916,6 @@@ int paint_stroke_exec(bContext *C, wmOp
        return OPERATOR_FINISHED;
  }
  
--int paint_stroke_cancel(bContext *C, wmOperator *op)
--{
--      PaintStroke *stroke = op->customdata;
--
--      if(stroke->done)
--              stroke->done(C, stroke);
--
--      MEM_freeN(stroke);
--      op->customdata = NULL;
--
--      return OPERATOR_CANCELLED;
--}
--
  ViewContext *paint_stroke_view_context(PaintStroke *stroke)
  {
        return &stroke->vc;
@@@ -301,7 -301,7 +301,7 @@@ static void wpaint_mirror_vgroup_ensure
                flip_side_name(name, defgroup->name, FALSE);
  
                if(strcmp(name, defgroup->name) != 0) {
--                      for (curdef= ob->defbase.first, mirrdef= 0; curdef; curdef=curdef->next, mirrdef++) {
++                      for (curdef= ob->defbase.first, mirrdef; curdef; curdef=curdef->next, mirrdef++) {
                                if (!strcmp(curdef->name, name)) {
                                        break;
                                }
@@@ -1600,13 -1600,13 +1600,6 @@@ static int wpaint_invoke(bContext *C, w
        return OPERATOR_RUNNING_MODAL;
  }
  
--static int wpaint_cancel(bContext *C, wmOperator *op)
--{
--      paint_stroke_cancel(C, op);
--
--      return OPERATOR_CANCELLED;
--}
--
  void PAINT_OT_weight_paint(wmOperatorType *ot)
  {
        
        ot->modal= paint_stroke_modal;
        /* ot->exec= vpaint_exec; <-- needs stroke property */
        ot->poll= weight_paint_poll;
--      ot->cancel= wpaint_cancel;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@@ -1900,13 -1900,13 +1892,6 @@@ static int vpaint_invoke(bContext *C, w
        return OPERATOR_RUNNING_MODAL;
  }
  
--static int vpaint_cancel(bContext *C, wmOperator *op)
--{
--      paint_stroke_cancel(C, op);
--
--      return OPERATOR_CANCELLED;
--}
--
  void PAINT_OT_vertex_paint(wmOperatorType *ot)
  {
        /* identifiers */
        ot->modal= paint_stroke_modal;
        /* ot->exec= vpaint_exec; <-- needs stroke property */
        ot->poll= vertex_paint_poll;
--      ot->cancel= vpaint_cancel;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@@ -3559,24 -3559,24 +3559,6 @@@ static int sculpt_brush_stroke_exec(bCo
        return OPERATOR_FINISHED;
  }
  
--static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
--{
--      Object *ob= CTX_data_active_object(C);
--      SculptSession *ss = ob->sculpt;
--      Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
--
--      paint_stroke_cancel(C, op);
--
--      if(ss->cache) {
--              sculpt_cache_free(ss->cache);
--              ss->cache = NULL;
--      }
--
--      sculpt_brush_exit_tex(sd);
--
--      return OPERATOR_CANCELLED;
--}
--
  static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
  {
        static EnumPropertyItem stroke_mode_items[] = {
        ot->modal= paint_stroke_modal;
        ot->exec= sculpt_brush_stroke_exec;
        ot->poll= sculpt_poll;
--      ot->cancel= sculpt_brush_stroke_cancel;
  
        /* flags (sculpt does own undo? (ton) */
        ot->flag= OPTYPE_BLOCKING;
@@@ -556,20 -556,20 +556,20 @@@ static void uiblock_layer_pass_buttons(
        /* menu buts */
        if(render_slot) {
                strp= slot_menu();
--              but= uiDefButS(block, MENU, 0, strp,                                    0, 0, wmenu1, UI_UNIT_Y, render_slot, 0,0,0,0, "Select Slot");
++              but= uiDefButS(block, MENU, 0, strp,                                    0, 0, wmenu1, 20, render_slot, 0,0,0,0, "Select Slot");
                uiButSetFunc(but, image_multi_cb, rr, iuser);
                MEM_freeN(strp);
        }
  
        if(rr) {
                strp= layer_menu(rr, &iuser->layer);
--              but= uiDefButS(block, MENU, 0, strp,                                    0, 0, wmenu2, UI_UNIT_Y, &iuser->layer, 0,0,0,0, "Select Layer");
++              but= uiDefButS(block, MENU, 0, strp,                                    0, 0, wmenu2, 20, &iuser->layer, 0,0,0,0, "Select Layer");
                uiButSetFunc(but, image_multi_cb, rr, iuser);
                MEM_freeN(strp);
                
                rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */
                strp= pass_menu(rl, &iuser->pass);
--              but= uiDefButS(block, MENU, 0, strp,                                    0, 0, wmenu3, UI_UNIT_Y, &iuser->pass, 0,0,0,0, "Select Pass");
++              but= uiDefButS(block, MENU, 0, strp,                                    0, 0, wmenu3, 20, &iuser->pass, 0,0,0,0, "Select Pass");
                uiButSetFunc(but, image_multi_cb, rr, iuser);
                MEM_freeN(strp);        
        }
@@@ -1086,13 -1086,13 +1086,6 @@@ static int snode_bg_viewmove_invoke(bCo
        return OPERATOR_RUNNING_MODAL;
  }
  
--static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
--{
--      MEM_freeN(op->customdata);
--      op->customdata= NULL;
--
--      return OPERATOR_CANCELLED;
--}
  
  void NODE_OT_backimage_move(wmOperatorType *ot)
  {
        ot->invoke= snode_bg_viewmove_invoke;
        ot->modal= snode_bg_viewmove_modal;
        ot->poll= composite_node_active;
--      ot->cancel= snode_bg_viewmove_cancel;
        
        /* flags */
        ot->flag= OPTYPE_BLOCKING;
@@@ -1392,14 -1392,14 +1384,6 @@@ static int node_resize_invoke(bContext 
        return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
  }
  
--static int node_resize_cancel(bContext *UNUSED(C), wmOperator *op)
--{
--      MEM_freeN(op->customdata);
--      op->customdata= NULL;
--
--      return OPERATOR_CANCELLED;
--}
--
  void NODE_OT_resize(wmOperatorType *ot)
  {
        /* identifiers */
        ot->invoke= node_resize_invoke;
        ot->modal= node_resize_modal;
        ot->poll= ED_operator_node_active;
--      ot->cancel= node_resize_cancel;
        
        /* flags */
        ot->flag= OPTYPE_BLOCKING;
@@@ -2296,18 -2296,18 +2279,6 @@@ static int node_link_invoke(bContext *C
        }
  }
  
--static int node_link_cancel(bContext *C, wmOperator *op)
--{
--      SpaceNode *snode= CTX_wm_space_node(C);
--      bNodeLinkDrag *nldrag= op->customdata;
--
--      nodeRemLink(snode->edittree, nldrag->link);
--      BLI_remlink(&snode->linkdrag, nldrag);
--      MEM_freeN(nldrag);
--
--      return OPERATOR_CANCELLED;
--}
--
  void NODE_OT_link(wmOperatorType *ot)
  {
        /* identifiers */
        ot->modal= node_link_modal;
  //    ot->exec= node_link_exec;
        ot->poll= ED_operator_node_active;
--      ot->cancel= node_link_cancel;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@@ -2432,7 -2432,7 +2402,6 @@@ void NODE_OT_links_cut(wmOperatorType *
        ot->invoke= WM_gesture_lines_invoke;
        ot->modal= WM_gesture_lines_modal;
        ot->exec= cut_links_exec;
--      ot->cancel= WM_gesture_lines_cancel;
        
        ot->poll= ED_operator_node_active;
        
@@@ -1557,7 -1560,7 +1557,7 @@@ static void restore_localviewdata(ScrAr
        }
  }
  
--static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa)
++static void endlocalview(Scene *scene, ScrArea *sa)
  {
        View3D *v3d= sa->spacedata.first;
        struct Base *base;
                                base->object->lay= base->lay;
                        }
                }
--              
--              DAG_on_visible_update(bmain, FALSE);
        } 
  }
  
@@@ -1593,7 -1596,7 +1591,7 @@@ static int localview_exec(bContext *C, 
        View3D *v3d= CTX_wm_view3d(C);
        
        if(v3d->localvd)
--              endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C));
++              endlocalview(CTX_data_scene(C), CTX_wm_area(C));
        else
                initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C));
        
@@@ -4140,7 -4140,7 +4140,7 @@@ void param_construct_end(ParamHandle *h
  
        param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
  
--      phandle->ncharts = p_connect_pairs(phandle, (PBool)impl);
++      phandle->ncharts = p_connect_pairs(phandle, impl);
        phandle->charts = p_split_charts(phandle, chart, phandle->ncharts);
  
        p_chart_delete(phandle->construction_chart);
@@@ -4189,7 -4189,7 +4189,7 @@@ void param_lscm_begin(ParamHandle *hand
        for (i = 0; i < phandle->ncharts; i++) {
                for (f=phandle->charts[i]->faces; f; f=f->nextlink)
                        p_face_backup_uvs(f);
--              p_chart_lscm_begin(phandle->charts[i], (PBool)live, (PBool)abf);
++              p_chart_lscm_begin(phandle->charts[i], live, abf);
        }
  }
  
@@@ -253,12 -253,12 +253,19 @@@ typedef struct RenderData 
         */
        short yparts;
          
--      short planes, imtype, subimtype, quality;
++      short winpos, planes, imtype, subimtype;
++      
++      /** Mode bits:                                                           */
++      /* 0: Enable backbuffering for images                                    */
++      short bufflag;
++       short quality;
        
        /**
         * Render to image editor, fullscreen or to new window.
         */
        short displaymode;
++      
++      short rpad1, rpad2;
  
        /**
         * Flags for render settings. Use bit-masking to access the settings.
        /**
         * Adjustment factors for the aspect ratio in the x direction, was a short in 2.45
         */
--      float xasp, yasp;
++      float xasp;
++      /**
++       * Adjustment factors for the aspect ratio in the x direction, was a short in 2.45
++       */
++      float yasp;
  
        float frs_sec_base;
        
        short bake_normal_space, bake_quad_split;
        float bake_maxdist, bake_biasdist, bake_pad;
  
--      /* path to render output */
--      char pic[240];
++      /* paths to backbufffer, output */
++      char backbuf[160], pic[160];
  
        /* stamps flags. */
        int stamp;
@@@ -305,7 -305,7 +305,7 @@@ typedef struct UserDef 
        int savetime;
        char tempdir[160];      // FILE_MAXDIR length
        char fontdir[160];
--      char renderdir[240]; // FILE_MAX length
++      char renderdir[160];
        char textudir[160];
        char plugtexdir[160];
        char plugseqdir[160];
@@@ -238,13 -245,13 +238,6 @@@ static void rna_UserDef_weight_color_up
  
  static void rna_UserDef_viewport_lights_update(Main *bmain, Scene *scene, PointerRNA *ptr)
  {
--      /* if all lights are off gpu_draw resets them all, [#27627]
--       * so disallow them all to be disabled */
--      if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) {
--              SolidLight *light= ptr->data;
--              light->flag |= 1;
--      }
--
        WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D|NS_VIEW3D_GPU, NULL);
        rna_userdef_update(bmain, scene, ptr);
  }
@@@ -214,7 -214,7 +214,7 @@@ struct Rende
        ListBase instancetable;
        int totinstance;
  
--      struct Image *bakebuf;
++      struct Image *backbuf, *bakebuf;
        
        struct GHash *orco_hash;
  
@@@ -4665,6 -4665,6 +4665,7 @@@ void RE_Database_Free(Render *re
        re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
        re->i.convertdone= 0;
  
++      re->backbuf= NULL;
        re->bakebuf= NULL;
  
        if(re->scene)
@@@ -149,6 -149,6 +149,7 @@@ static Render *envmap_render_copy(Rende
        envre->r.layers.first= envre->r.layers.last= NULL;
        envre->r.filtertype= 0;
        envre->r.xparts= envre->r.yparts= 2;
++      envre->r.bufflag= 0;
        envre->r.size= 100;
        envre->r.yasp= envre->r.xasp= 1;
        
@@@ -2065,6 -2065,6 +2065,36 @@@ static void do_render_fields_3d(Render 
        re->display_draw(re->ddh, re->result, NULL);
  }
  
++static void load_backbuffer(Render *re)
++{
++      if(re->r.alphamode == R_ADDSKY) {
++              ImBuf *ibuf;
++              char name[256];
++              
++              BLI_strncpy(name, re->r.backbuf, sizeof(name));
++              BLI_path_abs(name, re->main->name);
++              BLI_path_frame(name, re->r.cfra, 0);
++              
++              if(re->backbuf) {
++                      re->backbuf->id.us--;
++                      if(re->backbuf->id.us<1)
++                              BKE_image_signal(re->backbuf, NULL, IMA_SIGNAL_RELOAD);
++              }
++              
++              re->backbuf= BKE_add_image_file(name);
++              ibuf= BKE_image_get_ibuf(re->backbuf, NULL);
++              if(ibuf==NULL) {
++                      // error() doesnt work with render window open
++                      //error("No backbuf there!");
++                      printf("Error: No backbuf %s\n", name);
++              }
++              else {
++                      if (re->r.mode & R_FIELDS)
++                              image_de_interlace(re->backbuf, re->r.mode & R_ODDFIELD);
++              }
++      }
++}
++
  /* main render routine, no compositing */
  static void do_render_fields_blur_3d(Render *re)
  {
                G.afbreek= 1;
                return;
        }
++      
++      /* backbuffer initialize */
++      if(re->r.bufflag & 1)
++              load_backbuffer(re);
  
        /* now use renderdata and camera to set viewplane */
        RE_SetCamera(re, camera);
@@@ -502,6 -502,6 +502,21 @@@ int shadeHaloFloat(HaloRen *har,  floa
  
  /* ------------------------------------------------------------------------- */
  
++static void fillBackgroundImage(float *collector, float fx, float fy)
++{
++      collector[0] = 0.0; 
++      collector[1] = 0.0; 
++      collector[2] = 0.0; 
++      collector[3] = 0.0; 
++      
++      if(R.backbuf) {
++              float dx= 1.0f/(float)R.winx;
++              float dy= 1.0f/(float)R.winy;
++              
++              image_sample(R.backbuf, fx*dx, fy*dy, dx, dy, collector);
++      }
++}
++
  /* Only view vector is important here. Result goes to colf[3] */
  void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short thread)
  {
@@@ -611,14 -611,14 +626,18 @@@ void shadeSkyPixel(float *collector, fl
  
        float fac;
  
--      if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) {
--              /* 1. solid color */
++      /* 1. Do a backbuffer image: */ 
++      if(R.r.bufflag & 1) {
++              fillBackgroundImage(collector, fx, fy);
++      } 
++      else if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) {
++              /* 2. solid color */
                VECCOPY(collector, &R.wrld.horr);
  
                collector[3] = 0.0f;
        } 
        else {
--              /* 2. */
++              /* 3. */
  
                /* This one true because of the context of this routine  */
                if(R.wrld.skytype & WO_SKYPAPER) {
@@@ -183,12 -183,12 +183,6 @@@ endif(
                message(STATUS "Player Skipping: (${REM_MSG})")
        endif()
        target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS})
--
--      unset(SEARCHLIB)
--      unset(SORTLIB)
--      unset(REMLIB)
--      unset(REM_MSG)
--
  # else()
  #     target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS})
  # endif()
@@@ -876,12 -851,12 +876,6 @@@ endif(
                message(STATUS "Blender Skipping: (${REM_MSG})")
        endif()
        target_link_libraries(blender ${BLENDER_SORTED_LIBS})
--      
--      unset(SEARCHLIB)
--      unset(SORTLIB)
--      unset(REMLIB)
--      unset(REM_MSG)
--      
  #else()
  #     target_link_libraries(blender ${BLENDER_LINK_LIBS})
  #endif()
@@@ -538,7 -538,7 +538,7 @@@ static int set_output(int argc, const c
        if (argc >= 1){
                if (CTX_data_scene(C)) {
                        Scene *scene= CTX_data_scene(C);
--                      BLI_strncpy(scene->r.pic, argv[1], sizeof(scene->r.pic));
++                      BLI_strncpy(scene->r.pic, argv[1], FILE_MAXDIR);
                } else {
                        printf("\nError: no blend loaded. cannot use '-o / --render-output'.\n");
                }