synched with trunk at revision 36569
authorNick Samarin <nicks1987@bigmir.net>
Mon, 16 May 2011 20:30:59 +0000 (20:30 +0000)
committerNick Samarin <nicks1987@bigmir.net>
Mon, 16 May 2011 20:30:59 +0000 (20:30 +0000)
59 files changed:
1  2 
build_files/cmake/cmake_consistency_check.py
build_files/cmake/cmake_qtcreator_project.py
build_files/package_spec/build_debian.sh
extern/CMakeLists.txt
extern/SConscript
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_game.py
release/scripts/startup/bl_ui/properties_scene.py
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/sca.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/object/CMakeLists.txt
source/blender/editors/object/SConscript
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/util/CMakeLists.txt
source/blender/editors/util/SConscript
source/blender/gpu/intern/gpu_shader_material.glsl
source/blender/gpu/intern/gpu_shader_vertex.glsl
source/blender/makesdna/DNA_actuator_types.h
source/blender/makesdna/DNA_customdata_types.h
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_actuator.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/CMakeLists.txt
source/blender/modifiers/MOD_modifiertypes.h
source/blender/modifiers/SConscript
source/blender/modifiers/intern/MOD_util.c
source/creator/CMakeLists.txt
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/CMakeLists.txt
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Converter/SConscript
source/gameengine/GameLogic/SCA_IActuator.h
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_NavMeshObject.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_PythonInit.h
source/gameengine/Ketsji/KX_PythonInitTypes.cpp
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h
source/gameengine/Ketsji/KX_SteeringActuator.cpp
source/gameengine/Ketsji/KX_SteeringActuator.h
source/gameengine/Ketsji/SConscript
source/gameengine/Rasterizer/RAS_IRasterizer.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h

index a34f21d9e8aea7d6feb622535d98314eba0e38d0,f55b2e95d5e36c02e9fd96b44f2bba337d543a3c..f55b2e95d5e36c02e9fd96b44f2bba337d543a3c
mode 100644,100644..100755
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env python
  
- # $Id: cmake_consistency_check.py 34636 2011-02-04 09:27:25Z campbellbarton $
+ # $Id$
  # ***** BEGIN GPL LICENSE BLOCK *****
  #
  # This program is free software; you can redistribute it and/or
@@@ -34,7 -34,7 +34,7 @@@ IGNORE = 
      "/ik_glut_test/"
  
  import os
- from os.path import join, dirname, normpath, abspath
+ from os.path import join, dirname, normpath, abspath, splitext
  
  base = join(os.path.dirname(__file__), "..", "..")
  base = normpath(base)
@@@ -45,9 -45,6 +45,6 @@@ print("Scanning:", base
  global_h = set()
  global_c = set()
  
- import os
- from os.path import  splitext
  
  def source_list(path, filename_check=None):
      for dirpath, dirnames, filenames in os.walk(path):
  
  
  # extension checking
- def is_c_header(filename):
-     ext = splitext(filename)[1]
-     return (ext in (".h", ".hpp", ".hxx"))
  def is_cmake(filename):
      ext = splitext(filename)[1]
      return (ext == ".cmake") or (filename == "CMakeLists.txt")
index 3adce66fadefa3672c761093e7c70ffd85a82d00,59b8b2a3b02669140e2231f3fea028f27364a6f4..59b8b2a3b02669140e2231f3fea028f27364a6f4
mode 100644,100644..100755
  # along with this program; if not, write to the Free Software Foundation,
  # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  #
- # Contributor(s): Campbell Barton
+ # Contributor(s): Campbell Barton, M.G. Kishalmi
  #
  # ***** END GPL LICENSE BLOCK *****
  
  # <pep8 compliant>
  
+ """
+ Example Win32 usage:
+  c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build
+ example linux usage
+  python .~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake
+ """
+ import sys
  import os
  from os.path import join, dirname, normpath, abspath, splitext, relpath, exists
  
@@@ -30,6 -39,22 +39,22 @@@ base = join(os.path.dirname(__file__), 
  base = normpath(base)
  base = abspath(base)
  
+ SIMPLE_PROJECTFILE = False
+ # get cmake path
+ CMAKE_DIR = sys.argv[-1]
+ if not os.path.exists(os.path.join(CMAKE_DIR, "CMakeCache.txt")):
+     CMAKE_DIR = os.getcwd()
+ if not os.path.exists(os.path.join(CMAKE_DIR, "CMakeCache.txt")):
+     print("CMakeCache.txt not found in %r or %r\n    Pass CMake build dir as an argument, or run from that dir, aborting" % (CMAKE_DIR, os.getcwd()))
+     sys.exit(1)
+ # could be either.
+ # PROJECT_DIR = base
+ PROJECT_DIR = CMAKE_DIR
  
  def source_list(path, filename_check=None):
      for dirpath, dirnames, filenames in os.walk(path):
  
  
  # extension checking
+ def is_cmake(filename):
+     ext = splitext(filename)[1]
+     return (ext == ".cmake") or (filename.endswith("CMakeLists.txt"))
  def is_c_header(filename):
      ext = splitext(filename)[1]
      return (ext in (".h", ".hpp", ".hxx"))
  
  
- def is_cmake(filename):
+ def is_py(filename):
      ext = splitext(filename)[1]
-     return (ext == ".cmake") or (filename == "CMakeLists.txt")
+     return (ext == ".py")
  
  
- def is_c_header(filename):
+ def is_glsl(filename):
      ext = splitext(filename)[1]
-     return (ext in (".h", ".hpp", ".hxx"))
+     return (ext == ".glsl")
  
  
  def is_c(filename):
@@@ -76,29 -106,186 +106,186 @@@ def is_svn_file(filename)
  
  
  def is_project_file(filename):
-     return (is_c_any(filename) or is_cmake(filename)) and is_svn_file(filename)
+     return (is_c_any(filename) or is_cmake(filename) or is_glsl(filename))  # and is_svn_file(filename)
+ def cmake_advanced_info():
+     """ Extracr includes and defines from cmake.
+     """
+     def create_eclipse_project(CMAKE_DIR):
+         print("CMAKE_DIR %r" % CMAKE_DIR)
+         if sys.platform == "win32":
+             cmd = 'cmake "%s" -G"Eclipse CDT4 - MinGW Makefiles"' % CMAKE_DIR
+         else:
+             cmd = 'cmake "%s" -G"Eclipse CDT4 - Unix Makefiles"' % CMAKE_DIR
+         os.system(cmd)
+     includes = []
+     defines = []
+     create_eclipse_project(CMAKE_DIR)
+     from xml.dom.minidom import parse
+     tree = parse(os.path.join(CMAKE_DIR, ".cproject"))
+     '''
+     f = open(".cproject_pretty", 'w')
+     f.write(tree.toprettyxml(indent="    ", newl=""))
+     '''
+     ELEMENT_NODE = tree.ELEMENT_NODE
+     cproject, = tree.getElementsByTagName("cproject")
+     for storage in cproject.childNodes:
+         if storage.nodeType != ELEMENT_NODE:
+             continue
+         if storage.attributes["moduleId"].value == "org.eclipse.cdt.core.settings":
+             cconfig = storage.getElementsByTagName("cconfiguration")[0]
+             for substorage in cconfig.childNodes:
+                 if substorage.nodeType != ELEMENT_NODE:
+                     continue
+                 moduleId = substorage.attributes["moduleId"].value
+                 # org.eclipse.cdt.core.settings
+                 # org.eclipse.cdt.core.language.mapping
+                 # org.eclipse.cdt.core.externalSettings
+                 # org.eclipse.cdt.core.pathentry
+                 # org.eclipse.cdt.make.core.buildtargets
+                 if moduleId == "org.eclipse.cdt.core.pathentry":
+                     for path in substorage.childNodes:
+                         if path.nodeType != ELEMENT_NODE:
+                             continue
+                         kind = path.attributes["kind"].value
+                         if kind == "mac":
+                             # <pathentry kind="mac" name="PREFIX" path="" value="&quot;/opt/blender25&quot;"/>
+                             defines.append((path.attributes["name"].value, path.attributes["value"].value))
+                         elif kind == "inc":
+                             # <pathentry include="/data/src/blender/blender/source/blender/editors/include" kind="inc" path="" system="true"/>
+                             includes.append(path.attributes["include"].value)
+                         else:
+                             pass
+     return includes, defines
+ def cmake_cache_var(var):
+     cache_file = open(os.path.join(CMAKE_DIR, "CMakeCache.txt"))
+     lines = [l_strip for l in cache_file for l_strip in (l.strip(),) if l_strip if not l_strip.startswith("//") if not l_strip.startswith("#")]
+     cache_file.close()
+     for l in lines:
+         if l.split(":")[0] == var:
+             return l.split("=", 1)[-1]
+     return None
+ def cmake_compiler_defines():
+     compiler = cmake_cache_var("CMAKE_C_COMPILER")  # could do CXX too
+     if compiler is None:
+         print("Couldn't find the compiler, os defines will be omitted...")
+         return
+     import tempfile
+     temp_c = tempfile.mkstemp(suffix=".c")[1]
+     temp_def = tempfile.mkstemp(suffix=".def")[1]
+     os.system("%s -dM -E %s > %s" % (compiler, temp_c, temp_def))
+     temp_def_file = open(temp_def)
+     lines = [l.strip() for l in temp_def_file if l.strip()]
+     temp_def_file.close()
+     os.remove(temp_c)
+     os.remove(temp_def)
+     return lines
+ def create_qtc_project_main():
+     files = list(source_list(base, filename_check=is_project_file))
+     files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
+     files_rel.sort()
+     # --- qtcreator specific, simple format
+     if SIMPLE_PROJECTFILE:
+         # --- qtcreator specific, simple format
+         PROJECT_NAME = "Blender"
+         f = open(join(PROJECT_DIR, "%s.files" % PROJECT_NAME), 'w')
+         f.write("\n".join(files_rel))
+         f = open(join(PROJECT_DIR, "%s.includes" % PROJECT_NAME), 'w')
+         f.write("\n".join(sorted(list(set(dirname(f) for f in files_rel if is_c_header(f))))))
+         qtc_prj = join(PROJECT_DIR, "%s.creator" % PROJECT_NAME)
+         f = open(qtc_prj, 'w')
+         f.write("[General]\n")
+         qtc_cfg = join(PROJECT_DIR, "%s.config" % PROJECT_NAME)
+         if not exists(qtc_cfg):
+             f = open(qtc_cfg, 'w')
+             f.write("// ADD PREDEFINED MACROS HERE!\n")
+     else:
+         includes, defines = cmake_advanced_info()
+         # for some reason it doesnt give all internal includes
+         includes = list(set(includes) | set(dirname(f) for f in files_rel if is_c_header(f)))
+         includes.sort()
+         PROJECT_NAME = "Blender"
+         FILE_NAME = PROJECT_NAME.lower()
+         f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
+         f.write("\n".join(files_rel))
+         f = open(join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w')
+         f.write("\n".join(sorted(includes)))
+         qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME)
+         f = open(qtc_prj, 'w')
+         f.write("[General]\n")
+         qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME)
+         f = open(qtc_cfg, 'w')
+         f.write("// ADD PREDEFINED MACROS HERE!\n")
+         defines_final = [("#define %s %s" % item) for item in defines]
+         if sys.platform != "win32":
+             defines_final += cmake_compiler_defines()  # defines from the compiler
+         f.write("\n".join(defines_final))
+     print("Blender project file written to: %s" % qtc_prj)
+     # --- end
+ def create_qtc_project_python():
+     files = list(source_list(base, filename_check=is_py))
+     files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
+     files_rel.sort()
+     # --- qtcreator specific, simple format
+     PROJECT_NAME = "Blender_Python"
+     FILE_NAME = PROJECT_NAME.lower()
+     f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
+     f.write("\n".join(files_rel))
  
files = list(source_list(base, filename_check=is_project_file))
- files_rel = [relpath(f, start=base) for f in files]
files_rel.sort()
    qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME)
+     f = open(qtc_prj, 'w')
    f.write("[General]\n")
  
+     qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME)
+     if not exists(qtc_cfg):
+         f = open(qtc_cfg, 'w')
+         f.write("// ADD PREDEFINED MACROS HERE!\n")
  
- # --- qtcreator spesific, simple format
- PROJECT_NAME = "Blender"
- f = open(join(base, "%s.files" % PROJECT_NAME), 'w')
- f.write("\n".join(files_rel))
+     print("Python project file written to:  %s" % qtc_prj)
  
- f = open(join(base, "%s.includes" % PROJECT_NAME), 'w')
- f.write("\n".join(sorted(list(set(dirname(f) for f in files_rel if is_c_header(f))))))
  
- qtc_prj = join(base, "%s.creator" % PROJECT_NAME)
f = open(qtc_prj, 'w')
f.write("[General]\n")
+ def main():
    create_qtc_project_main()
    create_qtc_project_python()
  
- qtc_cfg = join(base, "%s.config" % PROJECT_NAME)
- if not exists(qtc_cfg):
-     f = open(qtc_cfg, 'w')
-     f.write("// ADD PREDEFINED MACROS HERE!\n")
  
- print("Project file written to: %s" % qtc_prj)
- # --- end
+ if __name__ == "__main__":
+     main()
index 17c0abb888b6b6915c0e82d6fb62132eefcde5ef,4594095451f07fff4ea7f79011f34a39cab1425a..4594095451f07fff4ea7f79011f34a39cab1425a
mode 100644,100755..100644
@@@ -11,11 -11,19 +11,19 @@@ cp -a build_files/package_spec/debian 
  
  
  # Get values from blender to use in debian/changelog.
- BLENDER_REVISION=$(svnversion)
+ # value may be formatted: 35042:35051M
+ BLENDER_REVISION=$(svnversion | cut -d: -f2 | tr -dc 0-9)
  
- blender_srcdir=$PWD
- blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
+ blender_version=$(grep BLENDER_VERSION source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
+ blender_version_char=$(sed -ne 's/.*BLENDER_VERSION_CHAR.*\([a-z]\)$/\1/p' source/blender/blenkernel/BKE_blender.h)
  BLENDER_VERSION=$(expr $blender_version / 100).$(expr $blender_version % 100)
+ # map the version a -> 1, to conform to debian naming convention
+ # not to be confused with blender's internal subversions
+ if [ "$blender_version_char" ]; then
+     BLENDER_VERSION=${BLENDER_VERSION}.$(expr index abcdefghijklmnopqrstuvwxyz $blender_version_char)
+ fi
  DEB_VERSION=${BLENDER_VERSION}+svn${BLENDER_REVISION}-bf
  
  # update debian/changelog
@@@ -23,6 -31,7 +31,7 @@@ dch -b -v $DEB_VERSION "New upstream SV
  
  
  # run the rules makefile
+ rm -rf get-orig-source
  debian/rules get-orig-source SVN_URL=.
  mv *.gz ../
  
diff --combined extern/CMakeLists.txt
index 6ce499427951e1acc1e236d7538521c14f0b63ee,3990d132757f62e7696de42aa025faa8ae940319..7a59e41c89bd41dff436b56d03234e6e89d7deac
@@@ -31,15 -31,19 +31,20 @@@ if(WITH_BULLET
        add_subdirectory(bullet2)
  endif()
  
- if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ if(WITH_MOD_CLOTH_ELTOPO)
+       add_subdirectory(eltopo)
+ endif()
+ if(WITH_BINRELOC)
        add_subdirectory(binreloc)
  endif()
  
- add_subdirectory(glew)
+ if(WITH_BUILTIN_GLEW)
+       add_subdirectory(glew)
+ endif()
 +add_subdirectory(recastnavigation)
  
- if(WITH_IMAGE_OPENJPEG)
+ if(WITH_IMAGE_OPENJPEG AND (NOT UNIX OR APPLE))
        add_subdirectory(libopenjpeg)
  endif()
  
diff --combined extern/SConscript
index 0d4d562336fd7940db04493e4020a07a29e3abcd,061bd1ba6a38bda04eab51704546efed9cec2a9b..88aeb400d13a28ea6ac28738557b8f1be45050b6
@@@ -3,8 -3,10 +3,11 @@@
  Import('env')
  
  SConscript(['glew/SConscript'])
 +SConscript(['recastnavigation/SConscript'])
  
+ if env['WITH_BF_ELTOPO']:
+     SConscript(['eltopo/SConscript'])
  if env['WITH_BF_BULLET']:
      SConscript(['bullet2/src/SConscript'])
  
@@@ -14,7 -16,7 +17,7 @@@ if env['WITH_BF_OPENJPEG'] and env['BF_
  if env['WITH_BF_REDCODE'] and env['BF_REDCODE_LIB'] == '':
      SConscript(['libredcode/SConscript'])
  
- if env['OURPLATFORM'] == 'linux2':
+ if env['WITH_BF_BINRELOC']:
      SConscript(['binreloc/SConscript']);
  
  if env['WITH_BF_LZO']:
index f17cd8a4b9814675a536b48a3f3892da9a134b43,27af84dbcfb2b985978555f7a5239097e28fbbdb..95db7d216fbb49374b315eedbc108b2f1e7cc517
@@@ -59,16 -59,15 +59,15 @@@ class DATA_PT_modifiers(ModifierButtons
          col.prop(md, "use_vertex_groups", text="Vertex Groups")
          col.prop(md, "use_bone_envelopes", text="Bone Envelopes")
  
-         split = layout.split()
+         layout.separator()
  
-         col = split.split()
-         col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-         sub = col.column()
+         row = layout.row()
+         row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+         sub = row.row()
          sub.active = bool(md.vertex_group)
          sub.prop(md, "invert_vertex_group")
  
-         col = layout.column()
-         col.prop(md, "use_multi_modifier")
+         layout.prop(md, "use_multi_modifier")
  
      def ARRAY(self, layout, ob, md):
          layout.prop(md, "fit_type")
  
          layout.separator()
  
-         col = layout.column()
-         col.prop(md, "start_cap")
-         col.prop(md, "end_cap")
+         layout.prop(md, "start_cap")
+         layout.prop(md, "end_cap")
  
      def BEVEL(self, layout, ob, md):
          split = layout.split()
  
-         col = split.column()
-         col.prop(md, "width")
-         col = split.column()
-         col.prop(md, "use_only_vertices")
+         split.prop(md, "width")
+         split.prop(md, "use_only_vertices")
  
          layout.label(text="Limit Method:")
          layout.row().prop(md, "limit_method", expand=True)
              col.prop(md, "use_transform")
  
      def CLOTH(self, layout, ob, md):
-         layout.label(text="See Cloth panel.")
+         layout.label(text="Settings can be found inside the Physics context")
  
      def COLLISION(self, layout, ob, md):
-         layout.label(text="See Collision panel.")
+         layout.label(text="Settings can be found inside the Physics context")
  
      def CURVE(self, layout, ob, md):
          split = layout.split()
  
          col = split.column()
          col.label(text="Texture:")
-         col.prop(md, "texture", text="")
+         col.template_ID(md, "texture", new="texture.new")
          col.label(text="Vertex Group:")
          col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
  
  
          layout.separator()
  
-         split = layout.split()
-         col = split.column()
-         col.prop(md, "mid_level")
-         col = split.column()
-         col.prop(md, "strength")
+         row = layout.row()
+         row.prop(md, "mid_level")
+         row.prop(md, "strength")
  
      def EDGE_SPLIT(self, layout, ob, md):
          split = layout.split()
          sub.active = md.use_edge_angle
          sub.prop(md, "split_angle")
  
-         col = split.column()
-         col.prop(md, "use_edge_sharp", text="Sharp Edges")
+         split.prop(md, "use_edge_sharp", text="Sharp Edges")
  
      def EXPLODE(self, layout, ob, md):
          split = layout.split()
          sub = col.column()
          sub.active = bool(md.vertex_group)
          sub.prop(md, "protect")
+         col.label(text="Particle UV")
+         col.prop_search(md, "particle_uv", ob.data, "uv_textures", text="")
  
          col = split.column()
-         col.prop(md, "use_edge_split")
+         col.prop(md, "use_edge_cut")
          col.prop(md, "show_unborn")
          col.prop(md, "show_alive")
          col.prop(md, "show_dead")
          layout.operator("object.explode_refresh", text="Refresh")
  
      def FLUID_SIMULATION(self, layout, ob, md):
-         layout.label(text="See Fluid panel.")
+         layout.label(text="Settings can be found inside the Physics context")
  
      def HOOK(self, layout, ob, md):
          split = layout.split()
  
      def MESH_DEFORM(self, layout, ob, md):
          split = layout.split()
          col = split.column()
          sub = col.column()
          sub.label(text="Object:")
          else:
              layout.operator("object.meshdeform_bind", text="Bind")
  
-             split = layout.split()
-             col = split.column()
-             col.prop(md, "precision")
-             col = split.column()
-             col.prop(md, "use_dynamic_bind")
+             row = layout.row()
+             row.prop(md, "precision")
+             row.prop(md, "use_dynamic_bind")
  
      def MIRROR(self, layout, ob, md):
          split = layout.split(percentage=0.25)
          col.prop(md, "use_mirror_v", text="V")
  
          col = layout.column()
-         
          if md.use_mirror_merge == True:
              col.prop(md, "merge_threshold")
          col.label(text="Mirror Object:")
          col.prop(md, "mirror_object", text="")
  
-             col.operator("object.assign_navpolygon", text="Assign poly idx")
-             col = split.column()
-             col.operator("object.assign_new_navpolygon", text="Assign new poly idx")
 +    def NAVMESH(self, layout, ob, md):
 +        split = layout.split()
 +        if ob.mode == 'EDIT':
 +            col = split.column()
++        col.operator("object.assign_navpolygon", text="Assign poly idx")
++        col = split.column()
++        col.operator("object.assign_new_navpolygon", text="Assign new poly idx")
 +
      def MULTIRES(self, layout, ob, md):
          layout.row().prop(md, "subdivision_type", expand=True)
  
          col.prop(md, "random_position", text="Random", slider=True)
  
      def PARTICLE_SYSTEM(self, layout, ob, md):
-         layout.label(text="See Particle panel.")
+         layout.label(text="Settings can be found inside the Particle context")
  
      def SCREW(self, layout, ob, md):
          split = layout.split()
              col = split.column()
  
              col.label(text="Cull Faces:")
-             col.prop(md, "use_cull_front_faces", text="Front")
-             col.prop(md, "use_cull_back_faces", text="Back")
+             col.prop(md, "cull_face", expand=True)
  
              layout.label(text="Auxiliary Target:")
              layout.prop(md, "auxiliary_target", text="")
          col.label(text="Deform:")
          col.prop(md, "factor")
          col.prop(md, "limits", slider=True)
-         if md.deform_method in ('TAPER', 'STRETCH'):
+         if md.deform_method in {'TAPER', 'STRETCH'}:
              col.prop(md, "lock_x")
              col.prop(md, "lock_y")
  
      def SMOKE(self, layout, ob, md):
-         layout.label(text="See Smoke panel.")
+         layout.label(text="Settings can be found inside the Physics context")
  
      def SMOOTH(self, layout, ob, md):
          split = layout.split(percentage=0.25)
          col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
  
      def SOFT_BODY(self, layout, ob, md):
-         layout.label(text="See Soft Body panel.")
+         layout.label(text="Settings can be found inside the Physics context")
  
      def SOLIDIFY(self, layout, ob, md):
          split = layout.split()
  
          col = split.column()
          col.prop(md, "edge_crease_inner", text="Inner")
          col.prop(md, "edge_crease_outer", text="Outer")
          col.prop(md, "edge_crease_rim", text="Rim")
+         col.label(text="Material Index Offset:")
  
          col = split.column()
  
          col.prop(md, "offset")
-         colsub = col.column()
-         colsub.active = bool(md.vertex_group)
-         colsub.prop(md, "invert_vertex_group", text="Invert")
+         sub = col.column()
+         sub.active = bool(md.vertex_group)
+         sub.prop(md, "invert_vertex_group", text="Invert")
  
          col.prop(md, "use_even_offset")
          col.prop(md, "use_quality_normals")
          col.prop(md, "use_rim")
-         colsub = col.column()
-         colsub.active = md.use_rim
-         colsub.prop(md, "use_rim_material")
+         sub = col.column()
+         sub.label()
+         row = sub.split(align=True, percentage=0.4)
+         row.prop(md, "material_offset", text="")
+         row = row.row()
+         row.active = md.use_rim
+         row.prop(md, "material_offset_rim", text="Rim")
  
      def SUBSURF(self, layout, ob, md):
          layout.row().prop(md, "subdivision_type", expand=True)
          col.prop(md, "show_only_control_edges")
  
      def SURFACE(self, layout, ob, md):
-         layout.label(text="See Fields panel.")
+         layout.label(text="Settings can be found inside the Physics context")
  
      def UV_PROJECT(self, layout, ob, md):
          if ob.type == 'MESH':
              sub.prop(md, "scale_x", text="Scale X")
              sub.prop(md, "scale_y", text="Scale Y")
  
+     def WARP(self, layout, ob, md):
+         use_falloff = (md.falloff_type != 'NONE')
+         split = layout.split()
+         col = split.column()
+         col.label(text="From:")
+         col.prop(md, "object_from", text="")
+         col.prop(md, "use_volume_preserve")
+         col = split.column()
+         col.label(text="To:")
+         col.prop(md, "object_to", text="")
+         col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+         col = layout.column()
+         row = col.row(align=True)
+         row.prop(md, "strength")
+         if use_falloff:
+             row.prop(md, "falloff_radius")
+         col.prop(md, "falloff_type")
+         if use_falloff:
+             if md.falloff_type == 'CURVE':
+                 col.template_curve_mapping(md, "falloff_curve")
+         # 2 new columns
+         split = layout.split()
+         col = split.column()
+         col.label(text="Texture:")
+         col.prop(md, "texture", text="")
+         col = split.column()
+         col.label(text="Texture Coordinates:")
+         col.prop(md, "texture_coords", text="")
+         if md.texture_coords == 'OBJECT':
+             layout.prop(md, "texture_coordinate_object", text="Object")
+         elif md.texture_coords == 'UV' and ob.type == 'MESH':
+             layout.prop_search(md, "uv_layer", ob.data, "uv_textures")
      def WAVE(self, layout, ob, md):
          split = layout.split()
  
  
          layout.prop(md, "start_position_object")
          layout.prop_search(md, "vertex_group", ob, "vertex_groups")
-         layout.prop(md, "texture")
+         split = layout.split(percentage=0.33)
+         col = split.column()
+         col.label(text="Texture")
+         col = split.column()
+         col.template_ID(md, "texture", new="texture.new")
          layout.prop(md, "texture_coords")
          if md.texture_coords == 'MAP_UV' and ob.type == 'MESH':
              layout.prop_search(md, "uv_layer", ob.data, "uv_textures")
          col.prop(md, "width", slider=True)
          col.prop(md, "narrowness", slider=True)
  
- def register():
+ if __name__ == "__main__":  # only for live edit.
      bpy.utils.register_module(__name__)
- def unregister():
-     bpy.utils.unregister_module(__name__)
- if __name__ == "__main__":
-     register()
index 60934891b7f11446fbcdb32c62c4dcbe685898e3,0c07451b3b2dcdde62413053dbe48b305765863c..6952f3c31db4ffa5a56dc9c3642c07145d6d3fcf
@@@ -47,7 -47,7 +47,7 @@@ class PHYSICS_PT_game_physics(PhysicsBu
          layout.separator()
  
          #if game.physics_type == 'DYNAMIC':
-         if game.physics_type in ('DYNAMIC', 'RIGID_BODY'):
+         if game.physics_type in {'DYNAMIC', 'RIGID_BODY'}:
              split = layout.split()
  
              col = split.column()
@@@ -56,7 -56,7 +56,7 @@@
              col.prop(ob, "hide_render", text="Invisible")  # out of place but useful
  
              col = split.column()
-             col.prop(game, "use_material_physics")
+             col.prop(game, "use_material_physics_fh")
              col.prop(game, "use_rotate_from_normal")
              col.prop(game, "use_sleep")
  
              subsub.active = game.use_anisotropic_friction
              subsub.prop(game, "friction_coefficients", text="", slider=True)
  
-         elif game.physics_type in ('SENSOR', 'INVISIBLE', 'NO_COLLISION', 'OCCLUDE'):
+         elif game.physics_type in {'SENSOR', 'INVISIBLE', 'NO_COLLISION', 'OCCLUDE'}:
              layout.prop(ob, "hide_render", text="Invisible")
  
  
@@@ -175,7 -175,7 +175,7 @@@ class PHYSICS_PT_game_collision_bounds(
      def poll(cls, context):
          game = context.object.game
          rd = context.scene.render
-         return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in cls.COMPAT_ENGINES)
+         return (game.physics_type in {'DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC'}) and (rd.engine in cls.COMPAT_ENGINES)
  
      def draw_header(self, context):
          game = context.active_object.game
          layout.active = game.use_collision_bounds
          layout.prop(game, "collision_bounds_type", text="Bounds")
  
-         split = layout.split()
-         col = split.column()
-         col.prop(game, "collision_margin", text="Margin", slider=True)
-         col = split.column()
-         col.prop(game, "use_collision_compound", text="Compound")
+         row = layout.row()
+         row.prop(game, "collision_margin", text="Margin", slider=True)
+         row.prop(game, "use_collision_compound", text="Compound")
  
 +class PHYSICS_PT_game_obstacles(PhysicsButtonsPanel, bpy.types.Panel):
 +    bl_label = "Create obstacle"
 +    COMPAT_ENGINES = {'BLENDER_GAME'}
-         col.prop(game, "obstacle_radius", text="Radius")
++ 
 +    @classmethod
 +    def poll(self, context):
 +        game = context.object.game
 +        rd = context.scene.render
 +        return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC'))  and (rd.engine in cls.COMPAT_ENGINES)
 +
 +    def draw_header(self, context):
 +        game = context.active_object.game
 +
 +        self.layout.prop(game, "create_obstacle", text="")
 +
 +    def draw(self, context):
 +        layout = self.layout
 +
 +        game = context.active_object.game
 +
 +        layout.active = game.create_obstacle
 +
 +        split = layout.split()
 +        col = split.column()
++        col.prop(game, "obstacle_radius", text="Radius")              
  
  class RenderButtonsPanel():
      bl_space_type = 'PROPERTIES'
@@@ -352,6 -323,7 +348,7 @@@ class RENDER_PT_game_shading(RenderButt
              col.prop(gs, "use_glsl_lights", text="Lights")
              col.prop(gs, "use_glsl_shaders", text="Shaders")
              col.prop(gs, "use_glsl_shadows", text="Shadows")
+             col.prop(gs, "use_glsl_color_management", text="Color Management")
  
              col = split.column()
              col.prop(gs, "use_glsl_ramps", text="Ramps")
@@@ -385,7 -357,7 +382,7 @@@ class RENDER_PT_game_display(RenderButt
          flow.prop(gs, "show_framerate_profile", text="Framerate and Profile")
          flow.prop(gs, "show_physics_visualization", text="Physics Visualization")
          flow.prop(gs, "use_deprecation_warnings")
-         flow.prop(gs, "show_mouse")
+         flow.prop(gs, "show_mouse", text="Mouse Cursor")
  
  
  class RENDER_PT_game_sound(RenderButtonsPanel, bpy.types.Panel):
@@@ -447,13 -419,9 +444,9 @@@ class WORLD_PT_game_world(WorldButtonsP
  
          world = context.world
  
-         split = layout.split()
-         col = split.column()
-         col.prop(world, "horizon_color")
-         col = split.column()
-         col.prop(world, "ambient_color")
+         row = layout.row()
+         row.column().prop(world, "horizon_color")
+         row.column().prop(world, "ambient_color")
  
  
  class WORLD_PT_game_mist(WorldButtonsPanel, bpy.types.Panel):
          world = context.world
  
          layout.active = world.mist_settings.use_mist
-         split = layout.split()
-         col = split.column()
-         col.prop(world.mist_settings, "start")
  
-         col = split.column()
-         col.prop(world.mist_settings, "depth")
+         row = layout.row()
+         row.prop(world.mist_settings, "start")
+         row.prop(world.mist_settings, "depth")
  
  
  class WORLD_PT_game_physics(WorldButtonsPanel, bpy.types.Panel):
              col.label(text="Logic Steps:")
              col.prop(gs, "logic_step_max", text="Max")
  
- def register():
 +class WORLD_PT_game_physics_obstacles(WorldButtonsPanel, bpy.types.Panel):
 +    bl_label = "Obstacle simulation"
 +    COMPAT_ENGINES = {'BLENDER_GAME'}
 +
 +    def draw(self, context):
 +        layout = self.layout
 +
 +        gs = context.scene.game_settings
 +
 +        layout.prop(gs, "obstacle_simulation", text = "Type")
 +        if gs.obstacle_simulation != 'None':
 +            layout.prop(gs, "level_height")
 +            layout.prop(gs, "show_obstacle_simulation")
 +
+ if __name__ == "__main__":  # only for live edit.
      bpy.utils.register_module(__name__)
- def unregister():
-     bpy.utils.unregister_module(__name__)
- if __name__ == "__main__":
-     register()
index 51fe7c9e132107c2cb18c05bdaff94c24aa5ae82,7725f6616934489646f33b259a9cef60dc3458f0..ce5ac0c62d3b3a8672053ea211284970de56ab54
@@@ -55,14 -55,10 +55,10 @@@ class SCENE_PT_unit(SceneButtonsPanel, 
          col.row().prop(unit, "system", expand=True)
          col.row().prop(unit, "system_rotation", expand=True)
  
-         split = layout.split()
-         split.active = (unit.system != 'NONE')
-         col = split.column()
-         col.prop(unit, "scale_length", text="Scale")
-         col = split.column()
-         col.prop(unit, "use_separate")
+         row = layout.row()
+         row.active = (unit.system != 'NONE')
+         row.prop(unit, "scale_length", text="Scale")
+         row.prop(unit, "use_separate")
  
  
  class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel):
@@@ -199,9 -195,6 +195,6 @@@ class SCENE_PT_custom_props(SceneButton
      _context_path = "scene"
      _property_type = bpy.types.Scene
  
- from bpy.props import *
  #  XXX, move operator to op/ dir
  
  
@@@ -309,84 -302,5 +302,76 @@@ class ANIM_OT_keying_set_export(bpy.typ
          wm.fileselect_add(self)
          return {'RUNNING_MODAL'}
  
-     bl_label = "Navmesh"
-     bl_default_closed = True
-     COMPAT_ENGINES = {'BLENDER_GAME'}
-     def draw(self, context):
-         layout = self.layout
-         rd = context.scene.game_settings.recast_data
-         layout.operator("object.create_navmesh", text='Build navigation mesh')
-         layout.label(text="Rasterization:")
-         split = layout.split()
-         col = split.column()
-         col.prop(rd, "cell_size")
-         col = split.column()
-         col.prop(rd, "cell_height")
-         layout.separator()
-         layout.label(text="Agent:")
-         split = layout.split()
-         col = split.column()
-         row = col.row()
-         row.prop(rd, "agent_height")
-         row = col.row()
-         row.prop(rd, "agent_radius")
-         col = split.column()
-         row = col.row()
-         row.prop(rd, "max_slope")
-         row = col.row()
-         row.prop(rd, "max_climb")
-         layout.separator()
-         layout.label(text="Region:")
-         split = layout.split()
-         col = split.column()
-         col.prop(rd, "region_min_size")
-         col = split.column()
-         col.prop(rd, "region_merge_size")
-         layout.separator()
-         layout.label(text="Polygonization:")
-         split = layout.split()
-         col = split.column()
-         row = col.row()
-         row.prop(rd, "edge_max_len")
-         row = col.row()
-         row.prop(rd, "edge_max_error")
-         col = split.column()
-         row = col.row()
-         row.prop(rd, "verts_per_poly")
-         layout.separator()
-         layout.label(text="Detail Mesh:")
-         split = layout.split()
-         col = split.column()
-         col.prop(rd, "sample_dist")
-         col = split.column()
-         col.prop(rd, "sample_max_error")
- def register():
 +class SCENE_PT_navmesh(SceneButtonsPanel, bpy.types.Panel):
++     bl_label = "Navmesh"
++     bl_default_closed = True
++     COMPAT_ENGINES = {'BLENDER_GAME'}
++ 
++     def draw(self, context):
++         layout = self.layout
++ 
++         rd = context.scene.game_settings.recast_data
++ 
++         layout.operator("object.create_navmesh", text='Build navigation mesh')
++ 
++         layout.label(text="Rasterization:")
++         split = layout.split()
++ 
++         col = split.column()
++         col.prop(rd, "cell_size")
++         col = split.column()
++         col.prop(rd, "cell_height")
++ 
++         layout.separator()
++ 
++         layout.label(text="Agent:")
++         split = layout.split()
++ 
++         col = split.column()
++         row = col.row()
++         row.prop(rd, "agent_height")
++         row = col.row()
++         row.prop(rd, "agent_radius")
++ 
++         col = split.column()
++         row = col.row()
++         row.prop(rd, "max_slope")
++         row = col.row()
++         row.prop(rd, "max_climb")
++ 
++         layout.separator()
++ 
++         layout.label(text="Region:")
++         split = layout.split()
++         col = split.column()
++         col.prop(rd, "region_min_size")
++ 
++         col = split.column()
++         col.prop(rd, "region_merge_size")
++ 
++         layout.separator()
++ 
++         layout.label(text="Polygonization:")
++         split = layout.split()
++         col = split.column()
++         row = col.row()
++         row.prop(rd, "edge_max_len")
++         row = col.row()
++         row.prop(rd, "edge_max_error")
++ 
++         col = split.column()
++         row = col.row()
++         row.prop(rd, "verts_per_poly")
++ 
++         layout.separator()
++ 
++         layout.label(text="Detail Mesh:")
++         split = layout.split()
++         col = split.column()
++         col.prop(rd, "sample_dist")
++ 
++         col = split.column()
++         col.prop(rd, "sample_max_error")
++
+ if __name__ == "__main__":  # only for live edit.
      bpy.utils.register_module(__name__)
- def unregister():
-     bpy.utils.unregister_module(__name__)
- if __name__ == "__main__":
-     register()
index 6ba7268303a9461f6a2c3ec209d02664dbdce0a7,f5f069767eb4666c0fca282dcbc5b47166e4371f..bffb4c3852a9c95a78a5bbe3ef5e7591f382123c
  *
  * BKE_customdata.h contains the function prototypes for this file.
  *
- */ 
+ */
+ /** \file blender/blenkernel/intern/customdata.c
+  *  \ingroup bke
+  */
+  
  
  #include <math.h>
  #include <string.h>
@@@ -469,19 -474,19 +474,19 @@@ static void layerInterp_mdisps(void **s
                                                        vindex[x] = y;
  
                        for(i = 0; i < 2; i++) {
-                               float sw[4][4] = {{0}};
+                               float sw_m4[4][4] = {{0}};
                                int a = 7 & ~(1 << vindex[i*2] | 1 << vindex[i*2+1]);
  
-                               sw[0][vindex[i*2+1]] = 1;
-                               sw[1][vindex[i*2]] = 1;
+                               sw_m4[0][vindex[i*2+1]] = 1;
+                               sw_m4[1][vindex[i*2]] = 1;
  
                                for(x = 0; x < 3; x++)
                                        if(a & (1 << x))
-                                               sw[2][x] = 1;
+                                               sw_m4[2][x] = 1;
  
                                tris[i] = *((MDisps*)sources[i]);
                                tris[i].disps = MEM_dupallocN(tris[i].disps);
-                               layerInterp_mdisps(&sources[i], NULL, (float*)sw, 1, &tris[i]);
+                               layerInterp_mdisps(&sources[i], NULL, (float*)sw_m4, 1, &tris[i]);
                        }
  
                        mdisp_join_tris(d, &tris[0], &tris[1]);
        }
  
        /* Initialize the destination */
-       out = disps = MEM_callocN(3*d->totdisp*sizeof(float), "iterp disps");
+       disps = MEM_callocN(3*d->totdisp*sizeof(float), "iterp disps");
  
        side = sqrt(d->totdisp / dst_corners);
        st = (side<<1)-1;
@@@ -803,7 -808,7 +808,7 @@@ static void layerDefault_mcol(void *dat
  
  
  
- const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL,
         NULL},
        {sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL},
        {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL},
        {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol},
-       {sizeof(float)*3*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        {sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
         layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL, layerRead_mdisps, layerWrite_mdisps,
         layerFilesize_mdisps, layerValidate_mdisps},
         layerSwap_mcol, layerDefault_mcol},
         {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
 -      {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}
 +      {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
 +      {sizeof(MRecast), "MRecast", 1,"Recast",NULL,NULL,NULL,NULL}
  };
  
- const char *LAYERTYPENAMES[CD_NUMTYPES] = {
static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
        /*   0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace",
        /*   5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
        /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco",
        /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps",
 -      /* 20-23 */"CDWeightMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco"
 +      /* 20-24 */"CDWeightMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast"
  };
  
  const CustomDataMask CD_MASK_BAREMESH =
  const CustomDataMask CD_MASK_MESH =
        CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
        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_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS | CD_MASK_RECAST;
  const CustomDataMask CD_MASK_EDITMESH =
        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_MCOL|CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS | CD_MASK_RECAST;
  const CustomDataMask CD_MASK_DERIVEDMESH =
        CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
        CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO |
 -      CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO | CD_MASK_TANGENT | CD_MASK_WEIGHT_MCOL;
 +      CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO | CD_MASK_TANGENT | CD_MASK_WEIGHT_MCOL | CD_MASK_RECAST;
  const CustomDataMask CD_MASK_BMESH = 
        CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR;
  const CustomDataMask CD_MASK_FACECORNERS =
index 1dc99c02f8b10269784bc0fad9f566b67f3ba99a,cbe0a959f1587e6f55fbed77cbf693b627621487..c889be9e51304d1c4eba3d58ff49eb99c4b8f0ac
   * ***** END GPL LICENSE BLOCK *****
   */
  
+ /** \file blender/blenkernel/intern/object.c
+  *  \ingroup bke
+  */
  #include <string.h>
  #include <math.h>
  #include <stdio.h>                    
@@@ -92,6 -97,7 +97,7 @@@
  #include "BKE_scene.h"
  #include "BKE_sequencer.h"
  #include "BKE_softbody.h"
+ #include "BKE_material.h"
  
  #include "LBM_fluidsim.h"
  
@@@ -203,8 -209,8 +209,8 @@@ void object_link_modifiers(struct Objec
                BLI_addtail(&ob->modifiers, nmd);
        }
  
-       copy_object_particlesystems(from, ob);
-       copy_object_softbody(from, ob);
+       copy_object_particlesystems(ob, from);
+       copy_object_softbody(ob, from);
  
        // TODO: smoke?, cloth?
  }
@@@ -273,7 -279,7 +279,7 @@@ void free_object(Object *ob
                        else if(ob->type==OB_CURVE) unlink_curve(ob->data);
                        else if(ob->type==OB_MBALL) unlink_mball(ob->data);
                }
-               ob->data= 0;
+               ob->data= NULL;
        }
        
        for(a=0; a<ob->totcol; a++) {
        }
        if(ob->mat) MEM_freeN(ob->mat);
        if(ob->matbits) MEM_freeN(ob->matbits);
-       ob->mat= 0;
-       ob->matbits= 0;
+       ob->mat= NULL;
+       ob->matbits= NULL;
        if(ob->bb) MEM_freeN(ob->bb); 
-       ob->bb= 0;
+       ob->bb= NULL;
        if(ob->path) free_path(ob->path); 
-       ob->path= 0;
+       ob->path= NULL;
        if(ob->adt) BKE_free_animdata((ID *)ob);
        if(ob->poselib) ob->poselib->id.us--;
        if(ob->gpd) ((ID *)ob->gpd)->us--;
@@@ -731,51 -737,45 +737,45 @@@ void make_local_camera(Camera *cam
  {
        Main *bmain= G.main;
        Object *ob;
-       Camera *camn;
        int local=0, lib=0;
  
        /* - only lib users: do nothing
-               * - only local users: set flag
-               * - mixed: make copy
-               */
+        * - only local users: set flag
+        * - mixed: make copy
+        */
        
-       if(cam->id.lib==0) return;
+       if(cam->id.lib==NULL) return;
        if(cam->id.us==1) {
-               cam->id.lib= 0;
+               cam->id.lib= NULL;
                cam->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)cam, 0);
+               new_id(&bmain->camera, (ID *)cam, NULL);
                return;
        }
        
-       ob= bmain->object.first;
-       while(ob) {
+       for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) {
                if(ob->data==cam) {
                        if(ob->id.lib) lib= 1;
                        else local= 1;
                }
-               ob= ob->id.next;
        }
        
        if(local && lib==0) {
-               cam->id.lib= 0;
+               cam->id.lib= NULL;
                cam->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)cam, 0);
+               new_id(&bmain->camera, (ID *)cam, NULL);
        }
        else if(local && lib) {
-               camn= copy_camera(cam);
+               Camera *camn= copy_camera(cam);
                camn->id.us= 0;
                
-               ob= bmain->object.first;
-               while(ob) {
-                       if(ob->data==cam) {
-                               
-                               if(ob->id.lib==0) {
+               for(ob= bmain->object.first; ob; ob= ob->id.next) {
+                       if(ob->data == cam) {
+                               if(ob->id.lib==NULL) {
                                        ob->data= camn;
                                        camn->id.us++;
                                        cam->id.us--;
                                }
                        }
-                       ob= ob->id.next;
                }
        }
  }
@@@ -888,11 -888,11 +888,11 @@@ void make_local_lamp(Lamp *la
                * - mixed: make copy
                */
        
-       if(la->id.lib==0) return;
+       if(la->id.lib==NULL) return;
        if(la->id.us==1) {
-               la->id.lib= 0;
+               la->id.lib= NULL;
                la->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)la, 0);
+               new_id(&bmain->lamp, (ID *)la, NULL);
                return;
        }
        
        }
        
        if(local && lib==0) {
-               la->id.lib= 0;
+               la->id.lib= NULL;
                la->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)la, 0);
+               new_id(&bmain->lamp, (ID *)la, NULL);
        }
        else if(local && lib) {
                lan= copy_lamp(la);
                while(ob) {
                        if(ob->data==la) {
                                
-                               if(ob->id.lib==0) {
+                               if(ob->id.lib==NULL) {
                                        ob->data= lan;
                                        lan->id.us++;
                                        la->id.us--;
@@@ -1057,7 -1057,6 +1057,7 @@@ Object *add_only_object(int type, cons
        ob->state=1;
        /* ob->pad3 == Contact Processing Threshold */
        ob->m_contactProcessingThreshold = 1.;
 +      ob->obstacleRad = 1.;
        
        /* NT fluid sim defaults */
        ob->fluidsimFlag = 0;
@@@ -1079,7 -1078,7 +1079,7 @@@ Object *add_object(struct Scene *scene
        Base *base;
        char name[32];
  
-       strcpy(name, get_obdata_defname(type));
+       BLI_strncpy(name, get_obdata_defname(type), sizeof(name));
        ob = add_only_object(type, name);
  
        ob->data= add_obdata_from_type(type);
@@@ -1128,7 -1127,7 +1128,7 @@@ BulletSoftBody *copy_bulletsoftbody(Bul
        return bsbn;
  }
  
- ParticleSystem *copy_particlesystem(ParticleSystem *psys)
static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
  {
        ParticleSystem *psysn;
        ParticleData *pa;
@@@ -1362,11 -1361,10 +1362,10 @@@ Object *copy_object(Object *ob
        return obn;
  }
  
void expand_local_object(Object *ob)
static void extern_local_object(Object *ob)
  {
        //bActionStrip *strip;
        ParticleSystem *psys;
-       int a;
  
  #if 0 // XXX old animation system
        id_lib_extern((ID *)ob->action);
  #endif // XXX old animation system
        id_lib_extern((ID *)ob->data);
        id_lib_extern((ID *)ob->dup_group);
-       
-       for(a=0; a<ob->totcol; a++) {
-               id_lib_extern((ID *)ob->mat[a]);
-       }
+       id_lib_extern((ID *)ob->poselib);
+       id_lib_extern((ID *)ob->gpd);
+       extern_local_matarar(ob->mat, ob->totcol);
  #if 0 // XXX old animation system
        for (strip=ob->nlastrips.first; strip; strip=strip->next) {
                id_lib_extern((ID *)strip->act);
  void make_local_object(Object *ob)
  {
        Main *bmain= G.main;
-       Object *obn;
        Scene *sce;
        Base *base;
        int local=0, lib=0;
  
        /* - only lib users: do nothing
-               * - only local users: set flag
-               * - mixed: make copy
-               */
-       
+        * - only local users: set flag
+        * - mixed: make copy
+        */
        if(ob->id.lib==NULL) return;
        
        ob->proxy= ob->proxy_from= NULL;
        if(ob->id.us==1) {
                ob->id.lib= NULL;
                ob->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)ob, 0);
+               new_id(&bmain->object, (ID *)ob, NULL);
        }
        else {
-               sce= bmain->scene.first;
-               while(sce) {
-                       base= sce->base.first;
-                       while(base) {
-                               if(base->object==ob) {
-                                       if(sce->id.lib) lib++;
-                                       else local++;
-                                       break;
-                               }
-                               base= base->next;
+               for(sce= bmain->scene.first; sce && ELEM(0, lib, local); sce= sce->id.next) {
+                       if(object_in_scene(ob, sce)) {
+                               if(sce->id.lib) lib= 1;
+                               else local= 1;
                        }
-                       sce= sce->id.next;
                }
-               
                if(local && lib==0) {
-                       ob->id.lib= 0;
+                       ob->id.lib= NULL;
                        ob->id.flag= LIB_LOCAL;
-                       new_id(0, (ID *)ob, 0);
+                       new_id(&bmain->object, (ID *)ob, NULL);
                }
                else if(local && lib) {
-                       obn= copy_object(ob);
+                       Object *obn= copy_object(ob);
                        obn->id.us= 0;
                        
                        sce= bmain->scene.first;
                        while(sce) {
-                               if(sce->id.lib==0) {
+                               if(sce->id.lib==NULL) {
                                        base= sce->base.first;
                                        while(base) {
                                                if(base->object==ob) {
                }
        }
        
-       expand_local_object(ob);
+       extern_local_object(ob);
  }
  
  /*
@@@ -1559,6 -1549,12 +1550,12 @@@ void object_make_proxy(Object *ob, Obje
        if(gob) {
                ob->rotmode= target->rotmode;
                mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat);
+               if(gob->dup_group) { /* should always be true */
+                       float tvec[3];
+                       copy_v3_v3(tvec, gob->dup_group->dupli_ofs);
+                       mul_mat3_m4_v3(ob->obmat, tvec);
+                       sub_v3_v3(ob->obmat[3], tvec);
+               }
                object_apply_mat4(ob, ob->obmat, FALSE, TRUE);
        }
        else {
                
                armature_set_id_extern(ob);
        }
+       else if (target->type == OB_EMPTY) {
+               ob->empty_drawtype = target->empty_drawtype;
+               ob->empty_drawsize = target->empty_drawsize;
+       }
  
        /* copy IDProperties */
        if(ob->id.properties) {
  
  /* there is also a timing calculation in drawobject() */
  
- int no_speed_curve= 0;
static int no_speed_curve= 0;
  
  void disable_speed_curve(int val)
  {
@@@ -1689,10 -1689,10 +1690,10 @@@ void object_rot_to_mat3(Object *ob, flo
        else {
                /* quats are normalised before use to eliminate scaling issues */
                float tquat[4];
+               
                normalize_qt_qt(tquat, ob->quat);
                quat_to_mat3(rmat, tquat);
+               
                normalize_qt_qt(tquat, ob->dquat);
                quat_to_mat3(dmat, tquat);
        }
@@@ -1736,7 -1736,7 +1737,7 @@@ void object_apply_mat4(Object *ob, floa
                invert_m4_m4(imat, diff_mat);
                mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
                object_apply_mat4(ob, rmat, use_compat, FALSE);
+               
                /* same as below, use rmat rather then mat */
                mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat);
                object_mat3_to_rot(ob, rot, use_compat);
@@@ -1776,6 -1776,7 +1777,7 @@@ void object_to_mat4(Object *ob, float m
        add_v3_v3v3(mat[3], ob->loc, ob->dloc);
  }
  
+ /* extern */
  int enable_cu_speed= 1;
  
  static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
                 * we divide the curvetime calculated in the previous step by the length of the path, to get a time
                 * factor, which then gets clamped to lie within 0.0 - 1.0 range
                 */
-               ctime= cu->ctime / cu->pathlen;
-               CLAMP(ctime, 0.0, 1.0);
+               if (IS_EQF(cu->pathlen, 0.0f) == 0)
+                       ctime= cu->ctime / cu->pathlen;
+               else
+                       ctime= cu->ctime;
+               CLAMP(ctime, 0.0f, 1.0f);
        }
        else {
                ctime= scene->r.cfra - give_timeoffset(ob);
-               ctime /= cu->pathlen;
+               if (IS_EQF(cu->pathlen, 0.0f) == 0)
+                       ctime /= cu->pathlen;
                
-               CLAMP(ctime, 0.0, 1.0);
+               CLAMP(ctime, 0.0f, 1.0f);
        }
        
        /* time calculus is correct, now apply distance offset */
@@@ -2258,12 -2264,12 +2265,12 @@@ void what_does_parent(Scene *scene, Obj
        workob->constraints.first = ob->constraints.first;
        workob->constraints.last = ob->constraints.last;
  
-       strcpy(workob->parsubstr, ob->parsubstr); 
+       BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
  
        where_is_object(scene, workob);
  }
  
- BoundBox *unit_boundbox()
+ BoundBox *unit_boundbox(void)
  {
        BoundBox *bb;
        float min[3] = {-1.0f,-1.0f,-1.0f}, max[3] = {-1.0f,-1.0f,-1.0f};
@@@ -2322,9 -2328,9 +2329,9 @@@ void object_get_dimensions(Object *ob, 
                
                mat4_to_size( scale,ob->obmat);
                
-               value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
-               value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
-               value[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
+               value[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
+               value[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
+               value[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
        } else {
                value[0] = value[1] = value[2] = 0.f;
        }
@@@ -2546,6 -2552,9 +2553,9 @@@ void object_handle_update(Scene *scene
                                        Object *obg= ob->proxy_from->proxy_group;
                                        invert_m4_m4(obg->imat, obg->obmat);
                                        mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat);
+                                       if(obg->dup_group) { /* should always be true */
+                                               add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
+                                       }
                                }
                                else
                                        copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
@@@ -2802,6 -2811,16 +2812,16 @@@ int object_insert_ptcache(Object *ob
        return i;
  }
  
+ void object_camera_mode(RenderData *rd, Object *camera)
+ {
+       rd->mode &= ~(R_ORTHO|R_PANORAMA);
+       if(camera && camera->type==OB_CAMERA) {
+               Camera *cam= camera->data;
+               if(cam->type == CAM_ORTHO) rd->mode |= R_ORTHO;
+               if(cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA;
+       }
+ }
  /* 'lens' may be set for envmap only */
  void object_camera_matrix(
                RenderData *rd, Object *camera, int winx, int winy, short field_second,
        Camera *cam=NULL;
        float pixsize;
        float shiftx=0.0, shifty=0.0, winside, viewfac;
-       rd->mode &= ~(R_ORTHO|R_PANORAMA);
+       short is_ortho= FALSE;
  
        /* question mark */
        (*ycor)= rd->yasp / rd->xasp;
        if(camera->type==OB_CAMERA) {
                cam= camera->data;
  
-               if(cam->type==CAM_ORTHO) rd->mode |= R_ORTHO;
-               if(cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA;
+               if(cam->type == CAM_ORTHO) {
+                       is_ortho= TRUE;
+               }
  
                /* solve this too... all time depending stuff is in convertblender.c?
                 * Need to update the camera early because it's used for projection matrices
        }
        else if(camera->type==OB_LAMP) {
                Lamp *la= camera->data;
-               float fac= cos( M_PI*la->spotsize/360.0 );
+               float fac= cosf((float)M_PI*la->spotsize/360.0f);
                float phi= acos(fac);
  
-               (*lens)= 16.0*fac/sin(phi);
+               (*lens)= 16.0f*fac/sinf(phi);
                if((*lens)==0.0f)
-                       (*lens)= 35.0;
+                       (*lens)= 35.0f;
                (*clipsta)= la->clipsta;
                (*clipend)= la->clipend;
        }
        else {  /* envmap exception... */;
                if((*lens)==0.0f)
-                       (*lens)= 16.0;
+                       (*lens)= 16.0f;
  
                if((*clipsta)==0.0f || (*clipend)==0.0f) {
                        (*clipsta)= 0.1f;
        }
  
        /* ortho only with camera available */
-       if(cam && rd->mode & R_ORTHO) {
+       if(cam && is_ortho) {
                if(rd->xasp*winx >= rd->yasp*winy) {
                        viewfac= winx;
                }
                pixsize= cam->ortho_scale/viewfac;
        }
        else {
-               if(rd->xasp*winx >= rd->yasp*winy)      viewfac= ((*lens) * winx)/32.0;
-               else                                                            viewfac= (*ycor) * ((*lens) * winy)/32.0;
+               if(rd->xasp*winx >= rd->yasp*winy)      viewfac= ((*lens) * winx)/32.0f;
+               else                                                            viewfac= (*ycor) * ((*lens) * winy)/32.0f;
                pixsize= (*clipsta) / viewfac;
        }
  
  
        if(field_second) {
                if(rd->mode & R_ODDFIELD) {
-                       viewplane->ymin-= 0.5 * (*ycor);
-                       viewplane->ymax-= 0.5 * (*ycor);
+                       viewplane->ymin-= 0.5f * (*ycor);
+                       viewplane->ymax-= 0.5f * (*ycor);
                }
                else {
-                       viewplane->ymin+= 0.5 * (*ycor);
-                       viewplane->ymax+= 0.5 * (*ycor);
+                       viewplane->ymin+= 0.5f * (*ycor);
+                       viewplane->ymax+= 0.5f * (*ycor);
                }
        }
        /* the window matrix is used for clipping, and not changed during OSA steps */
        (*viewdx)= pixsize;
        (*viewdy)= (*ycor) * pixsize;
  
-       if(rd->mode & R_ORTHO)
+       if(is_ortho)
                orthographic_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend);
        else
                perspective_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend);
@@@ -3051,3 -3070,53 +3071,53 @@@ KeyBlock *object_insert_shape_key(Scen
        else                                                                     return NULL;
  }
  
+ /* most important if this is modified it should _always_ return True, in certain
+  * cases false positives are hard to avoid (shape keys for eg)
+  */
+ int object_is_modified(Scene *scene, Object *ob)
+ {
+       int flag= 0;
+       if(ob_get_key(ob)) {
+               flag |= eModifierMode_Render | eModifierMode_Render;
+       }
+       else {
+               ModifierData *md;
+               /* cloth */
+               for(md=modifiers_getVirtualModifierList(ob); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); md=md->next) {
+                       if((flag & eModifierMode_Render) == 0   && modifier_isEnabled(scene, md, eModifierMode_Render))         flag |= eModifierMode_Render;
+                       if((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime))       flag |= eModifierMode_Realtime;
+               }
+       }
+       return flag;
+ }
+ static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin)
+ {
+       /* this is copied from ID_NEW; it might be better to have a macro */
+       if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid;
+ }
+ void object_relink(Object *ob)
+ {
+       if(ob->id.lib)
+               return;
+       relink_constraints(&ob->constraints);
+       if (ob->pose){
+               bPoseChannel *chan;
+               for (chan = ob->pose->chanbase.first; chan; chan=chan->next){
+                       relink_constraints(&chan->constraints);
+               }
+       }
+       modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL);
+       if(ob->adt)
+               BKE_relink_animdata(ob->adt);
+       ID_NEW(ob->parent);
+       ID_NEW(ob->proxy);
+       ID_NEW(ob->proxy_group);
+ }
index 202a236b4318252da3206c45edae6e01d1a0d1eb,16cef67ea6d2c098c67435e2a193ff573cf9864f..ee410e75873a1a510ae9e0911e326220e08f7009
@@@ -1,4 -1,4 +1,4 @@@
- /**
+ /*
   * $Id$
   *
   * ***** BEGIN GPL LICENSE BLOCK *****
   * all data is 'direct data', not Blender lib data.
   */
  
+ /** \file blender/blenkernel/intern/sca.c
+  *  \ingroup bke
+  */
  #include <stdio.h>
  #include <string.h>
  #include <float.h>
@@@ -86,7 -91,7 +91,7 @@@ void copy_sensors(ListBase *lbn, ListBa
  {
        bSensor *sens, *sensn;
        
-       lbn->first= lbn->last= 0;
+       lbn->first= lbn->last= NULL;
        sens= lbo->first;
        while(sens) {
                sensn= copy_sensor(sens);
@@@ -253,7 -258,7 +258,7 @@@ void copy_controllers(ListBase *lbn, Li
  {
        bController *cont, *contn;
        
-       lbn->first= lbn->last= 0;
+       lbn->first= lbn->last= NULL;
        cont= lbo->first;
        while(cont) {
                contn= copy_controller(cont);
@@@ -267,7 -272,7 +272,7 @@@ void init_controller(bController *cont
        /* also use when controller changes type, leave actuators... */
        
        if(cont->data) MEM_freeN(cont->data);
-       cont->data= 0;
+       cont->data= NULL;
        
        switch(cont->type) {
        case CONT_EXPRESSION:
@@@ -328,12 -333,12 +333,12 @@@ void free_actuator(bActuator *act
  
        if(act->data) {
                switch (act->type) {
-                       case ACT_SOUND:
-                               sa = (bSoundActuator *) act->data;
-                               if(sa->sound)
-                                       id_us_min((ID *) sa->sound);
-                               break;
-               }
+               case ACT_SOUND:
+                       sa = (bSoundActuator *) act->data;
+                       if(sa->sound)
+                               id_us_min((ID *) sa->sound);
+                       break;
+               }
  
                MEM_freeN(act->data);
        }
@@@ -375,7 -380,7 +380,7 @@@ void copy_actuators(ListBase *lbn, List
  {
        bActuator *act, *actn;
        
-       lbn->first= lbn->last= 0;
+       lbn->first= lbn->last= NULL;
        act= lbo->first;
        while(act) {
                actn= copy_actuator(act);
@@@ -391,10 -396,9 +396,10 @@@ void init_actuator(bActuator *act
        bObjectActuator *oa;
        bRandomActuator *ra;
        bSoundActuator *sa;
 +      bSteeringActuator *sta;
        
        if(act->data) MEM_freeN(act->data);
-       act->data= 0;
+       act->data= NULL;
        
        switch(act->type) {
        case ACT_ACTION:
        case ACT_ARMATURE:
                act->data = MEM_callocN(sizeof( bArmatureActuator ), "armature act");
                break;
 +      case ACT_STEERING:
 +              act->data = MEM_callocN(sizeof( bSteeringActuator), "steering act");
 +              sta = act->data;
 +              sta->acceleration = 3.f;
 +              sta->turnspeed = 120.f;
 +              sta->dist = 1.f;
 +              sta->velocity= 3.f;
 +              sta->flag = ACT_STEERING_AUTOMATICFACING;
 +              sta->facingaxis = 1;
 +              break;
        default:
                ; /* this is very severe... I cannot make any memory for this        */
                /* logic brick...                                                    */
@@@ -523,7 -517,7 +528,7 @@@ void clear_sca_new_poins_ob(Object *ob
        }
  }
  
- void clear_sca_new_poins()
+ void clear_sca_new_poins(void)
  {
        Object *ob;
        
@@@ -600,18 -594,13 +605,18 @@@ void set_sca_new_poins_ob(Object *ob
                                bPropertyActuator *pa= act->data;
                                ID_NEW(pa->ob);
                        }
 +                      else if(act->type==ACT_STEERING) {
 +                              bSteeringActuator *sta = act->data;
 +                              ID_NEW(sta->navmesh);
 +                              ID_NEW(sta->target);
 +                      }
                }
                act= act->next;
        }
  }
  
  
- void set_sca_new_poins()
+ void set_sca_new_poins(void)
  {
        Object *ob;
        
index e6a7d714cd05161ff974642606f09f14a504653f,791d572d385930384c91035f971353f8dab9bb24..749c820ab4eb220c8a8e1f04dafb7f392e8b6013
   * ***** END GPL LICENSE BLOCK *****
   */
  
+ /** \file blender/blenkernel/intern/scene.c
+  *  \ingroup bke
+  */
  #include <stddef.h>
  #include <stdio.h>
  #include <string.h>
@@@ -507,23 -512,6 +512,23 @@@ Scene *add_scene(const char *name
        sce->gm.flag = GAME_DISPLAY_LISTS;
        sce->gm.matmode = GAME_MAT_MULTITEX;
  
 +      sce->gm.obstacleSimulation= OBSTSIMULATION_NONE;
 +      sce->gm.levelHeight = 2.f;
 +
 +      sce->gm.recastData.cellsize = 0.3f;
 +      sce->gm.recastData.cellheight = 0.2f;
 +      sce->gm.recastData.agentmaxslope = M_PI/2;
 +      sce->gm.recastData.agentmaxclimb = 0.9f;
 +      sce->gm.recastData.agentheight = 2.0f;
 +      sce->gm.recastData.agentradius = 0.6f;
 +      sce->gm.recastData.edgemaxlen = 12.0f;
 +      sce->gm.recastData.edgemaxerror = 1.3f;
 +      sce->gm.recastData.regionminsize = 50.f;
 +      sce->gm.recastData.regionmergesize = 20.f;
 +      sce->gm.recastData.vertsperpoly = 6;
 +      sce->gm.recastData.detailsampledist = 6.0f;
 +      sce->gm.recastData.detailsamplemaxerror = 1.0f;
 +
        sound_create_scene(sce);
  
        return sce;
@@@ -844,54 -832,6 +849,6 @@@ char *scene_find_last_marker_name(Scen
        return best_marker ? best_marker->name : NULL;
  }
  
- /* markers need transforming from different parts of the code so have
-  * a generic function to do this */
- int scene_marker_tfm_translate(Scene *scene, int delta, int flag)
- {
-       TimeMarker *marker;
-       int tot= 0;
-       for (marker= scene->markers.first; marker; marker= marker->next) {
-               if ((marker->flag & flag) == flag) {
-                       marker->frame += delta;
-                       tot++;
-               }
-       }
-       return tot;
- }
- int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char side)
- {
-       TimeMarker *marker;
-       int tot= 0;
-       for (marker= scene->markers.first; marker; marker= marker->next) {
-               if ((marker->flag & flag) == flag) {
-                       if((side=='L' && marker->frame < frame) || (side=='R' && marker->frame >= frame)) {
-                               marker->frame += delta;
-                               tot++;
-                       }
-               }
-       }
-       return tot;
- }
- int scene_marker_tfm_scale(struct Scene *scene, float value, int flag)
- {
-       TimeMarker *marker;
-       int tot= 0;
-       for (marker= scene->markers.first; marker; marker= marker->next) {
-               if ((marker->flag & flag) == flag) {
-                       marker->frame= CFRA + (int)floorf(((float)(marker->frame - CFRA) * value) + 0.5f);
-                       tot++;
-               }
-       }
-       return tot;
- }
  
  Base *scene_add_base(Scene *sce, Object *ob)
  {
@@@ -1140,23 -1080,23 +1097,23 @@@ float get_render_aosss_error(RenderDat
  /* helper function for the SETLOOPER macro */
  Base *_setlooper_base_step(Scene **sce_iter, Base *base)
  {
-     if(base && base->next) {
-         /* common case, step to the next */
-         return base->next;
-     }
+       if(base && base->next) {
+               /* common case, step to the next */
+               return base->next;
+       }
        else if(base==NULL && (*sce_iter)->base.first) {
-         /* first time looping, return the scenes first base */
+               /* first time looping, return the scenes first base */
                return (Base *)(*sce_iter)->base.first;
-     }
-     else {
-         /* reached the end, get the next base in the set */
+       }
+       else {
+               /* reached the end, get the next base in the set */
                while((*sce_iter= (*sce_iter)->set)) {
                        base= (Base *)(*sce_iter)->base.first;
-             if(base) {
-                 return base;
-             }
-         }
-     }
+                       if(base) {
+                               return base;
+                       }
+               }
+       }
  
-     return NULL;
+       return NULL;
  }
index 3b62b5a5e477daf237a249960169e3fe548e414a,e1b13e0ee50b3afea4aa64ae9052a29466d2909c..320c169fb4c774773ffd9d34cfdbe6f23d9010e4
   *
   */
  
+ /** \file blender/blenloader/intern/readfile.c
+  *  \ingroup blenloader
+  */
  #include "zlib.h"
  
  #include <limits.h>
@@@ -229,7 -234,7 +234,7 @@@ typedef struct OldNewMap 
  
  /* local prototypes */
  static void *read_struct(FileData *fd, BHead *bh, const char *blockname);
+ static void direct_link_modifiers(FileData *fd, ListBase *lb);
  
  static OldNewMap *oldnewmap_new(void) 
  {
@@@ -285,6 -290,8 +290,8 @@@ static void *oldnewmap_lookup_and_inc(O
  {
        int i;
  
+       if(addr==NULL) return NULL;
        if (onm->lasthit<onm->nentries-1) {
                OldNew *entry= &onm->entries[++onm->lasthit];
  
@@@ -422,7 -429,7 +429,7 @@@ static void split_libdata(ListBase *lb
                                }
                                mainvar= mainvar->next;
                        }
-                       if(mainvar==0) printf("error split_libdata\n");
+                       if(mainvar==NULL) printf("error split_libdata\n");
                }
                id= idnext;
        }
@@@ -495,7 -502,7 +502,7 @@@ static Main *blo_find_main(FileData *fd
        for (m= mainlist->first; m; m= m->next) {
                char *libname= (m->curlib)?m->curlib->filepath:m->name;
                
-               if (BLI_streq(name1, libname)) {
+               if (BLI_path_cmp(name1, libname) == 0) {
                        if(G.f & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
                        return m;
                }
@@@ -589,7 -596,7 +596,7 @@@ static void bh8_from_bh4(BHead *bhead, 
  
  static BHeadN *get_bhead(FileData *fd)
  {
-       BHeadN *new_bhead = 0;
+       BHeadN *new_bhead = NULL;
        int readsize;
        
        if (fd) {
                        if ( ! fd->eof) {
                                new_bhead = MEM_mallocN(sizeof(BHeadN) + bhead.len, "new_bhead");
                                if (new_bhead) {
-                                       new_bhead->next = new_bhead->prev = 0;
+                                       new_bhead->next = new_bhead->prev = NULL;
                                        new_bhead->bhead = bhead;
  
                                        readsize = fd->read(fd, new_bhead + 1, bhead.len);
                                        if (readsize != bhead.len) {
                                                fd->eof = 1;
                                                MEM_freeN(new_bhead);
-                                               new_bhead = 0;
+                                               new_bhead = NULL;
                                        }
                                } else {
                                        fd->eof = 1;
  BHead *blo_firstbhead(FileData *fd)
  {
        BHeadN *new_bhead;
-       BHead *bhead = 0;
+       BHead *bhead = NULL;
  
        // Rewind the file
        // Read in a new block if necessary
  
        new_bhead = fd->listbase.first;
-       if (new_bhead == 0) {
+       if (new_bhead == NULL) {
                new_bhead = get_bhead(fd);
        }
  
@@@ -721,7 -728,7 +728,7 @@@ BHead *blo_nextbhead(FileData *fd, BHea
  
                // get the next BHeadN. If it doesn't exist we read in the next one
                new_bhead = new_bhead->next;
-               if (new_bhead == 0) {
+               if (new_bhead == NULL) {
                        new_bhead = get_bhead(fd);
                }
        }
@@@ -944,8 -951,8 +951,8 @@@ FileData *blo_openblenderfile(const cha
        errno= 0;
        gzfile= gzopen(name, "rb");
  
-       if (gzfile == Z_NULL) {
-               BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", name, errno ? strerror(errno) : "Unknown erro reading file");
+       if (gzfile == (gzFile)Z_NULL) {
+               BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", name, errno ? strerror(errno) : "Unknown error reading file");
                return NULL;
        } else {
                FileData *fd = filedata_new();
@@@ -1007,7 -1014,7 +1014,7 @@@ void blo_freefiledata(FileData *fd
  
                if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) {
                        MEM_freeN(fd->buffer);
-                       fd->buffer = 0;
+                       fd->buffer = NULL;
                }
  
                // Free all BHeadN data blocks
@@@ -1061,7 -1068,7 +1068,7 @@@ int BLO_is_a_library(const char *path, 
        /* Find the last slash */
        fd= BLI_last_slash(dir);
  
-       if(fd==0) return 0;
+       if(fd==NULL) return 0;
        *fd= 0;
        if(BLO_has_bfile_extension(fd+1)) {
                /* the last part of the dir is a .blend file, no group follows */
@@@ -1195,11 -1202,11 +1202,11 @@@ void blo_end_image_pointer_map(FileDat
        OldNew *entry= fd->imamap->entries;
        Image *ima= oldmain->image.first;
        Scene *sce= oldmain->scene.first;
-       int i, a;
+       int i;
        
        /* used entries were restored, so we put them to zero */
        for (i=0; i<fd->imamap->nentries; i++, entry++) {
-                if (entry->nr>0)
+               if (entry->nr>0)
                        entry->newp= NULL;
        }
        
                                ima->gputexture= NULL;
                        }
                }
+               for(i=0; i<IMA_MAX_RENDER_SLOT; i++)
+                       ima->renders[i]= newimaadr(fd, ima->renders[i]);
  
                ima->gputexture= newimaadr(fd, ima->gputexture);
-               for(a=0; a<IMA_MAX_RENDER_SLOT; a++)
-                       ima->renders[a]= newimaadr(fd, ima->renders[a]);
        }
        for(; sce; sce= sce->id.next) {
                if(sce->nodetree) {
@@@ -1310,7 -1317,7 +1317,7 @@@ static void link_glob_list(FileData *fd
        Link *ln, *prev;
        void *poin;
  
-       if(lb->first==0) return;
+       if(lb->first==NULL) return;
        poin= newdataadr(fd, lb->first);
        if(lb->first) {
                oldnewmap_insert(fd->globmap, lb->first, poin, 0);
        lb->first= poin;
  
        ln= lb->first;
-       prev= 0;
+       prev= NULL;
        while(ln) {
                poin= newdataadr(fd, ln->next);
                if(ln->next) {
@@@ -1459,7 -1466,7 +1466,7 @@@ static void IDP_DirectLinkGroup(IDPrope
        }
  }
  
- void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
  {
        switch (prop->type) {
                case IDP_GROUP:
  }
  
  /*stub function*/
- void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endian), FileData *UNUSED(fd))
static void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endian), FileData *UNUSED(fd))
  {
  }
  
@@@ -1858,6 -1865,10 +1865,10 @@@ static void lib_link_nladata_strips(Fil
                
                /* reassign the counted-reference to action */
                strip->act = newlibadr_us(fd, id->lib, strip->act);
+               
+               /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
+               if ((strip->act) && (strip->act->idroot == 0))
+                       strip->act->idroot = GS(id->name);
        }
  }
  
@@@ -1889,7 -1900,7 +1900,7 @@@ static void direct_link_nladata_strips(
                
                /* strip's F-Modifiers */
                link_list(fd, &strip->modifiers);
-               direct_link_fcurves(fd, &strip->modifiers);
+               direct_link_modifiers(fd, &strip->modifiers);
        }
  }
  
@@@ -1951,6 -1962,12 +1962,12 @@@ static void lib_link_animdata(FileData 
        adt->action= newlibadr_us(fd, id->lib, adt->action);
        adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact);
        
+       /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
+       if ((adt->action) && (adt->action->idroot == 0))
+               adt->action->idroot = GS(id->name);
+       if ((adt->tmpact) && (adt->tmpact->idroot == 0))
+               adt->tmpact->idroot = GS(id->name);
+       
        /* link drivers */
        lib_link_fcurves(fd, id, &adt->drivers);
        
@@@ -2028,6 -2045,55 +2045,55 @@@ static void lib_link_nodetree(FileData 
        }
  }
  
+ /* updates group node socket own_index so that
+  * external links to/from the group node are preserved.
+  */
+ static void lib_node_do_versions_group(bNode *gnode)
+ {
+       bNodeTree *ngroup= (bNodeTree*)gnode->id;
+       bNode *intnode;
+       bNodeSocket *sock, *gsock, *intsock;
+       int found;
+       
+       for (sock=gnode->outputs.first; sock; sock=sock->next) {
+               int old_index = sock->to_index;
+               for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) {
+                       if (gsock->link && gsock->link->fromsock->own_index == old_index) {
+                               sock->own_index = gsock->own_index;
+                               break;
+                       }
+               }
+       }
+       for (sock=gnode->inputs.first; sock; sock=sock->next) {
+               int old_index = sock->to_index;
+               /* can't use break in double loop */
+               found = 0;
+               for (intnode=ngroup->nodes.first; intnode && !found; intnode=intnode->next) {
+                       for (intsock=intnode->inputs.first; intsock; intsock=intsock->next) {
+                               if (intsock->own_index == old_index && intsock->link) {
+                                       sock->own_index = intsock->link->fromsock->own_index;
+                                       found = 1;
+                                       break;
+                               }
+                       }
+               }
+       }
+ }
+ /* updates external links for all group nodes in a tree */
+ static void lib_nodetree_do_versions_group(bNodeTree *ntree)
+ {
+       bNode *node;
+       
+       for (node=ntree->nodes.first; node; node=node->next) {
+               if (node->type==NODE_GROUP) {
+                       bNodeTree *ngroup= (bNodeTree*)node->id;
+                       if (ngroup->flag & NTREE_DO_VERSIONS)
+                               lib_node_do_versions_group(node);
+               }
+       }
+ }
  /* verify types for nodes and groups, all data has to be read */
  /* open = 0: appending/linking, open = 1: open new file (need to clean out dynamic
  * typedefs*/
@@@ -2046,10 -2112,43 +2112,43 @@@ static void lib_verify_nodetree(Main *m
        /* now create the own typeinfo structs an verify nodes */
        /* here we still assume no groups in groups */
        for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) {
-               ntreeVerifyTypes(ntree);        /* internal nodes, no groups! */
-               ntreeMakeOwnType(ntree);        /* for group usage */
+               ntreeVerifyTypes(ntree);                /* internal nodes, no groups! */
        }
        
+       {
+               int has_old_groups=0;
+               /* XXX this should actually be part of do_versions, but since we need
+                * finished library linking, it is not possible there. Instead in do_versions
+                * we have set the NTREE_DO_VERSIONS flag, so at this point we can do the
+                * actual group node updates.
+                */
+               for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) {
+                       if (ntree->flag & NTREE_DO_VERSIONS) {
+                               /* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
+                               nodeGroupExposeAllSockets(ntree);
+                               has_old_groups = 1;
+                       }
+               }
+               /* now verify all types in material trees, groups are set OK now */
+               for(ma= main->mat.first; ma; ma= ma->id.next) {
+                       if(ma->nodetree)
+                               lib_nodetree_do_versions_group(ma->nodetree);
+               }
+               /* and scene trees */
+               for(sce= main->scene.first; sce; sce= sce->id.next) {
+                       if(sce->nodetree)
+                               lib_nodetree_do_versions_group(sce->nodetree);
+               }
+               /* and texture trees */
+               for(tx= main->tex.first; tx; tx= tx->id.next) {
+                       if(tx->nodetree)
+                               lib_nodetree_do_versions_group(tx->nodetree);
+               }
+               
+               for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next)
+                       ntree->flag &= ~NTREE_DO_VERSIONS;
+       }
        /* now verify all types in material trees, groups are set OK now */
        for(ma= main->mat.first; ma; ma= ma->id.next) {
                if(ma->nodetree)
@@@ -2078,7 -2177,6 +2177,6 @@@ static void direct_link_nodetree(FileDa
        bNodeLink *link;
        
        ntree->init= 0;         /* to set callbacks and force setting types */
-       ntree->owntype= NULL;
        ntree->progress= NULL;
        
        ntree->adt= newdataadr(fd, ntree->adt);
        }
        link_list(fd, &ntree->links);
        
+       /* external sockets */
+       link_list(fd, &ntree->inputs);
+       link_list(fd, &ntree->outputs);
+       
        /* and we connect the rest */
        for(node= ntree->nodes.first; node; node= node->next) {
                node->preview= newimaadr(fd, node->preview);
                for(sock= node->outputs.first; sock; sock= sock->next)
                        sock->ns.data= NULL;
        }
+       for(sock= ntree->outputs.first; sock; sock= sock->next)
+               sock->link= newdataadr(fd, sock->link);
+       
        for(link= ntree->links.first; link; link= link->next) {
                link->fromnode= newdataadr(fd, link->fromnode);
                link->tonode= newdataadr(fd, link->tonode);
                link->fromsock= newdataadr(fd, link->fromsock);
                link->tosock= newdataadr(fd, link->tosock);
        }
-               
+       
        /* type verification is in lib-link */
  }
  
@@@ -2680,8 -2785,18 +2785,18 @@@ static void direct_link_image(FileData 
        ima->anim= NULL;
        ima->rr= NULL;
        ima->repbind= NULL;
-       memset(ima->renders, 0, sizeof(ima->renders));
-       ima->last_render_slot= ima->render_slot;
+       
+       /* undo system, try to restore render buffers */
+       if(fd->imamap) {
+               int a;
+               
+               for(a=0; a<IMA_MAX_RENDER_SLOT; a++)
+                       ima->renders[a]= newimaadr(fd, ima->renders[a]);
+       }
+       else {
+               memset(ima->renders, 0, sizeof(ima->renders));
+               ima->last_render_slot= ima->render_slot;
+       }
        
        ima->packedfile = direct_link_packedfile(fd, ima->packedfile);
        ima->preview = direct_link_preview_image(fd, ima->preview);
@@@ -2755,7 -2870,7 +2870,7 @@@ static void direct_link_curve(FileData 
  
        if(cu->vfont == NULL) link_list(fd, &(cu->nurb));
        else {
-               cu->nurb.first=cu->nurb.last= 0;
+               cu->nurb.first=cu->nurb.last= NULL;
  
                tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBoxread");
                if (cu->tb) {
                        cu->tb = tb;
                        cu->tb[0].w = cu->linewidth;
                }               
-               if (cu->wordspace == 0.0) cu->wordspace = 1.0;
+               if (cu->wordspace == 0.0f) cu->wordspace = 1.0f;
        }
  
        cu->bev.first=cu->bev.last= NULL;
@@@ -2829,7 -2944,7 +2944,7 @@@ static void direct_link_texture(FileDat
        
        tex->plugin= newdataadr(fd, tex->plugin);
        if(tex->plugin) {
-               tex->plugin->handle= 0;
+               tex->plugin->handle= NULL;
                open_plugin_tex(tex->plugin);
                /* initialize data for this instance, if an initialization
                 * function exists.
        if(tex->pd) {
                tex->pd->point_tree = NULL;
                tex->pd->coba= newdataadr(fd, tex->pd->coba);
+               tex->pd->falloff_curve= newdataadr(fd, tex->pd->falloff_curve);
+               if(tex->pd->falloff_curve) {
+                       direct_link_curvemapping(fd, tex->pd->falloff_curve);
+               }
        }
        
        tex->vd= newdataadr(fd, tex->vd);
@@@ -3007,7 -3126,7 +3126,7 @@@ static void direct_link_pointcache_list
        }
  }
  
- void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
  {
        if(pd && pd->tex)
                pd->tex=newlibadr_us(fd, id->lib, pd->tex);
@@@ -3017,6 -3136,8 +3136,8 @@@ static void lib_link_particlesettings(F
  {
        ParticleSettings *part;
        ParticleDupliWeight *dw;
+       MTex *mtex;
+       int a;
  
        part= main->particle.first;
        while(part) {
                                        }
                                }
                        }
+                       
+                       for(a=0; a<MAX_MTEX; a++) {
+                               mtex= part->mtex[a];
+                               if(mtex) {
+                                       mtex->tex = newlibadr_us(fd, part->id.lib, mtex->tex);
+                                       mtex->object = newlibadr(fd, part->id.lib, mtex->object);
+                               }
+                       }
                        part->id.flag -= LIB_NEEDLINK;
                }
                part= part->id.next;
@@@ -3075,6 -3205,7 +3205,7 @@@ static void direct_link_partdeflect(Par
  
  static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
  {
+       int a;
        part->adt= newdataadr(fd, part->adt);
        part->pd= newdataadr(fd, part->pd);
        part->pd2= newdataadr(fd, part->pd2);
                        link_list(fd, &state->actions);
                }
        }
+       for(a=0; a<MAX_MTEX; a++) {
+               part->mtex[a]= newdataadr(fd, part->mtex[a]);
+       }
  }
  
  static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles)
@@@ -3212,6 -3346,7 +3346,7 @@@ static void direct_link_particlesystems
                }
  
                psys->tree = NULL;
+               psys->bvhtree = NULL;
        }
        return;
  }
@@@ -3281,15 -3416,19 +3416,19 @@@ static void lib_link_mesh(FileData *fd
  
  static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts)
  {
-       int     i;
+       int i;
  
-       if (!mdverts)
+       if (mdverts == NULL) {
                return;
+       }
  
-       for (i=0; i<count; i++) {
-               mdverts[i].dw=newdataadr(fd, mdverts[i].dw);
-               if (!mdverts[i].dw)
-                       mdverts[i].totweight=0;
+       for (i= count; i > 0; i--, mdverts++) {
+               if(mdverts->dw) {
+                       mdverts->dw= newdataadr(fd, mdverts->dw);
+               }
+               if (mdverts->dw == NULL) {
+                       mdverts->totweight= 0;
+               }
        }
  }
  
@@@ -3559,7 -3698,7 +3698,7 @@@ static void lib_link_object(FileData *f
  
                        ob->gpd= newlibadr_us(fd, ob->id.lib, ob->gpd);
                        ob->duplilist= NULL;
-             
                        ob->id.flag -= LIB_NEEDLINK;
                        /* if id.us==0 a new base will be created later on */
                        
                                }
                                else if(act->type==ACT_OBJECT) {
                                        bObjectActuator *oa= act->data;
-                                       oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+                                       if(oa==NULL) {
+                                               init_actuator(act);
+                                       }
+                                       else {
+                                               oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
+                                       }
                                }
                                else if(act->type==ACT_EDIT_OBJECT) {
                                        bEditObjectActuator *eoa= act->data;
                                                eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
                                        }
                                }
-                               else if(act->type==ACT_OBJECT) {
-                                       bObjectActuator *oa= act->data;
-                                       if(oa==NULL) {
-                                               init_actuator(act);
-                                       }
-                                       else {
-                                               oa->reference= newlibadr(fd, ob->id.lib, oa->reference);
-                                       }
-                               }
                                else if(act->type==ACT_SCENE) {
                                        bSceneActuator *sa= act->data;
                                        sa->camera= newlibadr(fd, ob->id.lib, sa->camera);
                                        arma->target= newlibadr(fd, ob->id.lib, arma->target);
                                        arma->subtarget= newlibadr(fd, ob->id.lib, arma->subtarget);
                                }
 +                              else if(act->type==ACT_STEERING) {
 +                                      bSteeringActuator *steeringa = act->data; 
 +                                      steeringa->target = newlibadr(fd, ob->id.lib, steeringa->target);
 +                                      steeringa->navmesh = newlibadr(fd, ob->id.lib, steeringa->navmesh);
 +                              }
                                act= act->next;
                        }
                        
@@@ -3803,7 -3933,7 +3938,7 @@@ static void direct_link_modifiers(FileD
                if (md->type==eModifierType_Subsurf) {
                        SubsurfModifierData *smd = (SubsurfModifierData*) md;
  
-                       smd->emCache = smd->mCache = 0;
+                       smd->emCache = smd->mCache = NULL;
                }
                else if (md->type==eModifierType_Armature) {
                        ArmatureModifierData *amd = (ArmatureModifierData*) md;
                        
                        fluidmd->fss= newdataadr(fd, fluidmd->fss);
                        fluidmd->fss->fmd= fluidmd;
-                       fluidmd->fss->meshSurfNormals = 0;
+                       fluidmd->fss->meshSurfNormals = NULL;
                }
                else if (md->type==eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData*) md;
  
                                /* Smoke uses only one cache from now on, so store pointer convert */
                                if(smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) {
-                                       printf("High resolution smoke cache not available due to pointcache update. Please reset the simulation.\n");
+                                       if(smd->domain->point_cache[1]) {
+                                               PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]);
+                                               if(cache->flag & PTCACHE_FAKE_SMOKE)
+                                                       ; /* Smoke was already saved in "new format" and this cache is a fake one. */
+                                               else
+                                                       printf("High resolution smoke cache not available due to pointcache update. Please reset the simulation.\n");
+                                               BKE_ptcache_free(cache);
+                                       }
                                        smd->domain->ptcaches[1].first = NULL;
                                        smd->domain->ptcaches[1].last = NULL;
                                        smd->domain->point_cache[1] = NULL;
                        collmd->current_x = NULL;
                        collmd->current_xnew = NULL;
                        collmd->current_v = NULL;
-                       collmd->time = -1000;
+                       collmd->time_x = collmd->time_xnew = -1000;
                        collmd->numverts = 0;
                        collmd->bvhtree = NULL;
                        collmd->mfaces = NULL;
                } else if (md->type==eModifierType_Explode) {
                        ExplodeModifierData *psmd = (ExplodeModifierData*) md;
  
-                       psmd->facepa=0;
+                       psmd->facepa=NULL;
                }
                else if (md->type==eModifierType_MeshDeform) {
                        MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
                                                SWITCH_INT(mmd->bindcos[a])
                        }
                }
+               else if (md->type==eModifierType_Warp) {
+                       WarpModifierData *tmd = (WarpModifierData *) md;
+                       tmd->curfalloff= newdataadr(fd, tmd->curfalloff);
+                       if(tmd->curfalloff)
+                               direct_link_curvemapping(fd, tmd->curfalloff);
+               }
        }
  }
  
@@@ -4116,7 -4260,7 +4265,7 @@@ static void direct_link_object(FileDat
        prop= ob->prop.first;
        while(prop) {
                prop->poin= newdataadr(fd, prop->poin);
-               if(prop->poin==0) prop->poin= &prop->data;
+               if(prop->poin==NULL) prop->poin= &prop->data;
                prop= prop->next;
        }
  
  
        if(ob->sculpt) {
                ob->sculpt= MEM_callocN(sizeof(SculptSession), "reload sculpt session");
-               ob->sculpt->ob= ob;
        }
  }
  
@@@ -4263,13 -4406,14 +4411,14 @@@ static void lib_link_scene(FileData *fd
                                        BKE_reportf(fd->reports, RPT_ERROR, "LIB ERROR: Object lost from scene:'%s\'\n", sce->id.name+2);
                                        if(G.background==0) printf("LIB ERROR: base removed from scene:'%s\'\n", sce->id.name+2);
                                        BLI_remlink(&sce->base, base);
-                                       if(base==sce->basact) sce->basact= 0;
+                                       if(base==sce->basact) sce->basact= NULL;
                                        MEM_freeN(base);
                                }
                        }
  
                        SEQ_BEGIN(sce->ed, seq) {
                                if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo);
+                               seq->scene_sound = NULL;
                                if(seq->scene) {
                                        seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
                                        seq->scene_sound = sound_scene_add_scene_sound(sce, seq, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
                                                seq->scene_sound = sound_add_scene_sound(sce, seq, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
                                        }
                                }
-                               seq->anim= 0;
+                               seq->anim= NULL;
                        }
                        SEQ_END
  
@@@ -4346,8 -4490,10 +4495,10 @@@ static void direct_link_scene(FileData 
        sce->theDag = NULL;
        sce->dagisvalid = 0;
        sce->obedit= NULL;
-       sce->stats= 0;
+       sce->stats= NULL;
        sce->fps_info= NULL;
+       sce->customdata_mask_modal= 0;
+       sce->lay_updated = 0;
  
        sound_create_scene(sce);
  
                        seq->seq2= newdataadr(fd, seq->seq2);
                        seq->seq3= newdataadr(fd, seq->seq3);
                        /* a patch: after introduction of effects with 3 input strips */
-                       if(seq->seq3==0) seq->seq3= seq->seq2;
+                       if(seq->seq3==NULL) seq->seq3= seq->seq2;
  
                        seq->plugin= newdataadr(fd, seq->plugin);
                        seq->effectdata= newdataadr(fd, seq->effectdata);
                                        seq->strip->stripdata = newdataadr(
                                                fd, seq->strip->stripdata);
                                } else {
-                                       seq->strip->stripdata = 0;
+                                       seq->strip->stripdata = NULL;
                                }
                                if (seq->flag & SEQ_USE_CROP) {
                                        seq->strip->crop = newdataadr(
                                                fd, seq->strip->crop);
                                } else {
-                                       seq->strip->crop = 0;
+                                       seq->strip->crop = NULL;
                                }
                                if (seq->flag & SEQ_USE_TRANSFORM) {
                                        seq->strip->transform = newdataadr(
                                                fd, seq->strip->transform);
                                } else {
-                                       seq->strip->transform = 0;
+                                       seq->strip->transform = NULL;
                                }
                                if (seq->flag & SEQ_USE_PROXY) {
                                        seq->strip->proxy = newdataadr(
                                                fd, seq->strip->proxy);
-                                       seq->strip->proxy->anim = 0;
+                                       seq->strip->proxy->anim = NULL;
                                } else {
-                                       seq->strip->proxy = 0;
+                                       seq->strip->proxy = NULL;
                                }
                                if (seq->flag & SEQ_USE_COLOR_BALANCE) {
                                        seq->strip->color_balance = newdataadr(
                                                fd, seq->strip->color_balance);
                                } else {
-                                       seq->strip->color_balance = 0;
+                                       seq->strip->color_balance = NULL;
                                }
                                if (seq->strip->color_balance) {
                                        // seq->strip->color_balance->gui = 0; // XXX - peter, is this relevant in 2.5?
@@@ -4790,6 -4936,8 +4941,8 @@@ static void lib_link_screen(FileData *f
                                                        else if(GS(snode->id->name)==ID_TE)
                                                                snode->nodetree= ((Tex *)snode->id)->nodetree;
                                                }
+                                               
+                                               snode->linkdrag.first = snode->linkdrag.last = NULL;
                                        }
                                }
                                sa= sa->next;
@@@ -5045,7 -5193,6 +5198,6 @@@ static void direct_link_region(FileDat
                        rv3d->clipbb= newdataadr(fd, rv3d->clipbb);
                        
                        rv3d->depths= NULL;
-                       rv3d->retopo_view_data= NULL;
                        rv3d->ri= NULL;
                        rv3d->sms= NULL;
                        rv3d->smooth_timer= NULL;
@@@ -5230,10 -5377,12 +5382,12 @@@ static void direct_link_screen(FileDat
                                
                                /* WARNING: gpencil data is no longer stored directly in sima after 2.5 
                                 * so sacrifice a few old files for now to avoid crashes with new files!
-                                */
-                               //sima->gpd= newdataadr(fd, sima->gpd);
-                               //if (sima->gpd)
-                               //      direct_link_gpencil(fd, sima->gpd);
+                                * committed: r28002 */
+ #if 0
+                               sima->gpd= newdataadr(fd, sima->gpd);
+                               if (sima->gpd)
+                                       direct_link_gpencil(fd, sima->gpd);
+ #endif
                        }
                        else if(sl->spacetype==SPACE_NODE) {
                                SpaceNode *snode= (SpaceNode *)sl;
@@@ -5325,7 -5474,7 +5479,7 @@@ static void direct_link_library(FileDat
        
        for(newmain= fd->mainlist.first; newmain; newmain= newmain->next) {
                if(newmain->curlib) {
-                       if(strcmp(newmain->curlib->filepath, lib->filepath)==0) {
+                       if(BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
                                printf("Fixed error in file; multiple instances of lib:\n %s\n", lib->filepath);
                                BKE_reportf(fd->reports, RPT_WARNING, "Library '%s', '%s' had multiple instances, save and reload!", lib->name, lib->filepath);
  
@@@ -5700,8 -5849,8 +5854,8 @@@ static BHead *read_global(BlendFileDat
  static void link_global(FileData *fd, BlendFileData *bfd)
  {
        
-       bfd->curscreen= newlibadr(fd, 0, bfd->curscreen);
-       bfd->curscene= newlibadr(fd, 0, bfd->curscene);
+       bfd->curscreen= newlibadr(fd, NULL, bfd->curscreen);
+       bfd->curscene= newlibadr(fd, NULL, bfd->curscene);
        // this happens in files older than 2.35
        if(bfd->curscene==NULL) {
                if(bfd->curscreen) bfd->curscene= bfd->curscreen->scene;
@@@ -5714,7 -5863,7 +5868,7 @@@ static void vcol_to_fcol(Mesh *me
        unsigned int *mcol, *mcoln, *mcolmain;
        int a;
  
-       if(me->totface==0 || me->mcol==0) return;
+       if(me->totface==0 || me->mcol==NULL) return;
  
        mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln");
        mcol = (unsigned int *)me->mcol;
@@@ -6374,7 -6523,7 +6528,7 @@@ static void area_add_window_regions(Scr
                                
                                ar->v2d.max[0]= MAXFRAMEF;
                                ar->v2d.max[1]= FLT_MAX;
-                               
                                ar->v2d.minzoom= 0.01f;
                                ar->v2d.maxzoom= 50;
                                ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
@@@ -6525,10 -6674,14 +6679,14 @@@ static void do_versions_gpencil_2_50(Ma
                        }
                        else if (sl->spacetype==SPACE_IMAGE) {
                                SpaceImage *sima= (SpaceImage *)sl;
+ #if 0                 /* see comment on r28002 */
                                if(sima->gpd) {
                                        versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image");
                                        sima->gpd= NULL;
                                }
+ #else
+                               sima->gpd= NULL;
+ #endif
                        }
                }
        }               
@@@ -6581,7 -6734,6 +6739,6 @@@ static void do_version_mtex_factor_2_50
                        mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac;
                        mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac;
                        mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac;
-                       mtex->pvelfac= (neg & MAP_PA_PVEL)? -varfac: varfac;
  
                        mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac;
  
@@@ -6692,7 -6844,7 +6849,7 @@@ static void do_version_bone_roll_256(Bo
        float submat[3][3];
        
        copy_m3_m4(submat, bone->arm_mat);
-       mat3_to_vec_roll(submat, 0, &bone->arm_roll);
+       mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
        
        for(child = bone->childbase.first; child; child = child->next)
                do_version_bone_roll_256(child);
@@@ -6818,19 -6970,12 +6975,12 @@@ static void do_versions(FileData *fd, L
                        sc= sc->id.next;
                }
        }
-       if(main->versionfile <= 112) {
-               Mesh *me = main->mesh.first;
-               while(me) {
-                       me->cubemapsize= 1.0;
-                       me= me->id.next;
-               }
-       }
        if(main->versionfile <= 113) {
                Material *ma = main->mat.first;
                while(ma) {
-                       if(ma->flaresize==0.0) ma->flaresize= 1.0;
-                       ma->subsize= 1.0;
-                       ma->flareboost= 1.0;
+                       if(ma->flaresize==0.0f) ma->flaresize= 1.0f;
+                       ma->subsize= 1.0f;
+                       ma->flareboost= 1.0f;
                        ma= ma->id.next;
                }
        }
        if(main->versionfile <= 134) {
                Tex *tex = main->tex.first;
                while (tex) {
-                       if ((tex->rfac == 0.0) &&
-                               (tex->gfac == 0.0) &&
-                               (tex->bfac == 0.0)) {
-                               tex->rfac = 1.0;
-                               tex->gfac = 1.0;
-                               tex->bfac = 1.0;
-                               tex->filtersize = 1.0;
+                       if ((tex->rfac == 0.0f) &&
+                               (tex->gfac == 0.0f) &&
+                               (tex->bfac == 0.0f)) {
+                               tex->rfac = 1.0f;
+                               tex->gfac = 1.0f;
+                               tex->bfac = 1.0f;
+                               tex->filtersize = 1.0f;
                        }
                        tex = tex->id.next;
                }
                /* r-g-b-fac in texture */
                Tex *tex = main->tex.first;
                while (tex) {
-                       if ((tex->rfac == 0.0) &&
-                               (tex->gfac == 0.0) &&
-                               (tex->bfac == 0.0)) {
-                               tex->rfac = 1.0;
-                               tex->gfac = 1.0;
-                               tex->bfac = 1.0;
-                               tex->filtersize = 1.0;
+                       if ((tex->rfac == 0.0f) &&
+                               (tex->gfac == 0.0f) &&
+                               (tex->bfac == 0.0f)) {
+                               tex->rfac = 1.0f;
+                               tex->gfac = 1.0f;
+                               tex->bfac = 1.0f;
+                               tex->filtersize = 1.0f;
                        }
                        tex = tex->id.next;
                }
        if(main->versionfile <= 153) {
                Scene *sce = main->scene.first;
                while(sce) {
-                       if(sce->r.blurfac==0.0) sce->r.blurfac= 1.0;
+                       if(sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f;
                        sce= sce->id.next;
                }
        }
                                TFace *tface= me->tface;
                                for(a=0; a<me->totface; a++, tface++) {
                                        for(b=0; b<4; b++) {
-                                               tface->uv[b][0]/= 32767.0;
-                                               tface->uv[b][1]/= 32767.0;
+                                               tface->uv[b][0]/= 32767.0f;
+                                               tface->uv[b][1]/= 32767.0f;
                                        }
                                }
                        }
                                if(act->type==ACT_OBJECT) {
                                        oa= act->data;
  
-                                       oa->forceloc[0]*= 25.0;
-                                       oa->forceloc[1]*= 25.0;
-                                       oa->forceloc[2]*= 25.0;
+                                       oa->forceloc[0]*= 25.0f;
+                                       oa->forceloc[1]*= 25.0f;
+                                       oa->forceloc[2]*= 25.0f;
  
-                                       oa->forcerot[0]*= 10.0;
-                                       oa->forcerot[1]*= 10.0;
-                                       oa->forcerot[2]*= 10.0;
+                                       oa->forcerot[0]*= 10.0f;
+                                       oa->forcerot[1]*= 10.0f;
+                                       oa->forcerot[2]*= 10.0f;
                                }
                                act= act->next;
                        }
  
                sound = main->sound.first;
                while (sound) {
-                       if (sound->volume < 0.01) {
-                               sound->volume = 1.0;
+                       if (sound->volume < 0.01f) {
+                               sound->volume = 1.0f;
                        }
                        sound = sound->id.next;
                }
                                if (act->type==ACT_OBJECT) {
                                        /* multiply velocity with 50 in old files */
                                        oa= act->data;
-                                       if (fabs(oa->linearvelocity[0]) >= 0.01f)
-                                               oa->linearvelocity[0] *= 50.0;
-                                       if (fabs(oa->linearvelocity[1]) >= 0.01f)
-                                               oa->linearvelocity[1] *= 50.0;
-                                       if (fabs(oa->linearvelocity[2]) >= 0.01f)
-                                               oa->linearvelocity[2] *= 50.0;
-                                       if (fabs(oa->angularvelocity[0])>=0.01f)
-                                               oa->angularvelocity[0] *= 50.0;
-                                       if (fabs(oa->angularvelocity[1])>=0.01f)
-                                               oa->angularvelocity[1] *= 50.0;
-                                       if (fabs(oa->angularvelocity[2])>=0.01f)
-                                               oa->angularvelocity[2] *= 50.0;
+                                       if (fabsf(oa->linearvelocity[0]) >= 0.01f)
+                                               oa->linearvelocity[0] *= 50.0f;
+                                       if (fabsf(oa->linearvelocity[1]) >= 0.01f)
+                                               oa->linearvelocity[1] *= 50.0f;
+                                       if (fabsf(oa->linearvelocity[2]) >= 0.01f)
+                                               oa->linearvelocity[2] *= 50.0f;
+                                       if (fabsf(oa->angularvelocity[0])>=0.01f)
+                                               oa->angularvelocity[0] *= 50.0f;
+                                       if (fabsf(oa->angularvelocity[1])>=0.01f)
+                                               oa->angularvelocity[1] *= 50.0f;
+                                       if (fabsf(oa->angularvelocity[2])>=0.01f)
+                                               oa->angularvelocity[2] *= 50.0f;
                                }
                                act= act->next;
                        }
                        sound->min_gain = 0.0;
                        sound->distance = 1.0;
  
-                       if (sound->attenuation > 0.0)
+                       if (sound->attenuation > 0.0f)
                                sound->flags |= SOUND_FLAGS_3D;
                        else
                                sound->flags &= ~SOUND_FLAGS_3D;
                        ob->formfactor = 0.4f;
                        /* patch form factor , note that inertia equiv radius
                         * of a rotation symmetrical obj */
-                       if (ob->inertia != 1.0) {
+                       if (ob->inertia != 1.0f) {
                                ob->formfactor /= ob->inertia * ob->inertia;
                        }
                        ob = ob->id.next;
                                SpaceLink *sl;
  
                                for (sl= sa->spacedata.first; sl; sl= sl->next) {
-                                       if(sl->blockscale==0.0) sl->blockscale= 0.7f;
+                                       if(sl->blockscale==0.0f) sl->blockscale= 0.7f;
                                        /* added: 5x better zoom in for action */
                                        if(sl->spacetype==SPACE_ACTION) {
                                                SpaceAction *sac= (SpaceAction *)sl;
  
                /* introduction of raytrace */
                while(ma) {
-                       if(ma->fresnel_tra_i==0.0) ma->fresnel_tra_i= 1.25;
-                       if(ma->fresnel_mir_i==0.0) ma->fresnel_mir_i= 1.25;
+                       if(ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f;
+                       if(ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f;
  
                        ma->ang= 1.0;
                        ma->ray_depth= 2;
                }
                sce= main->scene.first;
                while(sce) {
-                       if(sce->r.gauss==0.0) sce->r.gauss= 1.0;
+                       if(sce->r.gauss==0.0f) sce->r.gauss= 1.0f;
                        sce= sce->id.next;
                }
                la= main->lamp.first;
                while(la) {
-                       if(la->k==0.0) la->k= 1.0;
+                       if(la->k==0.0f) la->k= 1.0;
                        if(la->ray_samp==0) la->ray_samp= 1;
                        if(la->ray_sampy==0) la->ray_sampy= 1;
                        if(la->ray_sampz==0) la->ray_sampz= 1;
-                       if(la->area_size==0.0) la->area_size= 1.0;
-                       if(la->area_sizey==0.0) la->area_sizey= 1.0;
-                       if(la->area_sizez==0.0) la->area_sizez= 1.0;
+                       if(la->area_size==0.0f) la->area_size= 1.0f;
+                       if(la->area_sizey==0.0f) la->area_sizey= 1.0f;
+                       if(la->area_sizez==0.0f) la->area_sizez= 1.0f;
                        la= la->id.next;
                }
                wrld= main->world.first;
                while(wrld) {
-                       if(wrld->range==0.0) {
+                       if(wrld->range==0.0f) {
                                wrld->range= 1.0f/wrld->exposure;
                        }
                        wrld= wrld->id.next;
                                tex->flag |= TEX_CHECKER_ODD;
                        }
                        /* copied from kernel texture.c */
-                       if(tex->ns_outscale==0.0) {
+                       if(tex->ns_outscale==0.0f) {
                                /* musgrave */
                                tex->mg_H = 1.0f;
                                tex->mg_lacunarity = 2.0f;
                }
  
                while(wrld) {
-                       if(wrld->aodist==0.0) {
+                       if(wrld->aodist==0.0f) {
                                wrld->aodist= 10.0f;
                                wrld->aobias= 0.05f;
                        }
-                       if(wrld->aosamp==0.0) wrld->aosamp= 5;
-                       if(wrld->aoenergy==0.0) wrld->aoenergy= 1.0;
+                       if(wrld->aosamp==0) wrld->aosamp= 5;
+                       if(wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f;
                        wrld= wrld->id.next;
                }
  
                        for (sa= sc->areabase.first; sa; sa= sa->next) {
                                SpaceLink *sl;
                                for (sl= sa->spacedata.first; sl; sl= sl->next) {
-                                       if(sl->blockscale==0.0) sl->blockscale= 0.7f;
+                                       if(sl->blockscale==0.0f) sl->blockscale= 0.7f;
  
                                        /* added: 5x better zoom in for nla */
                                        if(sl->spacetype==SPACE_NLA) {
                Object *ob= main->object.first;
                
                while(ma) {
-                       if(ma->rampfac_col==0.0) ma->rampfac_col= 1.0;
-                       if(ma->rampfac_spec==0.0) ma->rampfac_spec= 1.0;
+                       if(ma->rampfac_col==0.0f) ma->rampfac_col= 1.0;
+                       if(ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0;
                        if(ma->pr_lamp==0) ma->pr_lamp= 3;
                        ma= ma->id.next;
                }
                Editing *ed;
                
                while(tex) {
-                       if(tex->nabla==0.0) tex->nabla= 0.025f;
+                       if(tex->nabla==0.0f) tex->nabla= 0.025f;
                        tex= tex->id.next;
                }
                while(sce) {
                bScreen *sc;
  
                while(cam) {
-                       if(cam->ortho_scale==0.0) {
+                       if(cam->ortho_scale==0.0f) {
                                cam->ortho_scale= 256.0f/cam->lens;
                                if(cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
                        }
                }
                // init new shader vars
                for (ma= main->mat.first; ma; ma= ma->id.next) {
-                       if(ma->darkness==0.0) {
+                       if(ma->darkness==0.0f) {
                                ma->rms=0.1f;
                                ma->darkness=1.0f;
                        }
                /* softbody init new vars */
                for(ob= main->object.first; ob; ob= ob->id.next) {
                        if(ob->soft) {
-                               if(ob->soft->defgoal==0.0) ob->soft->defgoal= 0.7f;
-                               if(ob->soft->physics_speed==0.0) ob->soft->physics_speed= 1.0f;
+                               if(ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f;
+                               if(ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f;
                                
                                if(ob->soft->interval==0) {
                                        ob->soft->interval= 2;
                }
  
                for (lt=main->latt.first; lt; lt=lt->id.next) {
-                       if (lt->fu==0.0 && lt->fv==0.0 && lt->fw==0.0) {
+                       if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) {
                                calc_lat_fudu(lt->flag, lt->pntsu, &lt->fu, &lt->du);
                                calc_lat_fudu(lt->flag, lt->pntsv, &lt->fv, &lt->dv);
                                calc_lat_fudu(lt->flag, lt->pntsw, &lt->fw, &lt->dw);
                                ntree_version_241(sce->nodetree);
  
                        /* uv calculation options moved to toolsettings */
-                       if (sce->toolsettings->uvcalc_radius == 0.0) {
+                       if (sce->toolsettings->uvcalc_radius == 0.0f) {
                                sce->toolsettings->uvcalc_radius = 1.0f;
                                sce->toolsettings->uvcalc_cubesize = 1.0f;
                                sce->toolsettings->uvcalc_mapdir = 1;
                                }
                        }
                        /* transmissivity defaults */
-                       if(ma->tx_falloff==0.0) ma->tx_falloff= 1.0;
+                       if(ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f;
                }
                
                /* during 2.41 images with this name were used for viewer node output, lets fix that */
                                ima->gen_x= 256; ima->gen_y= 256;
                                ima->gen_type= 1;
                                
-                               if(0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name+2))) {
+                               if(0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) {
                                        ima->source= IMA_SRC_VIEWER;
                                        ima->type= IMA_TYPE_COMPOSITE;
                                }
-                               if(0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name+2))) {
+                               if(0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) {
                                        ima->source= IMA_SRC_VIEWER;
                                        ima->type= IMA_TYPE_R_RESULT;
                                }
                                                ima->flag |= IMA_STD_FIELD;
                                }
                                tex->iuser.frames= tex->frames;
-                               tex->iuser.fie_ima= tex->fie_ima;
+                               tex->iuser.fie_ima= (char)tex->fie_ima;
                                tex->iuser.offset= tex->offset;
                                tex->iuser.sfra= tex->sfra;
                                tex->iuser.cycl= (tex->imaflag & TEX_ANIMCYCLIC_)!=0;
                                                        strcpy (simasel->dir,  U.textudir);     /* TON */
                                                        strcpy (simasel->file, "");
                                                        
-                                                       simasel->returnfunc     =  0;   
+                                                       simasel->returnfunc     =  NULL;
                                                        simasel->title[0]       =  0;
                                                }
                                        }
        if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) {
                Scene *sce;
                Object *ob;
-               PartEff *paf=0;
+               PartEff *paf=NULL;
  
                for(ob = main->object.first; ob; ob= ob->id.next) {
                        if(ob->soft && ob->soft->keys) {
                                
                                fluidmd->fss->lastgoodframe = INT_MAX;
                                fluidmd->fss->flag = 0;
-                               fluidmd->fss->meshSurfNormals = 0;
+                               fluidmd->fss->meshSurfNormals = NULL;
                        }
                }
        }
                Lamp *la;
  
                for(la=main->lamp.first; la; la= la->id.next) {
-                       if(la->atm_turbidity == 0.0) {
+                       if(la->atm_turbidity == 0.0f) {
                                la->sun_effect_type = 0;
                                la->horizon_brightness = 1.0f;
                                la->spread = 1.0f;
                                        if(seq->type == SEQ_HD_SOUND)
                                        {
                                                char str[FILE_MAX];
-                                               BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
-                                               BLI_path_abs(str, G.main->name);
+                                               BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
+                                               BLI_path_abs(str, main->name);
                                                seq->sound = sound_new_file(main, str);
                                        }
                                        /* don't know, if anybody used that
  
                for(sce = main->scene.first; sce; sce = sce->id.next) {
                        ts= sce->toolsettings;
-                       if(ts->normalsize == 0.0 || !ts->uv_selectmode || ts->vgroup_weight == 0.0) {
+                       if(ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
                                ts->normalsize= 0.1f;
                                ts->selectmode= SCE_SELECT_VERTEX;
                                
                        }
                }
        }
+       
 +      // init facing axis property of steering actuators
 +      {                                       
 +              Object *ob;
 +              for(ob = main->object.first; ob; ob = ob->id.next) {
 +                      bActuator *act;
 +                      for(act= ob->actuators.first; act; act= act->next) {
 +                              if(act->type==ACT_STEERING) {
 +                                      bSteeringActuator* stact = act->data;
 +                                      if (stact->facingaxis==0)
 +                                      {
 +                                              stact->facingaxis=1;
 +                                      }                                               
 +                              }
 +                      }
 +              }
 +      }
 +      
        if (main->versionfile < 256) {
                bScreen *sc;
                ScrArea *sa;
                        KeyBlock *kb;
                        
                        for (kb = key->block.first; kb; kb = kb->next) {
-                               if (IS_EQ(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0))
+                               if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0))
                                        kb->slidermax = kb->slidermin + 1.0f;
                        }
                }
                }
        }
  
-       /* put compatibility code here until next subversion bump */
-       
-       {
+       if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) {
+               bNodeTree *ntree;
+               
+               /* node sockets are not exposed automatically any more,
+                * this mimics the old behaviour by adding all unlinked sockets to groups.
+                */
+               for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) {
+                       /* XXX Only setting a flag here. Actual adding of group sockets
+                        * is done in lib_verify_nodetree, because at this point the internal
+                        * nodes may not be up-to-date! (missing lib-link)
+                        */
+                       ntree->flag |= NTREE_DO_VERSIONS;
+               }
+       }
+       if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)){
                bScreen *sc;
+               Brush *brush;
+               Object *ob;
+               ParticleSettings *part;
+               Material *mat;
+               int tex_nr, transp_tex;
                
+               for(mat = main->mat.first; mat; mat = mat->id.next){
+                       if(!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)){
+                               
+                               transp_tex= 0;
+                               
+                               for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++){
+                                       if(!mat->mtex[tex_nr]) continue;
+                                       if(mat->mtex[tex_nr]->mapto & MAP_ALPHA) transp_tex= 1;
+                               }
+                               
+                               if(mat->alpha < 1.0f || mat->fresnel_tra > 0.0f || transp_tex){
+                                       mat->mode |= MA_TRANSP;
+                                       mat->mode &= ~(MA_ZTRANSP|MA_RAYTRANSP);
+                               }
+                       }
+               }
                /* redraws flag in SpaceTime has been moved to Screen level */
                for (sc = main->screen.first; sc; sc= sc->id.next) {
                        if (sc->redraws_flag == 0) {
                                sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
                        }
                }
+               for (brush= main->brush.first; brush; brush= brush->id.next) {
+                       if(brush->height == 0)
+                               brush->height= 0.4f;
+               }
+               /* replace 'rim material' option for in offset*/
+               for(ob = main->object.first; ob; ob = ob->id.next) {
+                       ModifierData *md;
+                       for(md= ob->modifiers.first; md; md= md->next) {
+                               if (md->type == eModifierType_Solidify) {
+                                       SolidifyModifierData *smd = (SolidifyModifierData *)md;
+                                       if(smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
+                                               smd->mat_ofs_rim= 1;
+                                               smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
+                                       }
+                               }
+                       }
+               }
+               /* particle draw color from material */
+               for(part = main->particle.first; part; part = part->id.next) {
+                       if(part->draw & PART_DRAW_MAT_COL)
+                               part->draw_col = PART_DRAW_COL_MAT;
+               }
+       }
+       if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)){
+               Mesh *me;
+               for(me= main->mesh.first; me; me= me->id.next)
+                       mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
        }
  
+       if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)){
+               /* update blur area sizes from 0..1 range to 0..100 percentage */
+               Scene *scene;
+               bNode *node;
+               for (scene=main->scene.first; scene; scene=scene->id.next)
+                       if (scene->nodetree)
+                               for (node=scene->nodetree->nodes.first; node; node=node->next)
+                                       if (node->type==CMP_NODE_BLUR) {
+                                               NodeBlurData *nbd= node->storage;
+                                               nbd->percentx *= 100.0f;
+                                               nbd->percenty *= 100.0f;
+                                       }
+       }
+       /* put compatibility code here until next subversion bump */
+       {
+               /* screen view2d settings were not properly initialized [#27164]
+                * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
+                * need to make less ugly - possibly an iterator? */
+               bScreen *screen;
+               for(screen= main->screen.first; screen; screen= screen->id.next) {
+                       ScrArea *sa;
+                       /* add regions */
+                       for(sa= screen->areabase.first; sa; sa= sa->next) {
+                               SpaceLink *sl= sa->spacedata.first;
+                               if(sl->spacetype==SPACE_IMAGE) {
+                                       ARegion *ar;
+                                       for (ar=sa->regionbase.first; ar; ar= ar->next) {
+                                               if(ar->regiontype == RGN_TYPE_WINDOW) {
+                                                       View2D *v2d= &ar->v2d;
+                                                       v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
+                                               }
+                                       }
+                               }
+                               for (sl= sa->spacedata.first; sl; sl= sl->next) {
+                                       if(sl->spacetype==SPACE_IMAGE) {
+                                               ARegion *ar;
+                                               for (ar=sl->regionbase.first; ar; ar= ar->next) {
+                                                       if(ar->regiontype == RGN_TYPE_WINDOW) {
+                                                               View2D *v2d= &ar->v2d;
+                                                               v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               {
+                       /* Initialize texture point density curve falloff */
+                       Tex *tex;
+                       for(tex= main->tex.first; tex; tex= tex->id.next) {
+                               if(tex->pd) {
+                                       if (tex->pd->falloff_speed_scale == 0.0)
+                                               tex->pd->falloff_speed_scale = 100.0;
+                                       if (!tex->pd->falloff_curve) {
+                                               tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
+                                               tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
+                                               tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+                                               curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
+                                               curvemapping_changed(tex->pd->falloff_curve, 0);
+                                       }
+                               }
+                       }
+               }
+       }
+       
 +      //set defaults for obstacle avoidance, recast data
 +      {
 +              Scene *sce;
 +              for(sce = main->scene.first; sce; sce = sce->id.next)
 +              {
 +                      if (sce->gm.levelHeight == 0.f)
 +                              sce->gm.levelHeight = 2.f;
 +
 +                      if(sce->gm.recastData.cellsize == 0.0f)
 +                              sce->gm.recastData.cellsize = 0.3f;
 +                      if(sce->gm.recastData.cellheight == 0.0f)
 +                              sce->gm.recastData.cellheight = 0.2f;
 +                      if(sce->gm.recastData.agentmaxslope == 0.0f)
 +                              sce->gm.recastData.agentmaxslope = M_PI/4;
 +                      if(sce->gm.recastData.agentmaxclimb == 0.0f)
 +                              sce->gm.recastData.agentmaxclimb = 0.9f;
 +                      if(sce->gm.recastData.agentheight == 0.0f)
 +                              sce->gm.recastData.agentheight = 2.0f;
 +                      if(sce->gm.recastData.agentradius == 0.0f)
 +                              sce->gm.recastData.agentradius = 0.6f;
 +                      if(sce->gm.recastData.edgemaxlen == 0.0f)
 +                              sce->gm.recastData.edgemaxlen = 12.0f;
 +                      if(sce->gm.recastData.edgemaxerror == 0.0f)
 +                              sce->gm.recastData.edgemaxerror = 1.3f;
 +                      if(sce->gm.recastData.regionminsize == 0.0f)
 +                              sce->gm.recastData.regionminsize = 50.f;
 +                      if(sce->gm.recastData.regionmergesize == 0.0f)
 +                              sce->gm.recastData.regionmergesize = 20.f;
 +                      if(sce->gm.recastData.vertsperpoly<3)
 +                              sce->gm.recastData.vertsperpoly = 6;
 +                      if(sce->gm.recastData.detailsampledist == 0.0f)
 +                              sce->gm.recastData.detailsampledist = 6.0f;
 +                      if(sce->gm.recastData.detailsamplemaxerror == 0.0f)
 +                              sce->gm.recastData.detailsamplemaxerror = 1.0f;
 +              }                       
 +      }
++      
        /* 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! */
  
@@@ -11876,6 -12104,8 +12163,8 @@@ static void expand_animdata(FileData *f
  
  static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
  {
+       int a;
        expand_doit(fd, mainvar, part->dup_ob);
        expand_doit(fd, mainvar, part->dup_group);
        expand_doit(fd, mainvar, part->eff_group);
        
        if(part->adt)
                expand_animdata(fd, mainvar, part->adt);
+       for(a=0; a<MAX_MTEX; a++) {
+               if(part->mtex[a]) {
+                       expand_doit(fd, mainvar, part->mtex[a]->tex);
+                       expand_doit(fd, mainvar, part->mtex[a]->object);
+               }
+       }
  }
  
  static void expand_group(FileData *fd, Main *mainvar, Group *group)
@@@ -12136,50 -12373,19 +12432,19 @@@ static void expand_armature(FileData *f
        }
  }
  
- static void expand_modifier(FileData *fd, Main *mainvar, ModifierData *md)
+ static void expand_object_expandModifiers(void *userData, Object *UNUSED(ob),
+                                                                                         ID **idpoin)
  {
-       if (md->type==eModifierType_Lattice) {
-               LatticeModifierData *lmd = (LatticeModifierData*) md;
-                       
-               expand_doit(fd, mainvar, lmd->object);
-       } 
-       else if (md->type==eModifierType_Curve) {
-               CurveModifierData *cmd = (CurveModifierData*) md;
-                       
-               expand_doit(fd, mainvar, cmd->object);
-       }
-       else if (md->type==eModifierType_Array) {
-               ArrayModifierData *amd = (ArrayModifierData*) md;
-                       
-               expand_doit(fd, mainvar, amd->curve_ob);
-               expand_doit(fd, mainvar, amd->offset_ob);
-       }
-       else if (md->type==eModifierType_Mirror) {
-               MirrorModifierData *mmd = (MirrorModifierData*) md;
-                       
-               expand_doit(fd, mainvar, mmd->mirror_ob);
-       }
-       else if (md->type==eModifierType_Displace) {
-               DisplaceModifierData *dmd = (DisplaceModifierData*) md;
-               
-               expand_doit(fd, mainvar, dmd->map_object);
-               expand_doit(fd, mainvar, dmd->texture);
-       }
-       else if (md->type==eModifierType_Smoke) {
-               SmokeModifierData *smd = (SmokeModifierData*) md;
-                       
-               if(smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain)
-               {       
-                       expand_doit(fd, mainvar, smd->domain->coll_group);
-                       expand_doit(fd, mainvar, smd->domain->fluid_group);
-                       expand_doit(fd, mainvar, smd->domain->eff_group);
-               }
-       }
+       struct { FileData *fd; Main *mainvar; } *data= userData;
+       FileData *fd= data->fd;
+       Main *mainvar= data->mainvar;
+       expand_doit(fd, mainvar, *idpoin);
  }
  
  static void expand_object(FileData *fd, Main *mainvar, Object *ob)
  {
-       ModifierData *md;
        ParticleSystem *psys;
        bSensor *sens;
        bController *cont;
        int a;
  
        expand_doit(fd, mainvar, ob->data);
-       
-       for (md=ob->modifiers.first; md; md=md->next) {
-               expand_modifier(fd, mainvar, md);
+       /* expand_object_expandModifier() */
+       if(ob->modifiers.first) {
+               struct { FileData *fd; Main *mainvar; } data;
+               data.fd= fd;
+               data.mainvar= mainvar;
+               modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
        }
  
        expand_pose(fd, mainvar, ob->pose);
                        bArmatureActuator *arma= act->data;
                        expand_doit(fd, mainvar, arma->target);
                }
 +              else if(act->type==ACT_STEERING) {
 +                      bSteeringActuator *sta= act->data;
 +                      expand_doit(fd, mainvar, sta->target);
 +                      expand_doit(fd, mainvar, sta->navmesh);
 +              }
                act= act->next;
        }
  
@@@ -12404,7 -12610,7 +12674,7 @@@ static void expand_main(FileData *fd, M
        ID *id;
        int a, doit= 1;
  
-       if(fd==0) return;
+       if(fd==NULL) return;
  
        while(doit) {
                doit= 0;
@@@ -12572,7 -12778,9 +12842,9 @@@ static void give_base_to_groups(Main *m
        }
  }
  
- static void append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *name, int idcode, short flag)
+ /* returns true if the item was found
+  * but it may already have already been appended/linked */
+ static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *name, int idcode, short flag)
  {
        Scene *scene= CTX_data_scene(C);
        Object *ob;
        BHead *bhead;
        ID *id;
        int endloop=0;
+       int found=0;
  
        bhead = blo_firstbhead(fd);
        while(bhead && endloop==0) {
                        char *idname= bhead_id_name(fd, bhead);
                                
                        if(strcmp(idname+2, name)==0) {
+                               found= 1;
                                id= is_yet_read(fd, mainl, bhead);
                                if(id==NULL) {
                                        read_libblock(fd, mainl, bhead, LIB_TESTEXT, NULL);
  
                bhead = blo_nextbhead(fd, bhead);
        }
+       return found;
  }
  
void BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag)
int BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag)
  {
        FileData *fd= (FileData*)(*bh);
-       append_named_part(C, mainl, fd, name, idcode, flag);
+       return append_named_part(C, mainl, fd, name, idcode, flag);
  }
  
  static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
index bf52866d8c86b875528b7d6822b8e4491ad173a9,d110f71c00b5c77dd719d632218cdd89449fe0eb..c914293d1fcfe2172a30406d860bc8f3387b5d60
   * ***** END GPL LICENSE BLOCK *****
   */
  
+ /** \file blender/blenloader/intern/writefile.c
+  *  \ingroup blenloader
+  */
  /*
  FILEFORMAT: IFF-style structure  (but not IFF compatible!)
  
@@@ -214,8 -219,6 +219,6 @@@ static void writedata_free(WriteData *w
  
  /***/
  
- int mywfile;
  /**
   * Low level WRITE(2) wrapper that buffers data
   * @param adr Pointer to new chunk of data
@@@ -343,7 -346,7 +346,7 @@@ static void writedata(WriteData *wd, in
  {
        BHead bh;
  
-       if(adr==0) return;
+       if(adr==NULL) return;
        if(len==0) return;
  
        len+= 3;
@@@ -465,7 -468,7 +468,7 @@@ static void write_fmodifiers(WriteData 
                                        
                                        /* write envelope data */
                                        if (data->data)
-                                               writedata(wd, DATA, sizeof(FCM_EnvelopeData)*(data->totvert), data->data);
+                                               writestruct(wd, DATA, "FCM_EnvelopeData", data->totvert, data->data);
                                }
                                        break;
                                case FMODIFIER_TYPE_PYTHON:
@@@ -672,6 -675,12 +675,12 @@@ static void write_nodetree(WriteData *w
        
        for(link= ntree->links.first; link; link= link->next)
                writestruct(wd, DATA, "bNodeLink", 1, link);
+       
+       /* external sockets */
+       for(sock= ntree->inputs.first; sock; sock= sock->next)
+               writestruct(wd, DATA, "bNodeSocket", 1, sock);
+       for(sock= ntree->outputs.first; sock; sock= sock->next)
+               writestruct(wd, DATA, "bNodeSocket", 1, sock);
  }
  
  static void current_screen_compat(Main *mainvar, bScreen **screen)
@@@ -823,6 -832,7 +832,7 @@@ static void write_particlesettings(Writ
  {
        ParticleSettings *part;
        ParticleDupliWeight *dw;
+       int a;
  
        part= idbase->first;
        while(part) {
                        if(part->fluid && part->phystype == PART_PHYS_FLUID){
                                writestruct(wd, DATA, "SPHFluidSettings", 1, part->fluid); 
                        }
+                       for(a=0; a<MAX_MTEX; a++) {
+                               if(part->mtex[a]) writestruct(wd, DATA, "MTex", 1, part->mtex[a]);
+                       }
                }
                part= part->id.next;
        }
@@@ -1060,9 -1074,6 +1074,9 @@@ static void write_actuators(WriteData *
                case ACT_ARMATURE:
                        writestruct(wd, DATA, "bArmatureActuator", 1, act->data);
                        break;
 +              case ACT_STEERING:
 +                      writestruct(wd, DATA, "bSteeringActuator", 1, act->data);
 +                      break;
                default:
                        ; /* error: don't know how to write this file */
                }
@@@ -1214,7 -1225,7 +1228,7 @@@ static void write_modifiers(WriteData *
  
                                        /* create fake pointcache so that old blender versions can read it */
                                        smd->domain->point_cache[1] = BKE_ptcache_add(&smd->domain->ptcaches[1]);
-                                       smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE;
+                                       smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE|PTCACHE_FAKE_SMOKE;
                                        smd->domain->point_cache[1]->step = 1;
  
                                        write_pointcaches(wd, &(smd->domain->ptcaches[1]));
                        writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->dyninfluences);
                        writedata(wd, DATA, sizeof(int)*mmd->totvert, mmd->dynverts);
                }
+               else if (md->type==eModifierType_Warp) {
+                       WarpModifierData *tmd = (WarpModifierData*) md;
+                       if(tmd->curfalloff) {
+                               write_curvemapping(wd, tmd->curfalloff);
+                       }
+               }
        }
  }
  
@@@ -1294,7 -1311,7 +1314,7 @@@ static void write_objects(WriteData *wd
                        if (ob->type == OB_ARMATURE) {
                                bArmature *arm = ob->data;
                                if (arm && ob->pose && arm->act_bone) {
-                                       strcpy(ob->pose->proxy_act_bone, arm->act_bone->name);
+                                       BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
                                }
                        }
  
@@@ -1687,6 -1704,7 +1707,7 @@@ static void write_textures(WriteData *w
                        if(tex->type == TEX_POINTDENSITY && tex->pd) {
                                writestruct(wd, DATA, "PointDensity", 1, tex->pd);
                                if(tex->pd->coba) writestruct(wd, DATA, "ColorBand", 1, tex->pd->coba);
+                               if(tex->pd->falloff_curve) write_curvemapping(wd, tex->pd->falloff_curve);
                        }
                        if(tex->type == TEX_VOXELDATA && tex->vd) writestruct(wd, DATA, "VoxelData", 1, tex->vd);
                        
@@@ -2536,7 -2554,7 +2557,7 @@@ int BLO_write_file(Main *mainvar, char 
        }
  
        BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
-       write_user_block= BLI_streq(dir, userfilename);
+       write_user_block= (BLI_path_cmp(dir, userfilename) == 0);
  
        if(write_flags & G_FILE_RELATIVE_REMAP)
                makeFilesRelative(mainvar, dir, NULL); /* note, making relative to something OTHER then G.main->name */
@@@ -2600,197 -2618,3 +2621,3 @@@ int BLO_write_file_mem(Main *mainvar, M
        if(err==0) return 1;
        return 0;
  }
-       /* Runtime writing */
- #ifdef WIN32
- #define PATHSEPERATOR         "\\"
- #else
- #define PATHSEPERATOR         "/"
- #endif
- static char *get_runtime_path(char *exename) {
-       char *installpath= get_install_dir();
-       if (!installpath) {
-               return NULL;
-       } else {
-               char *path= MEM_mallocN(strlen(installpath)+strlen(PATHSEPERATOR)+strlen(exename)+1, "runtimepath");
-               if (path == NULL) {
-                       MEM_freeN(installpath);
-                       return NULL;
-               }
-               strcpy(path, installpath);
-               strcat(path, PATHSEPERATOR);
-               strcat(path, exename);
-               MEM_freeN(installpath);
-               return path;
-       }
- }
- #ifdef __APPLE__
- static int recursive_copy_runtime(char *outname, char *exename, ReportList *reports)
- {
-       char *runtime = get_runtime_path(exename);
-       char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
-       int progfd = -1, error= 0;
-       if (!runtime) {
-               BKE_report(reports, RPT_ERROR, "Unable to find runtime");
-               error= 1;
-               goto cleanup;
-       }
-       //printf("runtimepath %s\n", runtime);
-               
-       progfd= open(runtime, O_BINARY|O_RDONLY, 0);
-       if (progfd==-1) {
-               BKE_report(reports, RPT_ERROR, "Unable to find runtime");
-               error= 1;
-               goto cleanup;
-       }
-       sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
-       //printf("command %s\n", command);
-       if (system(command) == -1) {
-               BKE_report(reports, RPT_ERROR, "Couldn't copy runtime");
-               error= 1;
-       }
- cleanup:
-       if (progfd!=-1)
-               close(progfd);
-       if (runtime)
-               MEM_freeN(runtime);
-       return !error;
- }
- int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *reports) 
- {
-       char gamename[FILE_MAXDIR+FILE_MAXFILE];
-       int outfd = -1, error= 0;
-       // remove existing file / bundle
-       //printf("Delete file %s\n", file);
-       BLI_delete(file, 0, TRUE);
-       if (!recursive_copy_runtime(file, exename, reports)) {
-               error= 1;
-               goto cleanup;
-       }
-       strcpy(gamename, file);
-       strcat(gamename, "/Contents/Resources/game.blend");
-       //printf("gamename %s\n", gamename);
-       outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
-       if (outfd != -1) {
-               write_file_handle(mainvar, outfd, NULL,NULL, 0, G.fileflags, NULL);
-               if (write(outfd, " ", 1) != 1) {
-                       BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
-                       error= 1;
-                       goto cleanup;
-               }
-       } else {
-               BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
-               error= 1;
-       }
- cleanup:
-       if (outfd!=-1)
-               close(outfd);
-       BKE_reports_prepend(reports, "Unable to make runtime: ");
-       return !error;
- }
- #else /* !__APPLE__ */
- static int handle_append_runtime(int handle, char *exename, ReportList *reports)
- {
-       char *runtime= get_runtime_path(exename);
-       unsigned char buf[1024];
-       int count, progfd= -1, error= 0;
-       if (!BLI_exists(runtime)) {
-               BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
-               error= 1;
-               goto cleanup;
-       }
-       progfd= open(runtime, O_BINARY|O_RDONLY, 0);
-       if (progfd==-1) {
-               BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
-               error= 1;
-               goto cleanup;
-       }
-       while ((count= read(progfd, buf, sizeof(buf)))>0) {
-               if (write(handle, buf, count)!=count) {
-                       BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
-                       error= 1;
-                       goto cleanup;
-               }
-       }
- cleanup:
-       if (progfd!=-1)
-               close(progfd);
-       if (runtime)
-               MEM_freeN(runtime);
-       return !error;
- }
- static int handle_write_msb_int(int handle, int i) 
- {
-       unsigned char buf[4];
-       buf[0]= (i>>24)&0xFF;
-       buf[1]= (i>>16)&0xFF;
-       buf[2]= (i>>8)&0xFF;
-       buf[3]= (i>>0)&0xFF;
-       return (write(handle, buf, 4)==4);
- }
- int BLO_write_runtime(Main *mainvar, char *file, char *exename, ReportList *reports)
- {
-       int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
-       int datastart, error= 0;
-       if (!outfd) {
-               BKE_report(reports, RPT_ERROR, "Unable to open output file.");
-               error= 1;
-               goto cleanup;
-       }
-       if (!handle_append_runtime(outfd, exename, reports)) {
-               error= 1;
-               goto cleanup;
-       }
-       datastart= lseek(outfd, 0, SEEK_CUR);
-       write_file_handle(mainvar, outfd, NULL,NULL, 0, G.fileflags, NULL);
-       if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
-               BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
-               error= 1;
-               goto cleanup;
-       }
- cleanup:
-       if (outfd!=-1)
-               close(outfd);
-       BKE_reports_prepend(reports, "Unable to make runtime: ");
-       return !error;
- }
- #endif /* !__APPLE__ */
index 5efe5af08420479ebef64c365376288428db889b,47cb4d009381747150f7d348cecf58643097aba9..935ac410d116d080eb6625a02558ef7b5c25246e
@@@ -22,6 -22,7 +22,7 @@@
  set(INC
        ../include
        ../../blenkernel
+       ../../blenloader
        ../../blenlib
        ../../gpu
        ../../ikplugin
@@@ -32,7 -33,6 +33,7 @@@
        ../../windowmanager
        ../../render/extern/include
        ../../../../intern/guardedalloc
 +      ../../../../extern/recastnavigation/Recast/Include
  )
  
  set(SRC
@@@ -44,7 -44,6 +45,7 @@@
        object_hook.c
        object_lattice.c
        object_modifier.c
 +      object_navmesh.cpp
        object_ops.c
        object_relations.c
        object_select.c
index 0b4d82ee5d3e9b5ac5950629dc2bf93ac29fc0a2,660643fbb0fc2793b0f2ae783e4c462ebd798f79..5460e3fa7fb3f6463a21606355dc8da968ca3367
@@@ -1,13 -1,12 +1,13 @@@
  #!/usr/bin/python
  Import ('env')
  
 -sources = env.Glob('*.c')
 +sources = env.Glob('*.c') + env.Glob('*.cpp')
  
  incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
- incs += ' ../../windowmanager #/intern/guardedalloc'
+ incs += ' ../../windowmanager #/intern/guardedalloc ../../blenloader'
  incs += ' ../../makesrna ../../python ../../ikplugin'
  incs += ' ../../render/extern/include ../../gpu' # for object_bake.c
 +incs += ' #extern/recastnavigation/Recast/Include'
  
  defs = []
  
index d3adb51d53c434ba6a9e8ef15a0e07d61406c120,801880f0f3266116a4e5f763cca223b0a84bf43c..2ff1b2d399cadb49122840c8e03d2344d5972d90
@@@ -1,4 -1,4 +1,4 @@@
- /**
+ /*
   * $Id$
   *
   * ***** BEGIN GPL LICENSE BLOCK *****
   *
   * ***** END GPL LICENSE BLOCK *****
   */
+ /** \file blender/editors/object/object_intern.h
+  *  \ingroup edobj
+  */
  #ifndef ED_OBJECT_INTERN_H
  #define ED_OBJECT_INTERN_H
  
@@@ -50,9 -55,7 +55,7 @@@ void OBJECT_OT_rotation_clear(struct wm
  void OBJECT_OT_scale_clear(struct wmOperatorType *ot);
  void OBJECT_OT_origin_clear(struct wmOperatorType *ot);
  void OBJECT_OT_visual_transform_apply(struct wmOperatorType *ot);
- void OBJECT_OT_location_apply(struct wmOperatorType *ot);
- void OBJECT_OT_scale_apply(struct wmOperatorType *ot);
- void OBJECT_OT_rotation_apply(struct wmOperatorType *ot);
+ void OBJECT_OT_transform_apply(struct wmOperatorType *ot);
  void OBJECT_OT_origin_set(struct wmOperatorType *ot);
  
  /* object_relations.c */
@@@ -219,10 -222,5 +222,10 @@@ void OBJECT_OT_group_remove(struct wmOp
  /* object_bake.c */
  void OBJECT_OT_bake_image(wmOperatorType *ot);
  
 +/* object_navmesh.cpp */
 +void OBJECT_OT_create_navmesh(struct wmOperatorType *ot);
 +void OBJECT_OT_assign_navpolygon(struct wmOperatorType *ot);
 +void OBJECT_OT_assign_new_navpolygon(struct wmOperatorType *ot);
 +
  #endif /* ED_OBJECT_INTERN_H */
  
index 5c5f42b974f7729015ce2823a8a939ed0e2ae140,ff9b13379a2197a3a0d23618946112d96bee38df..b7989ba5dd833a77afe7c0be38b538d3dc0ee6bb
@@@ -1,4 -1,4 +1,4 @@@
- /**
+ /*
   * $Id$
   *
   * ***** BEGIN GPL LICENSE BLOCK *****
   * ***** END GPL LICENSE BLOCK *****
   */
  
+ /** \file blender/editors/object/object_ops.c
+  *  \ingroup edobj
+  */
  #include <stdlib.h>
  #include <math.h>
  
@@@ -60,9 -65,7 +65,7 @@@ void ED_operatortypes_object(void
        WM_operatortype_append(OBJECT_OT_scale_clear);
        WM_operatortype_append(OBJECT_OT_origin_clear);
        WM_operatortype_append(OBJECT_OT_visual_transform_apply);
-       WM_operatortype_append(OBJECT_OT_location_apply);
-       WM_operatortype_append(OBJECT_OT_scale_apply);
-       WM_operatortype_append(OBJECT_OT_rotation_apply);
+       WM_operatortype_append(OBJECT_OT_transform_apply);
        WM_operatortype_append(OBJECT_OT_origin_set);
        
        WM_operatortype_append(OBJECT_OT_mode_set);
  
        WM_operatortype_append(OBJECT_OT_bake_image);
        WM_operatortype_append(OBJECT_OT_drop_named_material);
 +
 +      WM_operatortype_append(OBJECT_OT_create_navmesh);
 +      WM_operatortype_append(OBJECT_OT_assign_navpolygon);
 +      WM_operatortype_append(OBJECT_OT_assign_new_navpolygon);
  }
  
  void ED_operatormacros_object(void)
        wmOperatorType *ot;
        wmOperatorTypeMacro *otmacro;
        
-       ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
+       ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER);
        if(ot) {
                WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
                otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
index 01c5f962c63bca3e98d7f8f89aaa4df424f40215,bce492f5a040ae4e1ade57cc7330407599d40960..e09f9cff031361d7975332f7ebaeef691dc6bea3
@@@ -1,4 -1,4 +1,4 @@@
- /**
+ /*
   * $Id$
   *
   * ***** BEGIN GPL LICENSE BLOCK *****
   * ***** END GPL LICENSE BLOCK *****
   */
  
+ /** \file blender/editors/space_logic/logic_window.c
+  *  \ingroup splogic
+  */
  #include <string.h>
  #include <stdio.h>
  #include <stddef.h>
@@@ -356,7 -361,7 +361,7 @@@ static void old_sca_move_actuator(bCont
        }
  }
  
- void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
  {
        Main *bmain= CTX_data_main(C);
        bSensor *sens;
@@@ -713,8 -718,6 +718,8 @@@ static const char *actuator_name(int ty
                return "State";
        case ACT_ARMATURE:
                return "Armature";
-               return "Steering";
 +      case ACT_STEERING:
++              return "Steering";              
        }
        return "unknown";
  }
@@@ -1788,13 -1791,13 +1793,13 @@@ static void change_ipo_actuator(bContex
        but->retval = B_REDR;
  }
  
- void update_object_actuator_PID(bContext *UNUSED(C), void *act, void *UNUSED(arg))
static void update_object_actuator_PID(bContext *UNUSED(C), void *act, void *UNUSED(arg))
  {
        bObjectActuator *oa = act;
        oa->forcerot[0] = 60.0f*oa->forcerot[1];
  }
  
- char *get_state_name(Object *ob, short bit)
static char *get_state_name(Object *ob, short bit)
  {
        bController *cont;
        unsigned int mask;
@@@ -2197,28 -2200,28 +2202,28 @@@ static short draw_actuatorbuttons(Main 
                }
        case ACT_CAMERA:
  
-                ysize= 48;
-         
-                glRects(xco, yco-ysize, xco+width, yco);
-                uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+               ysize= 48;
+               glRects(xco, yco-ysize, xco+width, yco);
+               uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
                
-                ca= act->data;
-         
-                uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",                xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object");
-                uiDefButF(block, NUM, 0, "Height:",    xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, "");
+               ca= act->data;
+               uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",         xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object");
+               uiDefButF(block, NUM, 0, "Height:",     xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, "");
                
-                uiDefButF(block, NUM, 0, "Min:",       xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, "");
+               uiDefButF(block, NUM, 0, "Min:",        xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, "");
                
-                if(ca->axis==0) ca->axis= 'x';
-                uiDefButS(block, ROW, 0, "X",  xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis");
-                uiDefButS(block, ROW, 0, "Y",  xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis");
+               if(ca->axis==0) ca->axis= 'x';
+               uiDefButS(block, ROW, 0, "X",   xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis");
+               uiDefButS(block, ROW, 0, "Y",   xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis");
                
-                uiDefButF(block, NUM, 0, "Max:",       xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, "");
+               uiDefButF(block, NUM, 0, "Max:",        xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, "");
+               yco-= ysize;
+               break;
  
-                yco-= ysize;
-         
-                break;
-                               
        case ACT_EDIT_OBJECT:
                
                eoa= act->data;
                        ysize = 92;
                        glRects(xco, yco-ysize, xco+width, yco);
                        uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
-        
                        uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",         xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)");
                        uiDefButI(block, NUM, 0, "Time:",       xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives");
  
                uiDefButS(block, MENU, B_REDR, str,             xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, "");
  
                 yco-= ysize;
-         
                break;
-  
-        case ACT_CONSTRAINT:
+       case ACT_CONSTRAINT:
                coa= act->data;
        
                if (coa->type == ACT_CONST_TYPE_LOC) {
                        ysize= 69;
-         
                        glRects(xco, yco-ysize, xco+width, yco);
                        uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
                        
                break;
   
        case ACT_SCENE:
-                 sca= act->data; 
+               sca= act->data;
                
-                 if(sca->type==ACT_SCENE_RESTART) { 
-                         ysize= 28; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-                 } 
-                 else if(sca->type==ACT_SCENE_CAMERA) { 
-                       
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-        
-                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",               xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object"); 
-                 } 
-                 else if(sca->type==ACT_SCENE_SET) { 
+               if(sca->type==ACT_SCENE_RESTART) {
+                       ysize= 28;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+               }
+               else if(sca->type==ACT_SCENE_CAMERA) {
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",         xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object");
+               }
+               else if(sca->type==ACT_SCENE_SET) {
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-       
-                         uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",          xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); 
-                 } 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",            xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene");
+               }
                else if(sca->type==ACT_SCENE_ADD_FRONT) { 
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-       
-                         uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",          xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); 
-                 } 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",            xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene");
+               }
                else if(sca->type==ACT_SCENE_ADD_BACK) { 
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-       
-                         uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",          xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); 
-                 } 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",            xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene");
+               }
                else if(sca->type==ACT_SCENE_REMOVE) { 
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-       
-                         uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",          xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene");
-                 } 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",            xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene");
+               }
                else if(sca->type==ACT_SCENE_SUSPEND) { 
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-       
-                         uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",          xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene");
-                 } 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",            xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene");
+               }
                else if(sca->type==ACT_SCENE_RESUME) { 
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-       
-                         uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",          xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene");
-                 } 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:",            xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene");
+               }
  
                str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7";
                uiDefButS(block, MENU, B_REDR, str,             xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, ""); 
                yco -= ysize;
                break;
        case ACT_PARENT:
-                 parAct = act->data; 
+               parAct = act->data;
  
-                 if(parAct->type==ACT_PARENT_SET) { 
+               if(parAct->type==ACT_PARENT_SET) {
                        
-                         ysize= 48; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-                         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",               xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent"); 
+                       ysize= 48;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+                       uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:",         xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent");
                        uiBlockBeginAlign(block);
                        uiDefButBitS(block, TOGN, ACT_PARENT_COMPOUND, B_REDR,
-                                 "Compound",
-                                 xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag,
-                                 0.0, 0.0, 0, 0,
-                                 "Add this object shape to the parent shape (only if the parent shape is already compound)");
+                       "Compound",
+                       xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag,
+                       0.0, 0.0, 0, 0,
+                       "Add this object shape to the parent shape (only if the parent shape is already compound)");
                        uiDefButBitS(block, TOGN, ACT_PARENT_GHOST, B_REDR,
-                                 "Ghost",
-                                 xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag,
-                                 0.0, 0.0, 0, 0,
-                                 "Make this object ghost while parented (only if not compound)");
+                       "Ghost",
+                       xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag,
+                       0.0, 0.0, 0, 0,
+                       "Make this object ghost while parented (only if not compound)");
                        uiBlockEndAlign(block);
-                 }
-                 else if(parAct->type==ACT_PARENT_REMOVE) { 
-                       
-                         ysize= 28; 
-                         glRects(xco, yco-ysize, xco+width, yco); 
-                         uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-                }
+               }
+               else if(parAct->type==ACT_PARENT_REMOVE) {
+                       ysize= 28;
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
+               }
  
                str= "Parent %t|Set Parent %x0|Remove Parent %x1";
                uiDefButI(block, MENU, B_REDR, str,             xco+5, yco-24, parAct->type==1?(width-80):90, 19, &parAct->type, 0.0, 0.0, 0, 0, ""); 
  
-                 yco-= ysize; 
-                 break; 
+               yco-= ysize;
+               break;
        case ACT_ARMATURE:
-                 armAct = act->data; 
+               armAct = act->data;
  
                if (ob->type == OB_ARMATURE) {
                        str= "Constraint %t|Run armature %x0|Enable %x1|Disable %x2|Set target %x3|Set weight %x4";
                  }
                glRects(xco, yco-ysize, xco+width, yco); 
                uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); 
-                 yco-= ysize; 
-                 break; 
+               yco-= ysize;
+               break;
  
         default:
                ysize= 4;
@@@ -3180,9 -3183,9 +3185,9 @@@ static uiBlock *object_state_mask_menu(
  static int is_sensor_linked(uiBlock *block, bSensor *sens)
  {
        bController *cont;
-       int i, count;
+       int i;
  
-       for (count=0, i=0; i<sens->totlinks; i++) {
+       for (i=0; i<sens->totlinks; i++) {
                cont = sens->links[i];
                if (uiFindInlink(block, cont) != NULL)
                        return 1;
@@@ -3200,19 -3203,19 +3205,19 @@@ static void draw_sensor_header(uiLayou
        box= uiLayoutBox(layout);
        row= uiLayoutRow(box, 0);
        
-       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NULL);
+       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
        if(RNA_boolean_get(ptr, "show_expanded")) {
-               uiItemR(row, ptr, "type", 0, "", ICON_NULL);
-               uiItemR(row, ptr, "name", 0, "", ICON_NULL);
+               uiItemR(row, ptr, "type", 0, "", ICON_NONE);
+               uiItemR(row, ptr, "name", 0, "", ICON_NONE);
        } else {
-               uiItemL(row, sensor_name(sens->type), ICON_NULL);
-               uiItemL(row, sens->name, ICON_NULL);
+               uiItemL(row, sensor_name(sens->type), ICON_NONE);
+               uiItemL(row, sens->name, ICON_NONE);
        }
  
        subrow= uiLayoutRow(row, 0);
        uiLayoutSetActive(subrow, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states")
                                                        && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")));
-       uiItemR(subrow, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NULL);
+       uiItemR(subrow, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
  
        if(RNA_boolean_get(ptr, "show_expanded")==0) {
                subrow= uiLayoutRow(row, 1);
  
  static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
  {
-       uiLayout *box, *split, *row;
+       uiLayout *box, *split, *subrow, *row;
  
        box= uiLayoutBox(layout);
        split = uiLayoutSplit(box, 0.45, 0);
        row= uiLayoutRow(split, 1);
        uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP);
        uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN);
-       uiItemR(row, ptr, "frequency", 0, "Freq", ICON_NULL);
+       subrow=uiLayoutRow(row, 0);
+       uiLayoutSetActive(subrow, (RNA_boolean_get(ptr, "use_pulse_true_level")
+                                                       || RNA_boolean_get(ptr, "use_pulse_false_level")));
+       uiItemR(subrow, ptr, "frequency", 0, "Freq", ICON_NONE);
        
        row= uiLayoutRow(split, 1);
-       uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
-       uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+       uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
+       uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
        
        row= uiLayoutRow(split, 1);
-       uiItemR(row, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", ICON_NULL);
+       uiItemR(row, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", ICON_NONE);
  }
  /* sensors in alphabetical order */
  
@@@ -3263,7 -3270,7 +3272,7 @@@ static void draw_sensor_armature(uiLayo
        uiLayout *row;
  
        if(ob->type != OB_ARMATURE){
-               uiItemL(layout, "Sensor only available for armatures", ICON_NULL);
+               uiItemL(layout, "Sensor only available for armatures", ICON_NONE);
                return;
        }
  
                        uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
        }
        row = uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "test_type", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "test_type", 0, NULL, ICON_NONE);
        if (RNA_enum_get(ptr, "test_type") != SENS_ARM_STATE_CHANGED)
-               uiItemR(row, ptr, "value", 0, NULL, ICON_NULL);
+               uiItemR(row, ptr, "value", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C)
  
        split = uiLayoutSplit(layout, 0.3, 0);
        row = uiLayoutRow(split, 1);
-       uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
-       uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+       uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
+       uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
  
-       switch (RNA_enum_get(ptr, "use_material")) {
+       switch (RNA_boolean_get(ptr, "use_material")) {
                case SENS_COLLISION_PROPERTY:
-                       uiItemR(split, ptr, "property", 0, NULL, ICON_NULL);
+                       uiItemR(split, ptr, "property", 0, NULL, ICON_NONE);
                        break;
                case SENS_COLLISION_MATERIAL:
                        uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA);
@@@ -3312,48 -3319,48 +3321,48 @@@ static void draw_sensor_delay(uiLayout 
        
        row= uiLayoutRow(layout, 0);
  
-       uiItemR(row, ptr, "delay", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "duration", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "use_repeat", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "delay", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "duration", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "use_repeat", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr)
  {
        uiLayout *col, *row;
  
-       uiItemR(layout, ptr, "joystick_index", 0, NULL, ICON_NULL);
-       uiItemR(layout, ptr, "event_type", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "joystick_index", 0, NULL, ICON_NONE);
+       uiItemR(layout, ptr, "event_type", 0, NULL, ICON_NONE);
  
        switch (RNA_enum_get(ptr, "event_type")) {
                case SENS_JOY_BUTTON:
-                       uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE);
  
                        col = uiLayoutColumn(layout, 0);
                        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events")==0);
-                       uiItemR(col, ptr, "button_number", 0, NULL, ICON_NULL);
+                       uiItemR(col, ptr, "button_number", 0, NULL, ICON_NONE);
                        break;
                case SENS_JOY_AXIS:
                        row = uiLayoutRow(layout, 0);
-                       uiItemR(row, ptr, "axis_number", 0, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "axis_number", 0, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE);
  
-                       uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE);
                        col = uiLayoutColumn(layout, 0);
                        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events")==0);
-                       uiItemR(col, ptr, "axis_direction", 0, NULL, ICON_NULL);
+                       uiItemR(col, ptr, "axis_direction", 0, NULL, ICON_NONE);
                        break;
                case SENS_JOY_HAT:
-                       uiItemR(layout, ptr, "hat_number", 0, NULL, ICON_NULL);
-                       uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "hat_number", 0, NULL, ICON_NONE);
+                       uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE);
  
                        col = uiLayoutColumn(layout, 0);
                        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events")==0);
-                       uiItemR(col, ptr, "hat_direction", 0, NULL, ICON_NULL);
+                       uiItemR(col, ptr, "hat_direction", 0, NULL, ICON_NONE);
                        break;
                case SENS_JOY_AXIS_SINGLE:
                        row = uiLayoutRow(layout, 0);
-                       uiItemR(row, ptr, "single_axis_number", 0, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "single_axis_number", 0, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE);
                        break;
        }
  }
@@@ -3365,47 -3372,47 +3374,47 @@@ static void draw_sensor_keyboard(uiLayo
        uiLayout *row, *col;
  
        row = uiLayoutRow(layout, 0);
-       uiItemL(row, "Key:", ICON_NULL);
+       uiItemL(row, "Key:", ICON_NONE);
        col = uiLayoutColumn(row, 0);
        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys")==0);
-       uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NULL);
+       uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE);
        col = uiLayoutColumn(row, 0);
-       uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+       uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
        
        col = uiLayoutColumn(layout, 0);
        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys")==0);
        row = uiLayoutRow(col, 0);
-       uiItemL(row, "First Modifier:", ICON_NULL);
-       uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NULL);
+       uiItemL(row, "First Modifier:", ICON_NONE);
+       uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE);
        
        row = uiLayoutRow(col, 0);
-       uiItemL(row, "Second Modifier:", ICON_NULL);
-       uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NULL);
+       uiItemL(row, "Second Modifier:", ICON_NONE);
+       uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE);
  
        RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-       uiItemPointerR(layout, ptr, "log", &settings_ptr, "properties", NULL, ICON_NULL);
-       uiItemPointerR(layout, ptr, "target", &settings_ptr, "properties", NULL, ICON_NULL);
+       uiItemPointerR(layout, ptr, "log", &settings_ptr, "properties", NULL, ICON_NONE);
+       uiItemPointerR(layout, ptr, "target", &settings_ptr, "properties", NULL, ICON_NONE);
  }
  
  static void draw_sensor_message(uiLayout *layout, PointerRNA *ptr)
  {
-       uiItemR(layout, ptr, "subject", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "subject", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_mouse(uiLayout *layout, PointerRNA *ptr)
  {
-       uiItemR(layout, ptr, "mouse_event", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "mouse_event", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr)
  {
        uiLayout *row;
  
-       uiItemR(layout, ptr, "property", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE);
  
        row= uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "distance", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "reset_distance", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "reset_distance", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr)
        PointerRNA settings_ptr;
  
        uiLayout *row;
-       uiItemR(layout, ptr, "evaluation_type", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "evaluation_type", 0, NULL, ICON_NONE);
  
        RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
-       uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, ICON_NULL);
+       uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
  
        switch (RNA_enum_get(ptr, "evaluation_type")) {
                case SENS_PROP_INTERVAL:
                        row = uiLayoutRow(layout, 0);
-                       uiItemR(row, ptr, "value_min", 0, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "value_max", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "value_min", 0, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "value_max", 0, NULL, ICON_NONE);
                        break;
                case SENS_PROP_EQUAL:
-                       uiItemR(layout, ptr, "value", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
                        break;
                case SENS_PROP_NEQUAL:
-                       uiItemR(layout, ptr, "value", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
                        break;
                case SENS_PROP_CHANGED:
                        break;
@@@ -3440,17 -3447,17 +3449,17 @@@ static void draw_sensor_radar(uiLayout 
  {
        uiLayout *row;
  
-       uiItemR(layout, ptr, "property", 0, NULL, ICON_NULL);
-       uiItemR(layout, ptr, "axis", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE);
+       uiItemR(layout, ptr, "axis", 0, NULL, ICON_NONE);
  
        row= uiLayoutRow(layout, 0);
-       uiItemR(row, ptr, "angle", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "distance", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "angle", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_random(uiLayout *layout, PointerRNA *ptr)
  {
-       uiItemR(layout, ptr, "seed", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "seed", 0, NULL, ICON_NONE);
  }
  
  static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C)
  
        RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
        split= uiLayoutSplit(layout, 0.3, 0);
-       uiItemR(split, ptr, "ray_type", 0, "", ICON_NULL);
+       uiItemR(split, ptr, "ray_type", 0, "", ICON_NONE);
        switch (RNA_enum_get(ptr, "ray_type")) {
                case SENS_RAY_PROPERTY:
-                       uiItemR(split, ptr, "property", 0, "", ICON_NULL);
+                       uiItemR(split, ptr, "property", 0, "", ICON_NONE);
                        break;
                case SENS_RAY_MATERIAL:
                        uiItemPointerR(split, ptr, "material", &main_ptr, "materials", "", ICON_MATERIAL_DATA);
        }
  
        split= uiLayoutSplit(layout, 0.3, 0);
-       uiItemR(split, ptr, "axis", 0, "", ICON_NULL);
+       uiItemR(split, ptr, "axis", 0, "", ICON_NONE);
        row= uiLayoutRow(split, 0);     
-       uiItemR(row, ptr, "range", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+       uiItemR(row, ptr, "range", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
  }
  
  static void draw_sensor_touch(uiLayout *layout, PointerRNA *ptr)
  {
-       uiItemR(layout, ptr, "material", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "material", 0, NULL, ICON_NONE);
  }
  
- void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C)
static void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C)
  {
        uiLayout *box;
        
@@@ -3554,19 -3561,19 +3563,19 @@@ static void draw_controller_header(uiLa
        box= uiLayoutBox(layout);
        row= uiLayoutRow(box, 0);
        
-       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NULL);
+       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
        if(RNA_boolean_get(ptr, "show_expanded")) {
-               uiItemR(row, ptr, "type", 0, "", ICON_NULL);
-               uiItemR(row, ptr, "name", 0, "", ICON_NULL);
+               uiItemR(row, ptr, "type", 0, "", ICON_NONE);
+               uiItemR(row, ptr, "name", 0, "", ICON_NONE);
                /* XXX provisory for Blender 2.50Beta */
                uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, "Set controller state index (from 1 to 30)");
        } else {
-               uiItemL(row, controller_name(cont->type), ICON_NULL);
-               uiItemL(row, cont->name, ICON_NULL);
-               uiItemL(row, state, ICON_NULL);
+               uiItemL(row, controller_name(cont->type), ICON_NONE);
+               uiItemL(row, cont->name, ICON_NONE);
+               uiItemL(row, state, ICON_NONE);
        }
  
-       uiItemR(row, ptr, "use_priority", 0, "", ICON_NULL);
+       uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE);
  
        if(RNA_boolean_get(ptr, "show_expanded")==0) {
                subrow= uiLayoutRow(row, 1);
  
  static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr)
  {
-       uiItemR(layout, ptr, "expression", 0, "", ICON_NULL);
+       uiItemR(layout, ptr, "expression", 0, "", ICON_NONE);
  }
  
  static void draw_controller_python(uiLayout *layout, PointerRNA *ptr)
        uiLayout *split, *subsplit;
  
        split = uiLayoutSplit(layout, 0.3, 1);
-       uiItemR(split, ptr, "mode", 0, "", ICON_NULL);
+       uiItemR(split, ptr, "mode", 0, "", ICON_NONE);
        if (RNA_enum_get(ptr, "mode") == CONT_PY_SCRIPT) {
-               uiItemR(split, ptr, "text", 0, "", ICON_NULL);
+               uiItemR(split, ptr, "text", 0, "", ICON_NONE);
        }
        else {
                subsplit = uiLayoutSplit(split, 0.8, 0);
-               uiItemR(subsplit, ptr, "module", 0, "", ICON_NULL);
-               uiItemR(subsplit, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+               uiItemR(subsplit, ptr, "module", 0, "", ICON_NONE);
+               uiItemR(subsplit, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
        }
  }
  
@@@ -3602,7 -3609,7 +3611,7 @@@ static void draw_controller_state(uiLay
  
  }
  
- void draw_brick_controller(uiLayout *layout, PointerRNA *ptr)
static void draw_brick_controller(uiLayout *layout, PointerRNA *ptr)
  {
        uiLayout *box;
        
@@@ -3644,19 -3651,19 +3653,19 @@@ static void draw_actuator_header(uiLayo
        box= uiLayoutBox(layout);
        row= uiLayoutRow(box, 0);
        
-       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NULL);
+       uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE);
        if(RNA_boolean_get(ptr, "show_expanded")) {
-               uiItemR(row, ptr, "type", 0, "", ICON_NULL);
-               uiItemR(row, ptr, "name", 0, "", ICON_NULL);
+               uiItemR(row, ptr, "type", 0, "", ICON_NONE);
+               uiItemR(row, ptr, "name", 0, "", ICON_NONE);
        } else {
-               uiItemL(row, actuator_name(act->type), ICON_NULL);
-               uiItemL(row, act->name, ICON_NULL);
+               uiItemL(row, actuator_name(act->type), ICON_NONE);
+               uiItemL(row, act->name, ICON_NONE);
        }
  
        subrow= uiLayoutRow(row, 0);
        uiLayoutSetActive(subrow, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states")
                                                        && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin")));
-       uiItemR(subrow, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NULL);
+       uiItemR(subrow, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE);
  
        if(RNA_boolean_get(ptr, "show_expanded")==0) {
                subrow= uiLayoutRow(row, 1);
@@@ -3673,34 -3680,34 +3682,34 @@@ static void draw_actuator_action(uiLayo
        uiLayout *row;
  
        if(ob->type != OB_ARMATURE){
-               uiItemL(layout, "Actuator only available for armatures", ICON_NULL);
+               uiItemL(layout, "Actuator only available for armatures", ICON_NONE);
                return;
        }
        RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr);
  
        row= uiLayoutRow(layout, 0);
-       uiItemR(row, ptr, "play_mode", 0, "", ICON_NULL);
-       uiItemR(row, ptr, "action", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE);
+       uiItemR(row, ptr, "action", 0, "", ICON_NONE);
+       uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE);
  
        row= uiLayoutRow(layout, 0);
        if((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP))
-               uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NULL);
+               uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
  
        else {
-               uiItemR(row, ptr, "frame_start", 0, NULL, ICON_NULL);
-               uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NULL);
+               uiItemR(row, ptr, "frame_start", 0, NULL, ICON_NONE);
+               uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE);
        }
  
        row= uiLayoutRow(layout, 0);
-       uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "priority", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE);
  
        row= uiLayoutRow(layout, 0);
-       uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NULL);
+       uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);
  
  #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
-       uiItemR(row, "stride_length", 0, NULL, ICON_NULL);
+       uiItemR(row, "stride_length", 0, NULL, ICON_NONE);
  #endif
  }
  
@@@ -3714,7 -3721,7 +3723,7 @@@ static void draw_actuator_armature(uiLa
        PropertyRNA *bones_prop = NULL;
  
        if(ob->type != OB_ARMATURE){
-               uiItemL(layout, "Actuator only available for armatures", ICON_NULL);
+               uiItemL(layout, "Actuator only available for armatures", ICON_NONE);
                return;
        }
        
                bones_prop = RNA_struct_find_property(&pose_ptr, "bones");
        }
        
-       uiItemR(layout, ptr, "mode", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
        
        switch (RNA_enum_get(ptr, "mode"))
        {
                                        uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
                        }
  
-                       uiItemR(layout, ptr, "target", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE);
  
                        /* show second target only if the constraint supports it */
                        get_armature_bone_constraint(ob, aa->posechannel, aa->constraint, &constraint);
                        if (constraint && constraint->type == CONSTRAINT_TYPE_KINEMATIC) {
-                               uiItemR(layout, ptr, "secondary_target", 0, NULL, ICON_NULL);
+                               uiItemR(layout, ptr, "secondary_target", 0, NULL, ICON_NONE);
                        }
                        break;
                case ACT_ARM_SETWEIGHT:
                                        uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE);
                        }
  
-                       uiItemR(layout, ptr, "weight", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "weight", 0, NULL, ICON_NONE);
                        break;
        }
  }
  static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr)
  {
        uiLayout *row;
-       uiItemR(layout, ptr, "object", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
  
        row = uiLayoutRow(layout, 0);
-       uiItemR(row, ptr, "height", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "axis", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "height", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "axis", 0, NULL, ICON_NONE);
  
        row = uiLayoutRow(layout, 1);
-       uiItemR(row, ptr, "min", 0, NULL, ICON_NULL);
-       uiItemR(row, ptr, "max", 0, NULL, ICON_NULL);
+       uiItemR(row, ptr, "min", 0, NULL, ICON_NONE);
+       uiItemR(row, ptr, "max", 0, NULL, ICON_NONE);
  }
  
  static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext *C)
  
        RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
  
-       uiItemR(layout, ptr, "mode", 0, NULL, ICON_NULL);
+       uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
        switch (RNA_enum_get(ptr, "mode"))
        {
                case ACT_CONST_TYPE_LOC:
-                       uiItemR(layout, ptr, "limit", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "limit", 0, NULL, ICON_NONE);
  
                        row = uiLayoutRow(layout, 1);
-                       uiItemR(row, ptr, "limit_min", 0, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "limit_max", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "limit_min", 0, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "limit_max", 0, NULL, ICON_NONE);
  
-                       uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
                        break;
  
                case ACT_CONST_TYPE_DIST:
                        split = uiLayoutSplit(layout, 0.8, 0);
-                       uiItemR(split, ptr, "direction", 0, NULL, ICON_NULL);
+                       uiItemR(split, ptr, "direction", 0, NULL, ICON_NONE);
                        row = uiLayoutRow(split, 1);
-                       uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
  
                        row = uiLayoutRow(layout, 0);
                        col = uiLayoutColumn(row, 0);
-                       uiItemL(col, "Range:", ICON_NULL);
-                       uiItemR(col, ptr, "range", 0, "", ICON_NULL);
+                       uiItemL(col, "Range:", ICON_NONE);
+                       uiItemR(col, ptr, "range", 0, "", ICON_NONE);
  
                        col = uiLayoutColumn(row, 1);
-                       uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+                       uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
                        subcol = uiLayoutColumn(col, 0);
                        uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_force_distance")==1);
-                       uiItemR(subcol, ptr, "distance", 0, "", ICON_NULL);
+                       uiItemR(subcol, ptr, "distance", 0, "", ICON_NONE);
  
-                       uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, ICON_NONE);
  
                        split = uiLayoutSplit(layout, 0.15, 0);
-                       uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+                       uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
                        if (RNA_boolean_get(ptr, "use_material_detect"))
                                uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA);
                        else
-                               uiItemR(split, ptr, "property", 0, NULL, ICON_NULL);
+                               uiItemR(split, ptr, "property", 0, NULL, ICON_NONE);
  
                        split = uiLayoutSplit(layout, 0.15, 0);
-                       uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+                       uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
  
                        row = uiLayoutRow(split, 1);
-                       uiItemR(row, ptr, "time", 0, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "time", 0, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
                        break;
  
                case ACT_CONST_TYPE_ORI:
-                       uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NULL);
+                       uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NONE);
  
                        row=uiLayoutRow(layout, 1);
-                       uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER , NULL, ICON_NULL);
-                       uiItemR(row, ptr, "time", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER , NULL, ICON_NONE);
+                       uiItemR(row, ptr, "time", 0, NULL, ICON_NONE);
  
                        row=uiLayoutRow(layout, 0);
-                       uiItemR(row, ptr, "rotation_max", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "rotation_max", 0, NULL, ICON_NONE);
  
                        row=uiLayoutRow(layout, 1);
-                       uiItemR(row, ptr, "angle_min", 0, NULL, ICON_NULL);
-                       uiItemR(row, ptr, "angle_max", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "angle_min", 0, NULL, ICON_NONE);
+                       uiItemR(row, ptr, "angle_max", 0, NULL, ICON_NONE);
                        break;
  
                case ACT_CONST_TYPE_FH:
                        split=uiLayoutSplit(layout, 0.75, 0);
                        row= uiLayoutRow(split, 0);
-                       uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER , NULL, ICON_NULL);
+                       uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER , NULL, ICON_NONE);
  
-                       uiItemR(row, ptr, "fh_height", 0, NULL, ICON_NULL);
-                       uiItemR(split, ptr, "use_fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, ICON_NULL);
+                       uiItemR(row, ptr, "fh_height", 0, NULL, ICON_NONE);
+                       uiItemR(split, ptr, "use_fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, ICON_NONE);
  
                        row = uiLayoutRow(layout, 0);
-                       uiItemR(row, ptr, "direction_axis", 0, NULL, ICON_NULL);
+                       uiItemR(row, ptr, "direction_axis", 0, NULL, ICON_NONE);
                        split = uiLayoutSplit(row, 0.9, 0);
-                       uiItemR(split, ptr, "spring", 0, NULL, ICON_NULL);
-                       uiItemR(split, ptr, "use_fh_normal", UI_ITEM_R_TOGGLE , NULL, ICON_NULL);
+                       uiItemR(split, ptr, "fh_force", 0, NULL, ICON_NONE);
+                       uiItemR(split, ptr, "use_fh_normal", UI_ITEM_R_TOGGLE , NULL, ICON_NONE);
  
                        split = uiLayoutSplit(layout, 0.15, 0);
-                       uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+                       uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
                        if (RNA_boolean_get(ptr, "use_material_detect"))
                                uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA);
                        else
-                               uiItemR(split, ptr, "property", 0, NULL, ICON_NULL);
+                               uiItemR(split, ptr, "property", 0, NULL, ICON_NONE);
  
                        split = uiLayoutSplit(layout, 0.15, 0);
-                       uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NULL);
+                       uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE);
  
      &nbs