Merged changes in the trunk up to revision 55357.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Mon, 18 Mar 2013 00:48:59 +0000 (00:48 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Mon, 18 Mar 2013 00:48:59 +0000 (00:48 +0000)
Resolved conflicts:
release/datafiles/startup.blend
source/blender/editors/space_nla/nla_buttons.c

Also updated source/blender/blenkernel/intern/linestyle.c as a follow-up of
recent changes for the use of bool.

69 files changed:
1  2 
CMakeLists.txt
SConstruct
build_files/scons/tools/Blender.py
release/datafiles/startup.blend
release/scripts/startup/bl_ui/__init__.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenfont/BLF_translation.h
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/idcode.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/linestyle.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/SConscript
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/CMakeLists.txt
source/blender/bmesh/SConscript
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/CMakeLists.txt
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/render/SConscript
source/blender/editors/render/render_shading.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_view3d/CMakeLists.txt
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/python/intern/bpy.c
source/blender/python/intern/bpy_app.c
source/blender/render/CMakeLists.txt
source/blender/render/SConscript
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/render_result.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_files.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt

diff --cc CMakeLists.txt
Simple merge
diff --cc SConstruct
Simple merge
Simple merge
index 0a7e066,e5d781e..40e1363
Binary files differ
@@@ -2544,11 -2541,7 +2553,11 @@@ class VIEW3D_PT_view3d_meshdisplay(Pane
          col.prop(mesh, "show_edge_seams", text="Seams")
          col.prop(mesh, "show_edge_sharp", text="Sharp")
          col.prop(mesh, "show_edge_bevel_weight", text="Weights")
-         
 +        if context.scene and bpy.app.build_options.freestyle:
 +            col.prop(mesh, "show_freestyle_edge_marks", text="Freestyle Edge Marks")
 +            col.prop(mesh, "show_freestyle_face_marks", text="Freestyle Face Marks")
 +        
          col = layout.column()
  
          col.separator()
Simple merge
@@@ -1174,8 -1167,8 +1172,8 @@@ const CustomDataMask CD_MASK_MESH 
      CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL |
      CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
      CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP |
-     CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
+     CD_MASK_MTEXPOLY | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
 -    CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN;
 +    CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
  const CustomDataMask CD_MASK_EDITMESH =
      CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV |
      CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_SHAPE_KEYINDEX |
@@@ -231,64 -231,64 +234,68 @@@ bool id_make_local(ID *id, bool test
                                BKE_lattice_make_local((Lattice *)id);
                                BKE_key_make_local(((Lattice *)id)->key);
                        }
-                       return 1;
+                       return true;
                case ID_LA:
                        if (!test) BKE_lamp_make_local((Lamp *)id);
-                       return 1;
+                       return true;
                case ID_CA:
                        if (!test) BKE_camera_make_local((Camera *)id);
-                       return 1;
+                       return true;
                case ID_SPK:
                        if (!test) BKE_speaker_make_local((Speaker *)id);
-                       return 1;
+                       return true;
                case ID_IP:
-                       return 0; /* deprecated */
+                       return false; /* deprecated */
                case ID_KE:
                        if (!test) BKE_key_make_local((Key *)id);
-                       return 1;
+                       return true;
                case ID_WO:
                        if (!test) BKE_world_make_local((World *)id);
-                       return 1;
+                       return true;
                case ID_SCR:
-                       return 0; /* can't be linked */
+                       return false; /* can't be linked */
                case ID_VF:
-                       return 0; /* not implemented */
+                       return false; /* not implemented */
                case ID_TXT:
-                       return 0; /* not implemented */
+                       return false; /* not implemented */
                case ID_SCRIPT:
-                       return 0; /* deprecated */
+                       return false; /* deprecated */
                case ID_SO:
-                       return 0; /* not implemented */
+                       return false; /* not implemented */
                case ID_GR:
-                       return 0; /* not implemented */
+                       return false; /* not implemented */
                case ID_AR:
                        if (!test) BKE_armature_make_local((bArmature *)id);
-                       return 1;
+                       return true;
                case ID_AC:
                        if (!test) BKE_action_make_local((bAction *)id);
-                       return 1;
+                       return true;
                case ID_NT:
-                       return 0; /* not implemented */
+                       return false; /* not implemented */
                case ID_BR:
                        if (!test) BKE_brush_make_local((Brush *)id);
-                       return 1;
+                       return true;
                case ID_PA:
                        if (!test) BKE_particlesettings_make_local((ParticleSettings *)id);
-                       return 1;
+                       return true;
                case ID_WM:
-                       return 0; /* can't be linked */
+                       return false; /* can't be linked */
                case ID_GD:
-                       return 0; /* not implemented */
+                       return false; /* not implemented */
 +#ifdef WITH_FREESTYLE
 +              case ID_LS:
 +                      return 0; /* not implemented */
 +#endif
        }
  
-       return 0;
+       return false;
  }
  
- int id_copy(ID *id, ID **newid, int test)
+ /**
+  * Invokes the appropriate copy method for the block and returns the result in
+  * newid, unless test. Returns true iff the block can be copied.
+  */
+ bool id_copy(ID *id, ID **newid, bool test)
  {
        if (!test) *newid = NULL;
  
         * - id.us of the new ID is set to 1 */
        switch (GS(id->name)) {
                case ID_SCE:
-                       return 0; /* can't be copied from here */
+                       return false;  /* can't be copied from here */
                case ID_LI:
-                       return 0; /* can't be copied from here */
+                       return false;  /* can't be copied from here */
                case ID_OB:
                        if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
-                       return 1;
+                       return true;
                case ID_ME:
                        if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
-                       return 1;
+                       return true;
                case ID_CU:
                        if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
-                       return 1;
+                       return true;
                case ID_MB:
                        if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id);
-                       return 1;
+                       return true;
                case ID_MA:
                        if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
-                       return 1;
+                       return true;
                case ID_TE:
                        if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
-                       return 1;
+                       return true;
                case ID_IM:
                        if (!test) *newid = (ID *)BKE_image_copy(G.main, (Image *)id);
-                       return 1;
+                       return true;
                case ID_LT:
                        if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
-                       return 1;
+                       return true;
                case ID_LA:
                        if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
-                       return 1;
+                       return true;
                case ID_SPK:
                        if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
-                       return 1;
+                       return true;
                case ID_CA:
                        if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
-                       return 1;
+                       return true;
                case ID_IP:
-                       return 0; /* deprecated */
+                       return false;  /* deprecated */
                case ID_KE:
                        if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
-                       return 1;
+                       return true;
                case ID_WO:
                        if (!test) *newid = (ID *)BKE_world_copy((World *)id);
-                       return 1;
+                       return true;
                case ID_SCR:
-                       return 0; /* can't be copied from here */
+                       return false;  /* can't be copied from here */
                case ID_VF:
-                       return 0; /* not implemented */
+                       return false;  /* not implemented */
                case ID_TXT:
                        if (!test) *newid = (ID *)BKE_text_copy((Text *)id);
-                       return 1;
+                       return true;
                case ID_SCRIPT:
-                       return 0; /* deprecated */
+                       return false;  /* deprecated */
                case ID_SO:
-                       return 0; /* not implemented */
+                       return false;  /* not implemented */
                case ID_GR:
                        if (!test) *newid = (ID *)BKE_group_copy((Group *)id);
-                       return 1;
+                       return true;
                case ID_AR:
                        if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id);
-                       return 1;
+                       return true;
                case ID_AC:
                        if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
-                       return 1;
+                       return true;
                case ID_NT:
                        if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
-                       return 1;
+                       return true;
                case ID_BR:
                        if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
-                       return 1;
+                       return true;
                case ID_PA:
                        if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id);
-                       return 1;
+                       return true;
                case ID_WM:
-                       return 0; /* can't be copied from here */
+                       return false;  /* can't be copied from here */
                case ID_GD:
-                       return 0; /* not implemented */
+                       return false;  /* not implemented */
                case ID_MSK:
                        if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id);
-                       return 1;
+                       return true;
 +#ifdef WITH_FREESTYLE
 +              case ID_LS:
 +                      if(!test) *newid= (ID*)FRS_copy_linestyle((FreestyleLineStyle*)id);
 +                      return 1;
 +#endif
        }
        
-       return 0;
+       return false;
  }
  
int id_unlink(ID *id, int test)
bool id_unlink(ID *id, int test)
  {
        Main *mainlib = G.main;
        ListBase *lb;
index aa9200a,0000000..ca3a910
mode 100644,000000..100644
--- /dev/null
@@@ -1,1022 -1,0 +1,1023 @@@
- #include "BLI_blenlib.h"
- #include "BLI_math.h"
 +/*
 + * ***** BEGIN GPL LICENSE BLOCK *****
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2010 Blender Foundation.
 + * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
 + * Contributor(s): none yet.
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file blender/blenkernel/intern/linestyle.c
 + *  \ingroup bke
 + */
 +
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <string.h>
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "DNA_object_types.h"
 +#include "DNA_material_types.h" /* for ramp blend */
 +#include "DNA_texture_types.h"
 +
++#include "BLI_blenlib.h"
++#include "BLI_math.h"
++#include "BLI_utildefines.h"
++
 +#include "BKE_global.h"
 +#include "BKE_library.h"
 +#include "BKE_linestyle.h"
 +#include "BKE_main.h"
 +#include "BKE_texture.h"
 +#include "BKE_colortools.h"
 +#include "BKE_animsys.h"
 +
 +static const char *modifier_name[LS_MODIFIER_NUM] = {
 +      NULL,
 +      "Along Stroke",
 +      "Distance from Camera",
 +      "Distance from Object",
 +      "Material",
 +      "Sampling",
 +      "Bezier Curve",
 +      "Sinus Displacement",
 +      "Spatial Noise",
 +      "Perlin Noise 1D",
 +      "Perlin Noise 2D",
 +      "Backbone Stretcher",
 +      "Tip Remover",
 +      "Calligraphy",
 +      "Polygonalization",
 +      "Guiding Lines",
 +      "Blueprint",
 +      "2D Offset",
 +      "2D Transform",
 +};
 +
 +static void default_linestyle_settings(FreestyleLineStyle *linestyle)
 +{
 +      linestyle->panel = LS_PANEL_STROKES;
 +      linestyle->r = linestyle->g = linestyle->b = 0.0f;
 +      linestyle->alpha = 1.0f;
 +      linestyle->thickness = 1.0f;
 +      linestyle->thickness_position = LS_THICKNESS_CENTER;
 +      linestyle->thickness_ratio = 0.5f;
 +      linestyle->chaining = LS_CHAINING_PLAIN;
 +      linestyle->rounds = 3;
 +      linestyle->min_angle = DEG2RADF(0.0f);
 +      linestyle->max_angle = DEG2RADF(0.0f);
 +      linestyle->min_length = 0.0f;
 +      linestyle->max_length = 10000.0f;
 +      linestyle->split_length = 100;
 +
 +      linestyle->color_modifiers.first = linestyle->color_modifiers.last = NULL;
 +      linestyle->alpha_modifiers.first = linestyle->alpha_modifiers.last = NULL;
 +      linestyle->thickness_modifiers.first = linestyle->thickness_modifiers.last = NULL;
 +      linestyle->geometry_modifiers.first = linestyle->geometry_modifiers.last = NULL;
 +
 +      FRS_add_linestyle_geometry_modifier(linestyle, LS_MODIFIER_SAMPLING);
 +
 +      linestyle->caps = LS_CAPS_BUTT;
 +}
 +
 +FreestyleLineStyle *FRS_new_linestyle(const char *name, struct Main *main)
 +{
 +      FreestyleLineStyle *linestyle;
 +
 +      if (!main)
 +              main = G.main;
 +
 +      linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(&main->linestyle, ID_LS, name);
 +
 +      default_linestyle_settings(linestyle);
 +
 +      return linestyle;
 +}
 +
 +void FRS_free_linestyle(FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *m;
 +
 +      BKE_free_animdata(&linestyle->id);
 +      while ((m = (LineStyleModifier *)linestyle->color_modifiers.first))
 +              FRS_remove_linestyle_color_modifier(linestyle, m);
 +      while ((m = (LineStyleModifier *)linestyle->alpha_modifiers.first))
 +              FRS_remove_linestyle_alpha_modifier(linestyle, m);
 +      while ((m = (LineStyleModifier *)linestyle->thickness_modifiers.first))
 +              FRS_remove_linestyle_thickness_modifier(linestyle, m);
 +      while ((m = (LineStyleModifier *)linestyle->geometry_modifiers.first))
 +              FRS_remove_linestyle_geometry_modifier(linestyle, m);
 +}
 +
 +FreestyleLineStyle *FRS_copy_linestyle(FreestyleLineStyle *linestyle)
 +{
 +      FreestyleLineStyle *new_linestyle;
 +      LineStyleModifier *m;
 +
 +      new_linestyle = FRS_new_linestyle(linestyle->id.name + 2, NULL);
 +      FRS_free_linestyle(new_linestyle);
 +
 +      new_linestyle->r = linestyle->r;
 +      new_linestyle->g = linestyle->g;
 +      new_linestyle->b = linestyle->b;
 +      new_linestyle->alpha = linestyle->alpha;
 +      new_linestyle->thickness = linestyle->thickness;
 +      new_linestyle->thickness_position = linestyle->thickness_position;
 +      new_linestyle->thickness_ratio = linestyle->thickness_ratio;
 +      new_linestyle->flag = linestyle->flag;
 +      new_linestyle->caps = linestyle->caps;
 +      new_linestyle->chaining = linestyle->chaining;
 +      new_linestyle->rounds = linestyle->rounds;
 +      new_linestyle->min_angle = linestyle->min_angle;
 +      new_linestyle->max_angle = linestyle->max_angle;
 +      new_linestyle->min_length = linestyle->min_length;
 +      new_linestyle->max_length = linestyle->max_length;
 +      new_linestyle->split_length = linestyle->split_length;
 +      new_linestyle->dash1 = linestyle->dash1;
 +      new_linestyle->gap1 = linestyle->gap1;
 +      new_linestyle->dash2 = linestyle->dash2;
 +      new_linestyle->gap2 = linestyle->gap2;
 +      new_linestyle->dash3 = linestyle->dash3;
 +      new_linestyle->gap3 = linestyle->gap3;
 +      new_linestyle->panel = linestyle->panel;
 +      for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next)
 +              FRS_copy_linestyle_color_modifier(new_linestyle, m);
 +      for (m = (LineStyleModifier *)linestyle->alpha_modifiers.first; m; m = m->next)
 +              FRS_copy_linestyle_alpha_modifier(new_linestyle, m);
 +      for (m = (LineStyleModifier *)linestyle->thickness_modifiers.first; m; m = m->next)
 +              FRS_copy_linestyle_thickness_modifier(new_linestyle, m);
 +      for (m = (LineStyleModifier *)linestyle->geometry_modifiers.first; m; m = m->next)
 +              FRS_copy_linestyle_geometry_modifier(new_linestyle, m);
 +
 +      return new_linestyle;
 +}
 +
 +static LineStyleModifier *new_modifier(int type, size_t size)
 +{
 +      LineStyleModifier *m;
 +
 +      m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
 +      if (m) {
 +              m->type = type;
 +              strcpy(m->name, modifier_name[type]);
 +              m->influence = 1.0f;
 +              m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;
 +      }
 +
 +      return m;
 +}
 +
 +static void add_to_modifier_list(ListBase *lb, LineStyleModifier *m)
 +{
 +      BLI_addtail(lb, (void *)m);
 +      BLI_uniquename(lb, m, modifier_name[m->type], '.', offsetof(LineStyleModifier, name), sizeof(m->name));
 +}
 +
 +static LineStyleModifier *alloc_color_modifier(int type)
 +{
 +      size_t size;
 +
 +      switch (type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              size = sizeof(LineStyleColorModifier_AlongStroke);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              size = sizeof(LineStyleColorModifier_DistanceFromCamera);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              size = sizeof(LineStyleColorModifier_DistanceFromObject);
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              size = sizeof(LineStyleColorModifier_Material);
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +
 +      return new_modifier(type, size);
 +}
 +
 +LineStyleModifier *FRS_add_linestyle_color_modifier(FreestyleLineStyle *linestyle, int type)
 +{
 +      LineStyleModifier *m;
 +
 +      m = alloc_color_modifier(type);
 +      if (!m)
 +              return NULL;
 +      m->blend = MA_RAMP_BLEND;
 +
 +      switch (type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = add_colorband(1);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp = add_colorband(1);
 +              ((LineStyleColorModifier_DistanceFromCamera *)m)->range_min = 0.0f;
 +              ((LineStyleColorModifier_DistanceFromCamera *)m)->range_max = 10000.0f;
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              ((LineStyleColorModifier_DistanceFromObject *)m)->target = NULL;
 +              ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp = add_colorband(1);
 +              ((LineStyleColorModifier_DistanceFromObject *)m)->range_min = 0.0f;
 +              ((LineStyleColorModifier_DistanceFromObject *)m)->range_max = 10000.0f;
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              ((LineStyleColorModifier_Material *)m)->color_ramp = add_colorband(1);
 +              ((LineStyleColorModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->color_modifiers, m);
 +
 +      return m;
 +}
 +
 +LineStyleModifier *FRS_copy_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      LineStyleModifier *new_m;
 +
 +      new_m = alloc_color_modifier(m->type);
 +      if (!new_m)
 +              return NULL;
 +      new_m->influence = m->influence;
 +      new_m->flags = m->flags;
 +      new_m->blend = m->blend;
 +
 +      switch (m->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleColorModifier_AlongStroke *p = (LineStyleColorModifier_AlongStroke *)m;
 +                      ((LineStyleColorModifier_AlongStroke *)new_m)->color_ramp = MEM_dupallocN(p->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleColorModifier_DistanceFromCamera *p = (LineStyleColorModifier_DistanceFromCamera *)m;
 +                      ((LineStyleColorModifier_DistanceFromCamera *)new_m)->color_ramp = MEM_dupallocN(p->color_ramp);
 +                      ((LineStyleColorModifier_DistanceFromCamera *)new_m)->range_min = p->range_min;
 +                      ((LineStyleColorModifier_DistanceFromCamera *)new_m)->range_max = p->range_max;
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleColorModifier_DistanceFromObject *p = (LineStyleColorModifier_DistanceFromObject *)m;
 +                      if (p->target)
 +                              p->target->id.us++;
 +                      ((LineStyleColorModifier_DistanceFromObject *)new_m)->target = p->target;
 +                      ((LineStyleColorModifier_DistanceFromObject *)new_m)->color_ramp = MEM_dupallocN(p->color_ramp);
 +                      ((LineStyleColorModifier_DistanceFromObject *)new_m)->range_min = p->range_min;
 +                      ((LineStyleColorModifier_DistanceFromObject *)new_m)->range_max = p->range_max;
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleColorModifier_Material *p = (LineStyleColorModifier_Material *)m;
 +                      ((LineStyleColorModifier_Material *)new_m)->color_ramp = MEM_dupallocN(p->color_ramp);
 +                      ((LineStyleColorModifier_Material *)new_m)->mat_attr = p->mat_attr;
 +              }
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->color_modifiers, new_m);
 +
 +      return new_m;
 +}
 +
 +void FRS_remove_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      switch (m->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              MEM_freeN(((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              MEM_freeN(((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              MEM_freeN(((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              MEM_freeN(((LineStyleColorModifier_Material *)m)->color_ramp);
 +              break;
 +      }
 +      BLI_freelinkN(&linestyle->color_modifiers, m);
 +}
 +
 +static LineStyleModifier *alloc_alpha_modifier(int type)
 +{
 +      size_t size;
 +
 +      switch (type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              size = sizeof(LineStyleAlphaModifier_AlongStroke);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              size = sizeof(LineStyleAlphaModifier_DistanceFromCamera);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              size = sizeof(LineStyleAlphaModifier_DistanceFromObject);
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              size = sizeof(LineStyleAlphaModifier_Material);
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      return new_modifier(type, size);
 +}
 +
 +LineStyleModifier *FRS_add_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, int type)
 +{
 +      LineStyleModifier *m;
 +
 +      m = alloc_alpha_modifier(type);
 +      if (!m)
 +              return NULL;
 +      m->blend = LS_VALUE_BLEND;
 +
 +      switch (type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              ((LineStyleAlphaModifier_AlongStroke *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleAlphaModifier_DistanceFromCamera *)m)->range_min = 0.0f;
 +              ((LineStyleAlphaModifier_DistanceFromCamera *)m)->range_max = 10000.0f;
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              ((LineStyleAlphaModifier_DistanceFromObject *)m)->target = NULL;
 +              ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleAlphaModifier_DistanceFromObject *)m)->range_min = 0.0f;
 +              ((LineStyleAlphaModifier_DistanceFromObject *)m)->range_max = 10000.0f;
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              ((LineStyleAlphaModifier_Material *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleAlphaModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->alpha_modifiers, m);
 +
 +      return m;
 +}
 +
 +LineStyleModifier *FRS_copy_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      LineStyleModifier *new_m;
 +
 +      new_m = alloc_alpha_modifier(m->type);
 +      if (!new_m)
 +              return NULL;
 +      new_m->influence = m->influence;
 +      new_m->flags = m->flags;
 +      new_m->blend = m->blend;
 +
 +      switch (m->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m;
 +                      ((LineStyleAlphaModifier_AlongStroke *)new_m)->curve = curvemapping_copy(p->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromCamera *p = (LineStyleAlphaModifier_DistanceFromCamera *)m;
 +                      ((LineStyleAlphaModifier_DistanceFromCamera *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleAlphaModifier_DistanceFromCamera *)new_m)->range_min = p->range_min;
 +                      ((LineStyleAlphaModifier_DistanceFromCamera *)new_m)->range_max = p->range_max;
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromObject *p = (LineStyleAlphaModifier_DistanceFromObject *)m;
 +                      if (p->target)
 +                              p->target->id.us++;
 +                      ((LineStyleAlphaModifier_DistanceFromObject *)new_m)->target = p->target;
 +                      ((LineStyleAlphaModifier_DistanceFromObject *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleAlphaModifier_DistanceFromObject *)new_m)->range_min = p->range_min;
 +                      ((LineStyleAlphaModifier_DistanceFromObject *)new_m)->range_max = p->range_max;
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m;
 +                      ((LineStyleAlphaModifier_Material *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleAlphaModifier_Material *)new_m)->mat_attr = p->mat_attr;
 +              }
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->alpha_modifiers, new_m);
 +
 +      return new_m;
 +}
 +
 +void FRS_remove_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      switch (m->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve);
 +              break;
 +      }
 +      BLI_freelinkN(&linestyle->alpha_modifiers, m);
 +}
 +
 +static LineStyleModifier *alloc_thickness_modifier(int type)
 +{
 +      size_t size;
 +
 +      switch (type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              size = sizeof(LineStyleThicknessModifier_AlongStroke);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              size = sizeof(LineStyleThicknessModifier_DistanceFromCamera);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              size = sizeof(LineStyleThicknessModifier_DistanceFromObject);
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              size = sizeof(LineStyleThicknessModifier_Material);
 +              break;
 +      case LS_MODIFIER_CALLIGRAPHY:
 +              size = sizeof(LineStyleThicknessModifier_Calligraphy);
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +
 +      return new_modifier(type, size);
 +}
 +
 +LineStyleModifier *FRS_add_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, int type)
 +{
 +      LineStyleModifier *m;
 +
 +      m = alloc_thickness_modifier(type);
 +      if (!m)
 +              return NULL;
 +      m->blend = LS_VALUE_BLEND;
 +
 +      switch (type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              ((LineStyleThicknessModifier_AlongStroke *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleThicknessModifier_AlongStroke *)m)->value_min = 0.0f;
 +              ((LineStyleThicknessModifier_AlongStroke *)m)->value_max = 1.0f;
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleThicknessModifier_DistanceFromCamera *)m)->range_min = 0.0f;
 +              ((LineStyleThicknessModifier_DistanceFromCamera *)m)->range_max = 1000.0f;
 +              ((LineStyleThicknessModifier_DistanceFromCamera *)m)->value_min = 0.0f;
 +              ((LineStyleThicknessModifier_DistanceFromCamera *)m)->value_max = 1.0f;
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              ((LineStyleThicknessModifier_DistanceFromObject *)m)->target = NULL;
 +              ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleThicknessModifier_DistanceFromObject *)m)->range_min = 0.0f;
 +              ((LineStyleThicknessModifier_DistanceFromObject *)m)->range_max = 1000.0f;
 +              ((LineStyleThicknessModifier_DistanceFromObject *)m)->value_min = 0.0f;
 +              ((LineStyleThicknessModifier_DistanceFromObject *)m)->value_max = 1.0f;
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              ((LineStyleThicknessModifier_Material *)m)->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 +              ((LineStyleThicknessModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
 +              ((LineStyleThicknessModifier_Material *)m)->value_min = 0.0f;
 +              ((LineStyleThicknessModifier_Material *)m)->value_max = 1.0f;
 +              break;
 +      case LS_MODIFIER_CALLIGRAPHY:
 +              ((LineStyleThicknessModifier_Calligraphy *)m)->min_thickness = 1.0f;
 +              ((LineStyleThicknessModifier_Calligraphy *)m)->max_thickness = 10.0f;
 +              ((LineStyleThicknessModifier_Calligraphy *)m)->orientation = DEG2RADF(60.0f);
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->thickness_modifiers, m);
 +
 +      return m;
 +}
 +
 +LineStyleModifier *FRS_copy_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      LineStyleModifier *new_m;
 +
 +      new_m = alloc_thickness_modifier(m->type);
 +      if (!new_m)
 +              return NULL;
 +      new_m->influence = m->influence;
 +      new_m->flags = m->flags;
 +      new_m->blend = m->blend;
 +
 +      switch (m->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m;
 +                      ((LineStyleThicknessModifier_AlongStroke *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleThicknessModifier_AlongStroke *)new_m)->value_min = p->value_min;
 +                      ((LineStyleThicknessModifier_AlongStroke *)new_m)->value_max = p->value_max;
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromCamera *p = (LineStyleThicknessModifier_DistanceFromCamera *)m;
 +                      ((LineStyleThicknessModifier_DistanceFromCamera *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleThicknessModifier_DistanceFromCamera *)new_m)->range_min = p->range_min;
 +                      ((LineStyleThicknessModifier_DistanceFromCamera *)new_m)->range_max = p->range_max;
 +                      ((LineStyleThicknessModifier_DistanceFromCamera *)new_m)->value_min = p->value_min;
 +                      ((LineStyleThicknessModifier_DistanceFromCamera *)new_m)->value_max = p->value_max;
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)m;
 +                      if (p->target)
 +                              p->target->id.us++;
 +                      ((LineStyleThicknessModifier_DistanceFromObject *)new_m)->target = p->target;
 +                      ((LineStyleThicknessModifier_DistanceFromObject *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleThicknessModifier_DistanceFromObject *)new_m)->range_min = p->range_min;
 +                      ((LineStyleThicknessModifier_DistanceFromObject *)new_m)->range_max = p->range_max;
 +                      ((LineStyleThicknessModifier_DistanceFromObject *)new_m)->value_min = p->value_min;
 +                      ((LineStyleThicknessModifier_DistanceFromObject *)new_m)->value_max = p->value_max;
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m;
 +                      ((LineStyleThicknessModifier_Material *)new_m)->curve = curvemapping_copy(p->curve);
 +                      ((LineStyleThicknessModifier_Material *)new_m)->mat_attr = p->mat_attr;
 +                      ((LineStyleThicknessModifier_Material *)new_m)->value_min = p->value_min;
 +                      ((LineStyleThicknessModifier_Material *)new_m)->value_max = p->value_max;
 +              }
 +              break;
 +      case LS_MODIFIER_CALLIGRAPHY:
 +              {
 +                      LineStyleThicknessModifier_Calligraphy *p = (LineStyleThicknessModifier_Calligraphy *)m;
 +                      ((LineStyleThicknessModifier_Calligraphy *)new_m)->min_thickness = p->min_thickness;
 +                      ((LineStyleThicknessModifier_Calligraphy *)new_m)->max_thickness = p->max_thickness;
 +                      ((LineStyleThicknessModifier_Calligraphy *)new_m)->orientation = p->orientation;
 +              }
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->thickness_modifiers, new_m);
 +
 +      return new_m;
 +}
 +
 +void FRS_remove_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      switch (m->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve);
 +              break;
 +      case LS_MODIFIER_CALLIGRAPHY:
 +              break;
 +      }
 +      BLI_freelinkN(&linestyle->thickness_modifiers, m);
 +}
 +
 +static LineStyleModifier *alloc_geometry_modifier(int type)
 +{
 +      size_t size;
 +
 +      switch (type) {
 +      case LS_MODIFIER_SAMPLING:
 +              size = sizeof(LineStyleGeometryModifier_Sampling);
 +              break;
 +      case LS_MODIFIER_BEZIER_CURVE:
 +              size = sizeof(LineStyleGeometryModifier_BezierCurve);
 +              break;
 +      case LS_MODIFIER_SINUS_DISPLACEMENT:
 +              size = sizeof(LineStyleGeometryModifier_SinusDisplacement);
 +              break;
 +      case LS_MODIFIER_SPATIAL_NOISE:
 +              size = sizeof(LineStyleGeometryModifier_SpatialNoise);
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_1D:
 +              size = sizeof(LineStyleGeometryModifier_PerlinNoise1D);
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_2D:
 +              size = sizeof(LineStyleGeometryModifier_PerlinNoise2D);
 +              break;
 +      case LS_MODIFIER_BACKBONE_STRETCHER:
 +              size = sizeof(LineStyleGeometryModifier_BackboneStretcher);
 +              break;
 +      case LS_MODIFIER_TIP_REMOVER:
 +              size = sizeof(LineStyleGeometryModifier_TipRemover);
 +              break;
 +      case LS_MODIFIER_POLYGONIZATION:
 +              size = sizeof(LineStyleGeometryModifier_Polygonalization);
 +              break;
 +      case LS_MODIFIER_GUIDING_LINES:
 +              size = sizeof(LineStyleGeometryModifier_GuidingLines);
 +              break;
 +      case LS_MODIFIER_BLUEPRINT:
 +              size = sizeof(LineStyleGeometryModifier_Blueprint);
 +              break;
 +      case LS_MODIFIER_2D_OFFSET:
 +              size = sizeof(LineStyleGeometryModifier_2DOffset);
 +              break;
 +      case LS_MODIFIER_2D_TRANSFORM:
 +              size = sizeof(LineStyleGeometryModifier_2DTransform);
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +
 +      return new_modifier(type, size);
 +}
 +
 +LineStyleModifier *FRS_add_linestyle_geometry_modifier(FreestyleLineStyle *linestyle, int type)
 +{
 +      LineStyleModifier *m;
 +
 +      m = alloc_geometry_modifier(type);
 +      if (!m)
 +              return NULL;
 +
 +      switch (type) {
 +      case LS_MODIFIER_SAMPLING:
 +              ((LineStyleGeometryModifier_Sampling *)m)->sampling = 10.0f;
 +              break;
 +      case LS_MODIFIER_BEZIER_CURVE:
 +              ((LineStyleGeometryModifier_BezierCurve *)m)->error = 10.0f;
 +              break;
 +      case LS_MODIFIER_SINUS_DISPLACEMENT:
 +              ((LineStyleGeometryModifier_SinusDisplacement *)m)->wavelength = 20.0f;
 +              ((LineStyleGeometryModifier_SinusDisplacement *)m)->amplitude = 5.0f;
 +              ((LineStyleGeometryModifier_SinusDisplacement *)m)->phase = 0.0f;
 +              break;
 +      case LS_MODIFIER_SPATIAL_NOISE:
 +              ((LineStyleGeometryModifier_SpatialNoise *)m)->amplitude = 5.0f;
 +              ((LineStyleGeometryModifier_SpatialNoise *)m)->scale = 20.0f;
 +              ((LineStyleGeometryModifier_SpatialNoise *)m)->octaves = 4;
 +              ((LineStyleGeometryModifier_SpatialNoise *)m)->flags = LS_MODIFIER_SPATIAL_NOISE_SMOOTH | LS_MODIFIER_SPATIAL_NOISE_PURERANDOM;
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_1D:
 +              ((LineStyleGeometryModifier_PerlinNoise1D *)m)->frequency = 10.0f;
 +              ((LineStyleGeometryModifier_PerlinNoise1D *)m)->amplitude = 10.0f;
 +              ((LineStyleGeometryModifier_PerlinNoise1D *)m)->octaves = 4;
 +              ((LineStyleGeometryModifier_PerlinNoise1D *)m)->angle = DEG2RADF(45.0f);
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_2D:
 +              ((LineStyleGeometryModifier_PerlinNoise2D *)m)->frequency = 10.0f;
 +              ((LineStyleGeometryModifier_PerlinNoise2D *)m)->amplitude = 10.0f;
 +              ((LineStyleGeometryModifier_PerlinNoise2D *)m)->octaves = 4;
 +              ((LineStyleGeometryModifier_PerlinNoise2D *)m)->angle = DEG2RADF(45.0f);
 +              break;
 +      case LS_MODIFIER_BACKBONE_STRETCHER:
 +              ((LineStyleGeometryModifier_BackboneStretcher *)m)->backbone_length = 10.0f;
 +              break;
 +      case LS_MODIFIER_TIP_REMOVER:
 +              ((LineStyleGeometryModifier_TipRemover *)m)->tip_length = 10.0f;
 +              break;
 +      case LS_MODIFIER_POLYGONIZATION:
 +              ((LineStyleGeometryModifier_Polygonalization *)m)->error = 10.0f;
 +              break;
 +      case LS_MODIFIER_GUIDING_LINES:
 +              ((LineStyleGeometryModifier_GuidingLines *)m)->offset = 0.0f;
 +              break;
 +      case LS_MODIFIER_BLUEPRINT:
 +              ((LineStyleGeometryModifier_Blueprint *)m)->flags = LS_MODIFIER_BLUEPRINT_CIRCLES;
 +              ((LineStyleGeometryModifier_Blueprint *)m)->rounds = 1;
 +              ((LineStyleGeometryModifier_Blueprint *)m)->backbone_length = 10.0f;
 +              ((LineStyleGeometryModifier_Blueprint *)m)->random_radius = 3;
 +              ((LineStyleGeometryModifier_Blueprint *)m)->random_center = 5;
 +              ((LineStyleGeometryModifier_Blueprint *)m)->random_backbone = 5;
 +              break;
 +      case LS_MODIFIER_2D_OFFSET:
 +              ((LineStyleGeometryModifier_2DOffset *)m)->start = 0.0f;
 +              ((LineStyleGeometryModifier_2DOffset *)m)->end = 0.0f;
 +              ((LineStyleGeometryModifier_2DOffset *)m)->x = 0.0f;
 +              ((LineStyleGeometryModifier_2DOffset *)m)->y = 0.0f;
 +              break;
 +      case LS_MODIFIER_2D_TRANSFORM:
 +              ((LineStyleGeometryModifier_2DTransform *)m)->pivot = LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER;
 +              ((LineStyleGeometryModifier_2DTransform *)m)->scale_x = 1.0f;
 +              ((LineStyleGeometryModifier_2DTransform *)m)->scale_y = 1.0f;
 +              ((LineStyleGeometryModifier_2DTransform *)m)->angle = DEG2RADF(0.0f);
 +              ((LineStyleGeometryModifier_2DTransform *)m)->pivot_u = 0.5f;
 +              ((LineStyleGeometryModifier_2DTransform *)m)->pivot_x = 0.0f;
 +              ((LineStyleGeometryModifier_2DTransform *)m)->pivot_y = 0.0f;
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->geometry_modifiers, m);
 +
 +      return m;
 +}
 +
 +LineStyleModifier *FRS_copy_linestyle_geometry_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      LineStyleModifier *new_m;
 +
 +      new_m = alloc_geometry_modifier(m->type);
 +      if (!new_m)
 +              return NULL;
 +      new_m->flags = m->flags;
 +
 +      switch (m->type) {
 +      case LS_MODIFIER_SAMPLING:
 +              {
 +                      LineStyleGeometryModifier_Sampling *p = (LineStyleGeometryModifier_Sampling *)m;
 +                      ((LineStyleGeometryModifier_Sampling *)new_m)->sampling = p->sampling;
 +              }
 +              break;
 +      case LS_MODIFIER_BEZIER_CURVE:
 +              {
 +                      LineStyleGeometryModifier_BezierCurve *p = (LineStyleGeometryModifier_BezierCurve *)m;
 +                      ((LineStyleGeometryModifier_BezierCurve *)new_m)->error = p->error;
 +              }
 +              break;
 +      case LS_MODIFIER_SINUS_DISPLACEMENT:
 +              {
 +                      LineStyleGeometryModifier_SinusDisplacement *p = (LineStyleGeometryModifier_SinusDisplacement *)m;
 +                      ((LineStyleGeometryModifier_SinusDisplacement *)new_m)->wavelength = p->wavelength;
 +                      ((LineStyleGeometryModifier_SinusDisplacement *)new_m)->amplitude = p->amplitude;
 +                      ((LineStyleGeometryModifier_SinusDisplacement *)new_m)->phase = p->phase;
 +              }
 +              break;
 +      case LS_MODIFIER_SPATIAL_NOISE:
 +              {
 +                      LineStyleGeometryModifier_SpatialNoise *p = (LineStyleGeometryModifier_SpatialNoise *)m;
 +                      ((LineStyleGeometryModifier_SpatialNoise *)new_m)->amplitude = p->amplitude;
 +                      ((LineStyleGeometryModifier_SpatialNoise *)new_m)->scale = p->scale;
 +                      ((LineStyleGeometryModifier_SpatialNoise *)new_m)->octaves = p->octaves;
 +                      ((LineStyleGeometryModifier_SpatialNoise *)new_m)->flags = p->flags;
 +              }
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_1D:
 +              {
 +                      LineStyleGeometryModifier_PerlinNoise1D *p = (LineStyleGeometryModifier_PerlinNoise1D *)m;
 +                      ((LineStyleGeometryModifier_PerlinNoise1D *)new_m)->frequency = p->frequency;
 +                      ((LineStyleGeometryModifier_PerlinNoise1D *)new_m)->amplitude = p->amplitude;
 +                      ((LineStyleGeometryModifier_PerlinNoise1D *)new_m)->octaves = p->octaves;
 +                      ((LineStyleGeometryModifier_PerlinNoise1D *)new_m)->angle = p->angle;
 +              }
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_2D:
 +              {
 +                      LineStyleGeometryModifier_PerlinNoise2D *p = (LineStyleGeometryModifier_PerlinNoise2D *)m;
 +                      ((LineStyleGeometryModifier_PerlinNoise2D *)new_m)->frequency = p->frequency;
 +                      ((LineStyleGeometryModifier_PerlinNoise2D *)new_m)->amplitude = p->amplitude;
 +                      ((LineStyleGeometryModifier_PerlinNoise2D *)new_m)->octaves = p->octaves;
 +                      ((LineStyleGeometryModifier_PerlinNoise2D *)new_m)->angle = p->angle;
 +              }
 +              break;
 +      case LS_MODIFIER_BACKBONE_STRETCHER:
 +              {
 +                      LineStyleGeometryModifier_BackboneStretcher *p = (LineStyleGeometryModifier_BackboneStretcher *)m;
 +                      ((LineStyleGeometryModifier_BackboneStretcher *)new_m)->backbone_length = p->backbone_length;
 +              }
 +              break;
 +      case LS_MODIFIER_TIP_REMOVER:
 +              {
 +                      LineStyleGeometryModifier_TipRemover *p = (LineStyleGeometryModifier_TipRemover *)m;
 +                      ((LineStyleGeometryModifier_TipRemover *)new_m)->tip_length = p->tip_length;
 +              }
 +              break;
 +      case LS_MODIFIER_POLYGONIZATION:
 +              {
 +                      LineStyleGeometryModifier_Polygonalization *p = (LineStyleGeometryModifier_Polygonalization *)m;
 +                      ((LineStyleGeometryModifier_Polygonalization *)new_m)->error = p->error;
 +              }
 +              break;
 +      case LS_MODIFIER_GUIDING_LINES:
 +              {
 +                      LineStyleGeometryModifier_GuidingLines *p = (LineStyleGeometryModifier_GuidingLines *)m;
 +                      ((LineStyleGeometryModifier_GuidingLines *)new_m)->offset = p->offset;
 +              }
 +              break;
 +      case LS_MODIFIER_BLUEPRINT:
 +              {
 +                      LineStyleGeometryModifier_Blueprint *p = (LineStyleGeometryModifier_Blueprint *)m;
 +                      ((LineStyleGeometryModifier_Blueprint *)new_m)->flags = p->flags;
 +                      ((LineStyleGeometryModifier_Blueprint *)new_m)->rounds = p->rounds;
 +                      ((LineStyleGeometryModifier_Blueprint *)new_m)->backbone_length = p->backbone_length;
 +                      ((LineStyleGeometryModifier_Blueprint *)new_m)->random_radius = p->random_radius;
 +                      ((LineStyleGeometryModifier_Blueprint *)new_m)->random_center = p->random_center;
 +                      ((LineStyleGeometryModifier_Blueprint *)new_m)->random_backbone = p->random_backbone;
 +              }
 +              break;
 +      case LS_MODIFIER_2D_OFFSET:
 +              {
 +                      LineStyleGeometryModifier_2DOffset *p = (LineStyleGeometryModifier_2DOffset *)m;
 +                      ((LineStyleGeometryModifier_2DOffset *)new_m)->start = p->start;
 +                      ((LineStyleGeometryModifier_2DOffset *)new_m)->end = p->end;
 +                      ((LineStyleGeometryModifier_2DOffset *)new_m)->x = p->x;
 +                      ((LineStyleGeometryModifier_2DOffset *)new_m)->y = p->y;
 +              }
 +              break;
 +      case LS_MODIFIER_2D_TRANSFORM:
 +              {
 +                      LineStyleGeometryModifier_2DTransform *p = (LineStyleGeometryModifier_2DTransform *)m;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->pivot = p->pivot;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->scale_x = p->scale_x;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->scale_y = p->scale_y;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->angle = p->angle;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->pivot_u = p->pivot_u;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->pivot_x = p->pivot_x;
 +                      ((LineStyleGeometryModifier_2DTransform *)new_m)->pivot_y = p->pivot_y;
 +              }
 +              break;
 +      default:
 +              return NULL; /* unknown modifier type */
 +      }
 +      add_to_modifier_list(&linestyle->geometry_modifiers, new_m);
 +
 +      return new_m;
 +}
 +
 +void FRS_remove_linestyle_geometry_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
 +{
 +      switch (m->type) {
 +      case LS_MODIFIER_SAMPLING:
 +              break;
 +      case LS_MODIFIER_BEZIER_CURVE:
 +              break;
 +      case LS_MODIFIER_SINUS_DISPLACEMENT:
 +              break;
 +      case LS_MODIFIER_SPATIAL_NOISE:
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_1D:
 +              break;
 +      case LS_MODIFIER_PERLIN_NOISE_2D:
 +              break;
 +      case LS_MODIFIER_BACKBONE_STRETCHER:
 +              break;
 +      case LS_MODIFIER_TIP_REMOVER:
 +              break;
 +      case LS_MODIFIER_POLYGONIZATION:
 +              break;
 +      case LS_MODIFIER_GUIDING_LINES:
 +              break;
 +      case LS_MODIFIER_BLUEPRINT:
 +              break;
 +      case LS_MODIFIER_2D_OFFSET:
 +              break;
 +      case LS_MODIFIER_2D_TRANSFORM:
 +              break;
 +      }
 +      BLI_freelinkN(&linestyle->geometry_modifiers, m);
 +}
 +
 +static void move_modifier(ListBase *lb, LineStyleModifier *modifier, int direction)
 +{
 +      BLI_remlink(lb, modifier);
 +      if (direction > 0)
 +              BLI_insertlinkbefore(lb, modifier->prev, modifier);
 +      else
 +              BLI_insertlinkafter(lb, modifier->next, modifier);
 +}
 +
 +void FRS_move_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
 +{
 +      move_modifier(&linestyle->color_modifiers, modifier, direction);
 +}
 +
 +void FRS_move_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
 +{
 +      move_modifier(&linestyle->alpha_modifiers, modifier, direction);
 +}
 +
 +void FRS_move_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
 +{
 +      move_modifier(&linestyle->thickness_modifiers, modifier, direction);
 +}
 +
 +void FRS_move_linestyle_geometry_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
 +{
 +      move_modifier(&linestyle->geometry_modifiers, modifier, direction);
 +}
 +
 +void FRS_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase)
 +{
 +      LineStyleModifier *m;
 +      ColorBand *color_ramp;
 +      LinkData *link;
 +
 +      listbase->first = listbase->last = NULL;
 +      for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      color_ramp = ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp;
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      color_ramp = ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp;
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      color_ramp = ((LineStyleColorModifier_Material *)m)->color_ramp;
 +                      break;
 +              default:
 +                      continue;
 +              }
 +              link = (LinkData *) MEM_callocN( sizeof(LinkData), "link to color ramp");
 +              link->data = color_ramp;
 +              BLI_addtail(listbase, link);
 +      }
 +}
 +
 +/* XXX Do we want to keep that goto? Or use a boolean var? */
 +char *FRS_path_from_ID_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand *color_ramp)
 +{
 +      LineStyleModifier *m;
 +
 +      for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp)
 +                              goto found;
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp)
 +                              goto found;
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp)
 +                              goto found;
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp)
 +                              goto found;
 +                      break;
 +              }
 +      }
 +      printf("FRS_path_from_ID_to_color_ramp: No color ramps correspond to the given pointer.\n");
 +      return NULL;
 +
 +found:
 +      return BLI_sprintfN("color_modifiers[\"%s\"].color_ramp", m->name);
 +}
 +
 +void FRS_unlink_linestyle_target_object(FreestyleLineStyle *linestyle, struct Object *ob)
 +{
 +      LineStyleModifier *m;
 +
 +      for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
 +                      if (((LineStyleColorModifier_DistanceFromObject *)m)->target == ob) {
 +                              ((LineStyleColorModifier_DistanceFromObject *)m)->target = NULL;
 +                      }
 +              }
 +      }
 +      for (m = (LineStyleModifier *)linestyle->alpha_modifiers.first; m; m = m->next) {
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
 +                      if (((LineStyleAlphaModifier_DistanceFromObject *)m)->target == ob) {
 +                              ((LineStyleAlphaModifier_DistanceFromObject *)m)->target = NULL;
 +                      }
 +              }
 +      }
 +      for (m = (LineStyleModifier *)linestyle->thickness_modifiers.first; m; m = m->next) {
 +              if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
 +                      if (((LineStyleThicknessModifier_DistanceFromObject *)m)->target == ob) {
 +                              ((LineStyleThicknessModifier_DistanceFromObject *)m)->target = NULL;
 +                      }
 +              }
 +      }
 +}
Simple merge
Simple merge
@@@ -9053,109 -8816,19 +9025,118 @@@ static void do_versions(FileData *fd, L
                        do_version_node_fix_translate_wrapping(NULL, NULL, ntree);
        }
  
-       // if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) {
+       if (main->versionfile < 267) {
+               
+               /* TIP: to initialize new variables added, use the new function
+                  DNA_struct_elem_find(fd->filesdna, "structname", "typename", "varname")
+                  example: 
+                               if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "image_gpubuffer_limit"))
+                                       user->image_gpubuffer_limit = 10;
+                */
+               
+       }
+       
 +#ifdef WITH_FREESTYLE
 +      /* default values in Freestyle settings */
 +      {
 +              Scene *sce;
 +              SceneRenderLayer *srl;
 +              FreestyleLineStyle *linestyle;
 +
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      if (sce->r.line_thickness_mode == 0) {
 +                              sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
 +                              sce->r.unit_line_thickness = 1.0f;
 +                      }
 +                      for(srl = sce->r.layers.first; srl; srl = srl->next) {
 +                              if (srl->freestyleConfig.mode == 0)
 +                                      srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
 +                              if (srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
 +                                  srl->freestyleConfig.raycasting_algorithm == FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL) {
 +                                      srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */
 +                                      srl->freestyleConfig.flags |= FREESTYLE_CULLING;
 +                              }
 +                      }
 +              }
 +              for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
 +#if 1
 +                      /* disable the Misc panel for now */
 +                      if (linestyle->panel == LS_PANEL_MISC) {
 +                              linestyle->panel = LS_PANEL_STROKES;
 +                      }
 +#endif
 +                      if (linestyle->thickness_position == 0) {
 +                              linestyle->thickness_position = LS_THICKNESS_CENTER;
 +                              linestyle->thickness_ratio = 0.5f;
 +                      }
 +                      if (linestyle->chaining == 0)
 +                              linestyle->chaining = LS_CHAINING_PLAIN;
 +                      if (linestyle->rounds == 0)
 +                              linestyle->rounds = 3;
 +              }
 +      }
 +      /* The code segment below will be removed when the trunk merger is done.
 +         For now it is kept for backward compatibility, giving branch users time
 +         to migrate to the new CustomData-based edge/face marks. */
 +      {
 +              Mesh *me;
 +              MEdge *medge;
 +              MPoly *mpoly;
 +              int i, found;
 +
 +              for (me = main->mesh.first; me; me = me->id.next) {
 +                      /* Freestyle edge marks */
 +                      found = 0;
 +                      medge = me->medge;
 +                      for (i = 0; i < me->totedge; i++) {
 +                              if (medge->flag & ME_FREESTYLE_EDGE) {
 +                                      found = 1;
 +                                      break;
 +                              }
 +                              medge++;
 +                      }
 +                      if (found) {
 +                              FreestyleEdge *fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_CALLOC, NULL, me->totedge);
 +                              medge = me->medge;
 +                              for (i = 0; i < me->totedge; i++) {
 +                                      if (medge->flag & ME_FREESTYLE_EDGE) {
 +                                              medge->flag &= ~ME_FREESTYLE_EDGE;
 +                                              fed->flag |= FREESTYLE_EDGE_MARK;
 +                                      }
 +                                      medge++;
 +                                      fed++;
 +                              }
 +                              printf("Migrated to CustomData-based Freestyle edge marks\n");
 +                      }
 +                      /* Freestyle face marks */
 +                      found = 0;
 +                      mpoly = me->mpoly;
 +                      for (i = 0; i < me->totpoly; i++) {
 +                              if (mpoly->flag & ME_FREESTYLE_FACE) {
 +                                      found = 1;
 +                                      break;
 +                              }
 +                              mpoly++;
 +                      }
 +                      if (found) {
 +                              FreestyleFace *ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_CALLOC, NULL, me->totpoly);
 +                              mpoly = me->mpoly;
 +                              for (i = 0; i < me->totpoly; i++) {
 +                                      if (mpoly->flag & ME_FREESTYLE_FACE) {
 +                                              mpoly->flag &= ~ME_FREESTYLE_FACE;
 +                                              ffa->flag |= FREESTYLE_FACE_MARK;
 +                                      }
 +                                      mpoly++;
 +                                      ffa++;
 +                              }
 +                              printf("Migrated to CustomData-based Freestyle face marks\n");
 +                      }
 +              }
 +      }
 +#endif
 +
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
-       /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
+       /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
  
        /* don't forget to set version number in blender.c! */
  }
Simple merge
Simple merge
@@@ -142,9 -141,9 +141,12 @@@ static int nla_panel_context(const bCon
                        case ANIMTYPE_DSPART:
                        case ANIMTYPE_DSMBALL:
                        case ANIMTYPE_DSARM:
+                       case ANIMTYPE_DSMESH:
+                       case ANIMTYPE_DSTEX:
+                       case ANIMTYPE_DSLAT:
 +#ifdef WITH_FREESTYLE
 +                      case ANIMTYPE_DSLINESTYLE:
 +#endif
                        case ANIMTYPE_DSSPK:
                        {
                                /* for these channels, we only do AnimData */
Simple merge
Simple merge
Simple merge
Simple merge
  #include "BLI_memarena.h"
  #include "BLI_ghash.h"
  #include "BLI_linklist.h"
 +#ifdef WITH_FREESTYLE
 +#  include "BLI_edgehash.h"
 +#endif
  
+ #include "BLF_translation.h"
  #include "DNA_armature_types.h"
  #include "DNA_camera_types.h"
  #include "DNA_material_types.h"
Simple merge