svn merge -r 22628:22714 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
authorMatt Ebb <matt@mke3.net>
Sun, 23 Aug 2009 03:33:33 +0000 (03:33 +0000)
committerMatt Ebb <matt@mke3.net>
Sun, 23 Aug 2009 03:33:33 +0000 (03:33 +0000)
1  2 
release/ui/buttons_material.py
release/ui/buttons_texture.py
source/blender/blenkernel/intern/material.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/preview/previewrender.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_texture.c
source/blender/render/intern/source/texture.c

index 3aec2517bf1dd751506dc34482584b2db7bc1b3d,eaba26c7e5177b8a86a29c2390cb0f617a2c904c..21201166edaf6fef10a274b79c2f75e4d3a3363e
@@@ -2,8 -2,8 +2,8 @@@
  import bpy
  
  class MaterialButtonsPanel(bpy.types.Panel):
-       __space_type__ = "PROPERTIES"
-       __region_type__ = "WINDOW"
+       __space_type__ = 'PROPERTIES'
+       __region_type__ = 'WINDOW'
        __context__ = "material"
        # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
  
@@@ -45,10 -45,10 +45,10 @@@ class MATERIAL_PT_context_material(Mate
                        row.template_list(ob, "materials", ob, "active_material_index", rows=2)
  
                        col = row.column(align=True)
-                       col.itemO("object.material_slot_add", icon="ICON_ZOOMIN", text="")
-                       col.itemO("object.material_slot_remove", icon="ICON_ZOOMOUT", text="")
+                       col.itemO("object.material_slot_add", icon='ICON_ZOOMIN', text="")
+                       col.itemO("object.material_slot_remove", icon='ICON_ZOOMOUT', text="")
  
-                       if context.edit_object:
+                       if ob.mode == 'EDIT':
                                row = layout.row(align=True)
                                row.itemO("object.material_slot_assign", text="Assign")
                                row.itemO("object.material_slot_select", text="Select")
@@@ -73,9 -73,6 +73,9 @@@ class MATERIAL_PT_shading(MaterialButto
        __label__ = "Shading"
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
  
 +      def poll(self, context):
 +              return (context.material.type in ('SURFACE', 'WIRE', 'HALO'))
 +
        def draw(self, context):
                layout = self.layout
                
  
                if mat:
  
 -                      if mat.type in ('SURFACE', 'WIRE', 'VOLUME'):
 +                      if mat.type in ('SURFACE', 'WIRE'):
                                split = layout.split()
        
                                col = split.column()
-                               col.active = not mat.shadeless
-                               col.itemR(mat, "ambient")
-                               col.itemR(mat, "emit")
-                               col.itemR(mat, "translucency")
+                               sub = col.column()
+                               sub.active = not mat.shadeless
+                               sub.itemR(mat, "emit")
+                               sub.itemR(mat, "ambient")
+                               sub = col.column()
+                               sub.itemR(mat, "translucency")
                                
                                col = split.column()
                                col.itemR(mat, "shadeless")     
@@@ -114,9 -113,6 +116,9 @@@ class MATERIAL_PT_strand(MaterialButton
                mat = context.material
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
        
 +      def poll(self, context):
 +              return context.material.type in ('SURFACE', 'WIRE', 'HALO')
 +      
        def draw(self, context):
                layout = self.layout
                
                
                split = layout.split()
                
-               col = split.column()
+               col = split.column(align=True)
                col.itemL(text="Size:")
                col.itemR(tan, "start_size", text="Root")
                col.itemR(tan, "end_size", text="Tip")
                sub = col.column()
                sub.active = (not mat.shadeless)
                sub.itemR(tan, "tangent_shading")
+               col.itemR(tan, "shape")
                
                col = split.column()
-               col.itemR(tan, "shape")
+               col.itemL(text="Shading:")
                col.itemR(tan, "width_fade")
                col.itemR(tan, "uv_layer")
+               col.itemS()
                sub = col.column()
                sub.active = (not mat.shadeless)
                sub.itemR(tan, "surface_diffuse")
@@@ -172,9 -170,6 +176,9 @@@ class MATERIAL_PT_options(MaterialButto
        __label__ = "Options"
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
  
 +      def poll(self, context):
 +              return (context.material.type in ('SURFACE', 'WIRE', 'HALO'))
 +
        def draw(self, context):
                layout = self.layout
                
@@@ -209,9 -204,6 +213,9 @@@ class MATERIAL_PT_shadow(MaterialButton
        __label__ = "Shadow"
        __default_closed__ = True
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 +      
 +      def poll(self, context):
 +              return context.material.type in ('SURFACE', 'WIRE')
  
        def draw(self, context):
                layout = self.layout
@@@ -244,7 -236,7 +248,7 @@@ class MATERIAL_PT_diffuse(MaterialButto
  
        def poll(self, context):
                mat = context.material
 -              return mat and (mat.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
 +              return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
  
        def draw(self, context):
                layout = self.layout
@@@ -298,7 -290,7 +302,7 @@@ class MATERIAL_PT_specular(MaterialButt
  
        def poll(self, context):
                mat = context.material
 -              return mat and (mat.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
 +              return mat and (mat.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
  
        def draw(self, context):
                layout = self.layout
@@@ -355,7 -347,9 +359,9 @@@ class MATERIAL_PT_sss(MaterialButtonsPa
        def draw_header(self, context):
                layout = self.layout
                sss = context.material.subsurface_scattering
+               mat = context.material
+               
+               layout.active = (not mat.shadeless)
                layout.itemR(sss, "enabled", text="")
        
        def draw(self, context):
                split = layout.split()
                split.active = (not mat.shadeless)
                
-               col = split.column(align=True)
+               col = split.column()
+               col.itemR(sss, "ior")
+               col.itemR(sss, "scale")
                col.itemR(sss, "color", text="")
-               col.itemL(text="Blend:")
-               col.itemR(sss, "color_factor", text="Color")
-               col.itemR(sss, "texture_factor", text="Texture")
-               col.itemL(text="Scattering Weight:")
-               col.itemR(sss, "front")
-               col.itemR(sss, "back")
+               col.itemR(sss, "radius", text="RGB Radius")
                
                col = split.column()
                sub = col.column(align=True)
-               sub.itemR(sss, "ior")
-               sub.itemR(sss, "scale")
-               col.itemR(sss, "radius", text="RGB Radius")
-               col.itemR(sss, "error_tolerance")
+               sub.itemL(text="Blend:")
+               sub.itemR(sss, "color_factor", text="Color")
+               sub.itemR(sss, "texture_factor", text="Texture")
+               sub.itemL(text="Scattering Weight:")
+               sub.itemR(sss, "front")
+               sub.itemR(sss, "back")
+               col.itemS()
+               col.itemR(sss, "error_tolerance", text="Error")
  
  class MATERIAL_PT_mirror(MaterialButtonsPanel):
        __label__ = "Mirror"
                col = split.column()
                col.itemR(raym, "reflect", text="Reflectivity")
                col.itemR(mat, "mirror_color", text="")
-               col.itemL(text="Fresnel:")
-               col.itemR(raym, "fresnel", text="Amount")
+               
+               
+               col = split.column()
+               col.itemR(raym, "fresnel")
                sub = col.column()
                sub.active = raym.fresnel > 0
                sub.itemR(raym, "fresnel_factor", text="Blend")
+               
+               split = layout.split()
+               
+               col = split.column()
                col.itemS()
+               col.itemR(raym, "distance", text="Max Dist")
+               col.itemR(raym, "depth")
                col.itemS()
                sub = col.split(percentage=0.4)
                sub.itemL(text="Fade To:")
                sub.itemR(raym, "fade_to", text="")
                
                col = split.column()
-               col.itemR(raym, "depth")
-               col.itemR(raym, "distance", text="Max Dist")
                col.itemL(text="Gloss:")
                col.itemR(raym, "gloss", text="Amount")
                sub = col.column()
@@@ -465,25 -466,24 +478,24 @@@ class MATERIAL_PT_transp(MaterialButton
                split = layout.split()
                
                col = split.column()
-               col.itemL(text="Transparency:")
                row = col.row()
                row.itemR(mat, "alpha")
-               row.active = mat.transparency
                row = col.row()
-               row.itemR(mat, "specular_alpha", text="Specular")
                row.active = mat.transparency and (not mat.shadeless)
+               row.itemR(mat, "specular_alpha", text="Specular")
+               
                
                col = split.column()
-               col.active = mat.transparency and (not mat.shadeless)
-               col.itemL(text="Fresnel:")
-               col.itemR(rayt, "fresnel", text="Amount")
+               col.active = (not mat.shadeless)
+               col.itemR(rayt, "fresnel")
                sub = col.column()
                sub.active = rayt.fresnel > 0
                sub.itemR(rayt, "fresnel_factor", text="Blend")
  
                if mat.transparency_method == 'RAYTRACE':
+                       layout.itemS()
                        split = layout.split()
-                       split.active = mat.transparency and (not mat.shadeless)
+                       split.active = mat.transparency
  
                        col = split.column()
                        col.itemR(rayt, "ior")
                        sub.active = rayt.gloss < 1
                        sub.itemR(rayt, "gloss_threshold", text="Threshold")
                        sub.itemR(rayt, "gloss_samples", text="Samples")
 +
 +class MATERIAL_PT_volume_shading(MaterialButtonsPanel):
 +      __label__ = "Shading"
 +      __default_closed__ = False
 +      COMPAT_ENGINES = set(['BLENDER_RENDER'])
 +      
 +      def poll(self, context):
 +              return (context.material.type == 'VOLUME') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
 +      
 +      def draw(self, context):
 +              layout = self.layout
 +
 +              mat = context.material
 +              vol = context.material.volume
 +              
 +              split = layout.split()
 +              
 +              row = split.row()
 +              row.itemR(vol, "density")
 +              row.itemR(vol, "scattering")
 +              
 +              split = layout.split()
 +              col = split.column()
 +              col.itemR(vol, "absorption")
 +              col.itemR(vol, "absorption_color", text="")
 +              
 +                              
 +              col = split.column()
 +              col.itemR(vol, "emission")
 +              col.itemR(vol, "emission_color", text="")
 +              
 +              
 +
 +class MATERIAL_PT_volume_scattering(MaterialButtonsPanel):
 +      __label__ = "Scattering"
 +      __default_closed__ = False
 +      COMPAT_ENGINES = set(['BLENDER_RENDER'])
 +      
 +      def poll(self, context):
 +              return (context.material.type == 'VOLUME') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
 +      
 +      def draw(self, context):
 +              layout = self.layout
 +              
 +              mat = context.material
 +              vol = context.material.volume
 +              
 +              split = layout.split()
 +              
 +              col = split.column()
 +              col.itemR(vol, "scattering_mode", text="")
 +              if vol.scattering_mode == 'SINGLE_SCATTERING':
 +                      col.itemR(vol, "light_cache")
 +                      sub = col.column()
 +                      sub.active = vol.light_cache
 +                      sub.itemR(vol, "cache_resolution")
 +              elif vol.scattering_mode in ('MULTIPLE_SCATTERING', 'SINGLE_PLUS_MULTIPLE_SCATTERING'):
 +                      col.itemR(vol, "cache_resolution")
 +                      
 +                      col = col.column(align=True)
 +                      col.itemR(vol, "ms_diffusion")
 +                      col.itemR(vol, "ms_spread")
 +                      col.itemR(vol, "ms_intensity")
 +              
 +              col = split.column()
 +              # col.itemL(text="Anisotropic Scattering:")
 +              col.itemR(vol, "phase_function", text="")
 +              if vol.phase_function in ('SCHLICK', 'HENYEY-GREENSTEIN'):
 +                      col.itemR(vol, "asymmetry")
 +
 +class MATERIAL_PT_volume_transp(MaterialButtonsPanel):
 +      __label__= "Transparency"
 +      COMPAT_ENGINES = set(['BLENDER_RENDER'])
 +              
 +      def poll(self, context):
 +              mat = context.material
 +              return mat and (mat.type == 'VOLUME') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
 +
 +      def draw_header(self, context):
 +              layout = self.layout
 +
 +      def draw(self, context):
 +              layout = self.layout
 +              
 +              mat = context.material
 +              rayt = context.material.raytrace_transparency
 +              
 +              row= layout.row()
 +              row.itemR(mat, "transparency_method", expand=True)
 +              row.active = mat.transparency and (not mat.shadeless)
 +              
 +class MATERIAL_PT_volume_integration(MaterialButtonsPanel):
 +      __label__ = "Integration"
 +      __default_closed__ = False
 +      COMPAT_ENGINES = set(['BLENDER_RENDER'])
 +      
 +      def poll(self, context):
 +              return (context.material.type == 'VOLUME') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
 +      
 +      def draw(self, context):
 +              layout = self.layout
 +              
 +              mat = context.material
 +              vol = context.material.volume
 +              
 +              split = layout.split()
 +              
 +              col = split.column()
 +              col.itemL(text="Step Calculation:")
 +              col.itemR(vol, "step_calculation", text="")
 +              col = col.column(align=True)
 +              col.itemR(vol, "step_size")
 +              col.itemR(vol, "shading_step_size")
 +              
 +              col = split.column()
 +              col.itemL()
 +              col.itemR(vol, "depth_cutoff")
 +              col.itemR(vol, "density_scale")
 +              
                
  class MATERIAL_PT_halo(MaterialButtonsPanel):
        __label__= "Halo"
                sub.active = halo.ring
                sub.itemR(halo, "rings")
                sub.itemR(mat, "mirror_color", text="")
+               col.itemS()
                col.itemR(halo, "lines")
                sub = col.column()
                sub.active = halo.lines
                sub.itemR(halo, "line_number", text="Lines")
                sub.itemR(mat, "specular_color", text="")
+               col.itemS()
                col.itemR(halo, "star")
                sub = col.column()
                sub.active = halo.star
                sub.itemR(halo, "star_tips")
-               col.itemR(halo, "flare_mode")
-               sub = col.column()
-               sub.active = halo.flare_mode
-               sub.itemR(halo, "flare_size", text="Size")
-               sub.itemR(halo, "flare_subsize", text="Subsize")
-               sub.itemR(halo, "flare_boost", text="Boost")
-               sub.itemR(halo, "flare_seed", text="Seed")
-               sub.itemR(halo, "flares_sub", text="Sub")
+               
+ class MATERIAL_PT_flare(MaterialButtonsPanel):
+       __label__= "Flare"
+       COMPAT_ENGINES = set(['BLENDER_RENDER'])
+       
+       def poll(self, context):
+               mat = context.material
+               return mat and (mat.type == 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
+       
+       def draw_header(self, context):
+               layout = self.layout
+               
+               mat = context.material
+               halo = mat.halo
+               layout.itemR(halo, "flare_mode", text="")
+       
+       def draw(self, context):
+               layout = self.layout
+               
+               mat = context.material
+               halo = mat.halo
+               layout.active = halo.flare_mode
+               
+               split = layout.split()
+               
+               col = split.column()
+               col.itemR(halo, "flare_size", text="Size")
+               col.itemR(halo, "flare_boost", text="Boost")
+               col.itemR(halo, "flare_seed", text="Seed")
+               col = split.column()
+               col.itemR(halo, "flares_sub", text="Subflares")
+               col.itemR(halo, "flare_subsize", text="Subsize")
  
  bpy.types.register(MATERIAL_PT_context_material)
  bpy.types.register(MATERIAL_PT_preview)
@@@ -679,11 -587,8 +718,12 @@@ bpy.types.register(MATERIAL_PT_shading
  bpy.types.register(MATERIAL_PT_transp)
  bpy.types.register(MATERIAL_PT_mirror)
  bpy.types.register(MATERIAL_PT_sss)
 +bpy.types.register(MATERIAL_PT_volume_shading)
 +bpy.types.register(MATERIAL_PT_volume_scattering)
 +bpy.types.register(MATERIAL_PT_volume_transp)
 +bpy.types.register(MATERIAL_PT_volume_integration)
  bpy.types.register(MATERIAL_PT_halo)
+ bpy.types.register(MATERIAL_PT_flare)
  bpy.types.register(MATERIAL_PT_physics)
  bpy.types.register(MATERIAL_PT_strand)
  bpy.types.register(MATERIAL_PT_options)
index e4db27cc9f9b3466578262e6b84f44d3cdb689ea,20b3c7bca3e72e17dfafb5e38540dc867d6f79bc..756f96b4803a0c2d2b2daca9298323a109b45869
@@@ -1,9 -1,9 +1,9 @@@
 -
 +      
  import bpy
  
  class TextureButtonsPanel(bpy.types.Panel):
-       __space_type__ = "PROPERTIES"
-       __region_type__ = "WINDOW"
+       __space_type__ = 'PROPERTIES'
+       __region_type__ = 'WINDOW'
        __context__ = "texture"
        
        def poll(self, context):
@@@ -210,51 -210,35 +210,51 @@@ class TEXTURE_PT_influence(TextureSlotP
                        sub.itemR(tex, factor, text=name, slider=True)
                
                if ma:
 -                      split = layout.split()
 -                      
 -                      col = split.column()
 -                      col.itemL(text="Diffuse:")
 -                      factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
 -                      factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
 -                      factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
 -                      factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
 -
 -                      col.itemL(text="Specular:")
 -                      factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
 -                      factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
 -                      factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
 +                      if ma.type in ['SURFACE', 'HALO', 'WIRE']:
 +                              split = layout.split()
 +                              
 +                              col = split.column()
 +                              col.itemL(text="Diffuse:")
 +                              factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
 +                              factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
 +                              factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
 +                              factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
 +
 +                              col.itemL(text="Specular:")
 +                              factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
 +                              factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
 +                              factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
 +
 +                              col = split.column()
 +                              col.itemL(text="Shading:")
 +                              factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
 +                              factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
 +                              factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
 +                              factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
 +
 +                              col.itemL(text="Geometry:")
 +                              factor_but(col, tex.map_normal, "map_normal", "normal_factor", "Normal")
 +                              factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
 +                              factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
 +
 +                              #sub = col.column()
 +                              #sub.active = tex.map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror
 +                              #sub.itemR(tex, "default_value", text="Amount", slider=True)
 +                      elif ma.type == 'VOLUME':
 +                              split = layout.split()
 +                              
 +                              col = split.column()
 +                              factor_but(col, tex.map_density, "map_density", "density_factor", "Density")
 +                              factor_but(col, tex.map_emission, "map_emission", "emission_factor", "Emission")
 +                              factor_but(col, tex.map_absorption, "map_absorption", "absorption_factor", "Absorption")
 +                              factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering")
 +                              
 +                              col = split.column()
 +                              col.itemL(text=" ")
 +                              factor_but(col, tex.map_alpha, "map_coloremission", "coloremission_factor", "Emission Color")
 +                              factor_but(col, tex.map_colorabsorption, "map_colorabsorption", "colorabsorption_factor", "Absorption Color")
 +                              
  
 -                      col = split.column()
 -                      col.itemL(text="Shading:")
 -                      factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
 -                      factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
 -                      factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
 -                      factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
 -
 -                      col.itemL(text="Geometry:")
 -                      factor_but(col, tex.map_normal, "map_normal", "normal_factor", "Normal")
 -                      factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
 -                      factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
 -
 -                      #sub = col.column()
 -                      #sub.active = tex.map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror
 -                      #sub.itemR(tex, "default_value", text="Amount", slider=True)
                elif la:
                        row = layout.row()
                        factor_but(row, tex.map_color, "map_color", "color_factor", "Color")
@@@ -612,62 -596,6 +612,62 @@@ class TEXTURE_PT_distortednoise(Texture
                flow.itemR(tex, "distortion_amount", text="Distortion")
                flow.itemR(tex, "noise_size", text="Size")
                flow.itemR(tex, "nabla")        
 +              
 +class TEXTURE_PT_voxeldata(TextureButtonsPanel):
 +      __idname__= "TEXTURE_PT_voxeldata"
 +      __label__ = "Voxel Data"
 +      
 +      def poll(self, context):
 +              tex = context.texture
 +              return (tex and tex.type == 'VOXEL_DATA')
 +
 +      def draw(self, context):
 +              layout = self.layout
 +              tex = context.texture
 +              vd = tex.voxeldata
 +
 +              layout.itemR(vd, "file_format")
 +              if vd.file_format in ['BLENDER_VOXEL', 'RAW_8BIT']:
 +                      layout.itemR(vd, "source_path")
 +              if vd.file_format == 'RAW_8BIT':
 +                      layout.itemR(vd, "resolution")
 +              if vd.file_format == 'SMOKE':
 +                      layout.itemR(vd, "domain_object")
 +              
 +              layout.itemR(vd, "still")
 +              if vd.still:
 +                      layout.itemR(vd, "still_frame_number")
 +              
 +              layout.itemR(vd, "interpolation")
 +              layout.itemR(vd, "intensity")
 +              
 +class TEXTURE_PT_pointdensity(TextureButtonsPanel):
 +      __idname__= "TEXTURE_PT_pointdensity"
 +      __label__ = "Point Density"
 +      
 +      def poll(self, context):
 +              tex = context.texture
 +              return (tex and tex.type == 'POINT_DENSITY')
 +
 +      def draw(self, context):
 +              layout = self.layout
 +              tex = context.texture
 +              pd = tex.pointdensity
 +
 +              layout.itemR(pd, "point_source")
 +              layout.itemR(pd, "object")
 +              if pd.point_source == 'PARTICLE_SYSTEM':
 +                      layout.item_pointerR(pd, "particle_system", pd.object, "particle_systems", text="")
 +              layout.itemR(pd, "radius")
 +              layout.itemR(pd, "falloff")
 +              if pd.falloff == 'SOFT':
 +                      layout.itemR(pd, "falloff_softness")
 +              layout.itemR(pd, "color_source")
 +              layout.itemR(pd, "turbulence")
 +              layout.itemR(pd, "turbulence_size")
 +              layout.itemR(pd, "turbulence_depth")
 +              layout.itemR(pd, "turbulence_influence")
 +              
  
  bpy.types.register(TEXTURE_PT_context_texture)
  bpy.types.register(TEXTURE_PT_preview)
@@@ -685,8 -613,6 +685,8 @@@ bpy.types.register(TEXTURE_PT_envmap
  bpy.types.register(TEXTURE_PT_musgrave)
  bpy.types.register(TEXTURE_PT_voronoi)
  bpy.types.register(TEXTURE_PT_distortednoise)
 +bpy.types.register(TEXTURE_PT_voxeldata)
 +bpy.types.register(TEXTURE_PT_pointdensity)
  bpy.types.register(TEXTURE_PT_colors)
  bpy.types.register(TEXTURE_PT_mapping)
  bpy.types.register(TEXTURE_PT_influence)
index 0e26564df74ee41f30474509cc08124bdb929724,62ec12349aa2e5c1bd6bc605e2b3b8e5049d41d4..53de570b55e92e9c4d2ee6ce9e47d1e31af82608
@@@ -170,22 -170,7 +170,22 @@@ void init_material(Material *ma
        ma->sss_front= 1.0f;
        ma->sss_back= 1.0f;
  
-       ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR;
 +      ma->vol.density = 1.0f;
 +      ma->vol.emission = 0.0f;
 +      ma->vol.absorption = 1.0f;
 +      ma->vol.scattering = 1.0f;
 +      ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
 +      ma->vol.absorption_col[0] = ma->vol.absorption_col[1] = ma->vol.absorption_col[2] = 0.0f;
 +      ma->vol.density_scale = 1.0f;
 +      ma->vol.depth_cutoff = 0.01f;
 +      ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
 +      ma->vol.stepsize = 0.2f;
 +      ma->vol.shade_stepsize = 0.2f;
 +      ma->vol.shade_type = MA_VOL_SHADE_SINGLE;
 +      ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
 +      ma->vol.precache_resolution = 50;
 +      
+       ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP;
  
        ma->preview = NULL;
  }
index d239245545db756083d75d7715ec8a8eec9e596f,77b51d950b937195c5201e80f99b0d81d7b1a7f3..5cc3ff7695a28d93dfadf53d821009fc59f1efc8
@@@ -2819,11 -2819,6 +2819,11 @@@ static void lib_link_texture(FileData *
                        tex->ima= newlibadr_us(fd, tex->id.lib, tex->ima);
                        tex->ipo= newlibadr_us(fd, tex->id.lib, tex->ipo);
                        if(tex->env) tex->env->object= newlibadr(fd, tex->id.lib, tex->env->object);
 +                      if(tex->pd) {
 +                              tex->pd->object= newlibadr(fd, tex->id.lib, tex->pd->object);
 +                              tex->pd->psys= newlibadr(fd, tex->id.lib, tex->pd->psys);
 +                      }
 +                      if(tex->vd) tex->vd->object= newlibadr(fd, tex->id.lib, tex->vd->object);
  
                        if(tex->nodetree)
                                lib_link_ntree(fd, &tex->id, tex->nodetree);
@@@ -2856,16 -2851,6 +2856,16 @@@ static void direct_link_texture(FileDat
                memset(tex->env->cube, 0, 6*sizeof(void *));
                tex->env->ok= 0;
        }
 +      tex->pd= newdataadr(fd, tex->pd);
 +      if(tex->pd) {
 +              tex->pd->point_tree = NULL;
 +              tex->pd->coba= newdataadr(fd, tex->pd->coba);
 +      }
 +      
 +      tex->vd= newdataadr(fd, tex->vd);
 +      if(tex->vd) {
 +              tex->vd->dataset = NULL;
 +      }
        
        tex->nodetree= newdataadr(fd, tex->nodetree);
        if(tex->nodetree)
@@@ -3108,7 -3093,7 +3108,7 @@@ static void direct_link_particlesystems
                        psys->flag &= ~PSYS_KEYED;
                }
  
-               if(psys->particles->boid) {
+               if(psys->particles && psys->particles->boid) {
                        pa = psys->particles;
                        pa->boid = newdataadr(fd, pa->boid);
                        for(a=1,pa++; a<psys->totpart; a++, pa++)
@@@ -3684,8 -3669,6 +3684,6 @@@ static void direct_link_modifiers(FileD
                else if (md->type==eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData*) md;
  
-                       smd->point_cache = NULL;
                        if(smd->type==MOD_SMOKE_TYPE_DOMAIN)
                        {
                                smd->flow = NULL;
                                smd->domain->smd = smd;
  
                                smd->domain->fluid = NULL;
-                               smd->domain->wt = NULL;
-                               smd->domain->tvox = NULL;
-                               smd->domain->tray = NULL;
-                               smd->domain->tvoxbig = NULL;
-                               smd->domain->traybig = NULL;
-                               smd->domain->bind = NULL;
-                               smd->domain->max_textures= 0;
-                               // do_versions trick
-                               if(smd->domain->strength < 1.0)
-                                       smd->domain->strength = 2.0;
-                               // reset 3dview
-                               if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG)
-                                       smd->domain->viewsettings = 0;
-                               else
-                                       smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG;
+                               smd->domain->view3d = NULL;
+                               smd->domain->tex = NULL;
+                               direct_link_pointcache_list(fd, &smd->domain->ptcaches, &smd->domain->point_cache);
                        }
                        else if(smd->type==MOD_SMOKE_TYPE_FLOW)
                        {
@@@ -4149,6 -4119,7 +4134,7 @@@ static void direct_link_scene(FileData 
        sce->theDag = NULL;
        sce->dagisvalid = 0;
        sce->obedit= NULL;
+       sce->stats= 0;
  
        memset(&sce->sound_handles, 0, sizeof(sce->sound_handles));
  
@@@ -9445,7 -9416,7 +9431,7 @@@ static void do_versions(FileData *fd, L
  
                                        mmd->lvl = mmd->totlvl;
                                        orig = CDDM_from_mesh(me, NULL);
-                                       dm = multires_dm_create_from_derived(mmd, orig, me, 0, 0);
+                                       dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0, 0);
                                         
                                        multires_load_old(dm, me->mr);
  
                                        }
                                }
                        }
 +                      
 +                      /* volume rendering settings */
 +                      if (ma->vol.stepsize < 0.0001f) {
 +                              ma->vol.density = 1.0f;
 +                              ma->vol.emission = 0.0f;
 +                              ma->vol.absorption = 1.0f;
 +                              ma->vol.scattering = 1.0f;
 +                              ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
 +                              ma->vol.absorption_col[0] = ma->vol.absorption_col[1] = ma->vol.absorption_col[2] = 0.0f;
 +                              ma->vol.density_scale = 1.0f;
 +                              ma->vol.depth_cutoff = 0.01f;
 +                              ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
 +                              ma->vol.stepsize = 0.2f;
 +                              ma->vol.shade_stepsize = 0.2f;
 +                              ma->vol.shade_type = MA_VOL_SHADE_SINGLE;
 +                              ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
 +                              ma->vol.precache_resolution = 50;
 +                      }
                }
  
                for(sce = main->scene.first; sce; sce = sce->id.next) {
@@@ -10851,14 -10804,16 +10837,16 @@@ static Library* library_append(Main *ma
        fix_relpaths_library(G.sce, mainvar); /* make all relative paths, relative to the open blend file */
  
        /* give a base to loose objects. If group append, do it for objects too */
-       if(idcode==ID_GR) {
-               if (flag & FILE_LINK) {
-                       give_base_to_objects(mainvar, scene, NULL, 0);
+       if(scene) {
+               if(idcode==ID_GR) {
+                       if (flag & FILE_LINK) {
+                               give_base_to_objects(mainvar, scene, NULL, 0);
+                       } else {
+                               give_base_to_objects(mainvar, scene, curlib, 1);
+                       }       
                } else {
-                       give_base_to_objects(mainvar, scene, curlib, 1);
-               }       
-       } else {
-               give_base_to_objects(mainvar, scene, NULL, 0);
+                       give_base_to_objects(mainvar, scene, NULL, 0);
+               }
        }
        /* has been removed... erm, why? s..ton) */
        /* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
index 98f454d5b08d4d4de293c1b342fa8ba72bb20253,31fe0c01900d942770225da572c11d5eb9ec8fd0..eb3f17f368ce94e7b8dff7b0289e80ada02e6d04
@@@ -1100,7 -1100,7 +1100,7 @@@ static void write_defgroups(WriteData *
                writestruct(wd, DATA, "bDeformGroup", 1, defgroup);
  }
  
- static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo)
+ static void write_modifiers(WriteData *wd, ListBase *modbase)
  {
        ModifierData *md;
  
                else if(md->type==eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData*) md;
                        
-                       if(smd->type==MOD_SMOKE_TYPE_DOMAIN)
+                       if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
                                writestruct(wd, DATA, "SmokeDomainSettings", 1, smd->domain);
-                       else if(smd->type==MOD_SMOKE_TYPE_FLOW)
+                       else if(smd->type & MOD_SMOKE_TYPE_FLOW)
                                writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow);
                        /*
-                       else if(smd->type==MOD_SMOKE_TYPE_COLL)
+                       else if(smd->type & MOD_SMOKE_TYPE_COLL)
                                writestruct(wd, DATA, "SmokeCollSettings", 1, smd->coll);
                        */
+                       if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
+                               write_pointcaches(wd, &smd->domain->ptcaches);
                } 
                else if(md->type==eModifierType_Fluidsim) {
                        FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
                else if (md->type==eModifierType_Multires) {
                        MultiresModifierData *mmd = (MultiresModifierData*) md;
  
-                       if(mmd->undo_verts && write_undo)
+                       if(mmd->undo_verts)
                                writestruct(wd, DATA, "MVert", mmd->undo_verts_tot, mmd->undo_verts);
                }
        }
  }
  
- static void write_objects(WriteData *wd, ListBase *idbase, int write_undo)
+ static void write_objects(WriteData *wd, ListBase *idbase)
  {
        Object *ob;
        
                        writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
                        
                        write_particlesystems(wd, &ob->particlesystem);
-                       write_modifiers(wd, &ob->modifiers, write_undo);
+                       write_modifiers(wd, &ob->modifiers);
                }
                ob= ob->id.next;
        }
@@@ -1569,11 -1572,6 +1572,11 @@@ static void write_textures(WriteData *w
                        if(tex->type == TEX_PLUGIN && tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin);
                        if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba);
                        if(tex->type == TEX_ENVMAP && tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env);
 +                      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->type == TEX_VOXELDATA && tex->vd) writestruct(wd, DATA, "VoxelData", 1, tex->vd);
                        
                        /* nodetree is integral part of texture, no libdata */
                        if(tex->nodetree) {
@@@ -2325,7 -2323,7 +2328,7 @@@ static int write_file_handle(Main *main
        write_groups   (wd, &mainvar->group);
        write_armatures(wd, &mainvar->armature);
        write_actions  (wd, &mainvar->action);
-       write_objects  (wd, &mainvar->object, (current != NULL));
+       write_objects  (wd, &mainvar->object);
        write_materials(wd, &mainvar->mat);
        write_textures (wd, &mainvar->tex);
        write_meshs    (wd, &mainvar->mesh);
index e273791273d7884c701c4d4e1bcfa84e4cd2affa,94db74c18d9d417ae10e357d0b5f00d276de1ee9..d17391811bbb2248786059b8243a18cc8fdcb79d
@@@ -307,8 -307,6 +307,8 @@@ static Scene *preview_prepare_scene(Sce
                                /* turn on raytracing if needed */
                                if(mat->mode_l & MA_RAYMIRROR)
                                        sce->r.mode |= R_RAYTRACE;
 +                              if(mat->material_type == MA_TYPE_VOLUME)
 +                                      sce->r.mode |= R_RAYTRACE;
                                if((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP))
                                        sce->r.mode |= R_RAYTRACE;
                                if(mat->sss_flag & MA_DIFF_SSS)
@@@ -948,7 -946,11 +948,11 @@@ void ED_preview_shader_job(const bConte
        /* XXX ugly global still, but we can't do preview while rendering */
        if(G.rendering)
                return;
+       
+       if(GS(id->name) == ID_TE) {
+               ntreeTexSetPreviewFlag(1);
+       }
+       
        steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner);
        sp= MEM_callocN(sizeof(ShaderPreview), "shader preview");
  
index 3850ca387861dc70a88b1f93f65bceb3761bae32,e4fe92317d4247ed427c363fecee1552c93aeae7..fb351efed668b538dd18f9fd088704c1f720c161
@@@ -321,8 -321,6 +321,8 @@@ extern StructRNA RNA_ParticleTarget
  extern StructRNA RNA_PluginSequence;
  extern StructRNA RNA_PluginTexture;
  extern StructRNA RNA_PointCache;
 +extern StructRNA RNA_PointDensity;
 +extern StructRNA RNA_PointDensityTexture;
  extern StructRNA RNA_PointerProperty;
  extern StructRNA RNA_Pose;
  extern StructRNA RNA_PoseChannel;
@@@ -389,6 -387,7 +389,7 @@@ extern StructRNA RNA_SmokeCollSettings
  extern StructRNA RNA_SmokeDomainSettings;
  extern StructRNA RNA_SmokeFlowSettings;
  extern StructRNA RNA_SmokeModifier;
+ extern StructRNA RNA_SmokeHRModifier;
  extern StructRNA RNA_SmoothModifier;
  extern StructRNA RNA_SoftBodyModifier;
  extern StructRNA RNA_SoftBodySettings;
@@@ -500,8 -499,6 +501,8 @@@ extern StructRNA RNA_VertexGroup
  extern StructRNA RNA_VertexGroupElement;
  extern StructRNA RNA_VertexPaint;
  extern StructRNA RNA_VoronoiTexture;
 +extern StructRNA RNA_VoxelData;
 +extern StructRNA RNA_VoxelDataTexture;
  extern StructRNA RNA_WaveModifier;
  extern StructRNA RNA_Window;
  extern StructRNA RNA_WindowManager;
index 5130145fa561d05158c6566f29a605c6747a641f,69298fbb8a4410b629b3692a3113220c7548c340..a949d26f51a1a7b54cc8b8349eabffc4043e5c70
@@@ -86,32 -86,11 +86,32 @@@ StructRNA *rna_Texture_refine(struct Po
                        return &RNA_VoronoiTexture;
                case TEX_DISTNOISE:
                        return &RNA_DistortedNoiseTexture;
 +              case TEX_POINTDENSITY:
 +                      return &RNA_PointDensityTexture;
 +              case TEX_VOXELDATA:
 +                      return &RNA_VoxelDataTexture;
                default:
                        return &RNA_Texture;
        }
  }
  
 +static void rna_Texture_type_set(PointerRNA *ptr, int value)
 +{
 +      Tex *tex= (Tex*)ptr->data;
 +
 +      if (value == TEX_VOXELDATA) {
 +              if (tex->vd == NULL) {
 +                      tex->vd = BKE_add_voxeldata();
 +              }
 +      } else if (value == TEX_POINTDENSITY) {
 +              if (tex->pd == NULL) {
 +                      tex->pd = BKE_add_pointdensity();
 +              }
 +      }
 +      
 +      tex->type = value;
 +}
 +
  static int rna_TextureSlot_name_length(PointerRNA *ptr)
  {
        MTex *mtex= ptr->data;
@@@ -163,7 -142,7 +163,7 @@@ static EnumPropertyItem *rna_TextureSlo
        EnumPropertyItem *item= NULL;
        int totitem= 0;
        
-       if(tex) {
+       if(tex && C) { /* Note, tex/mtex/ntree can be invalid of C is NULL, TODO - can this give valid results when C is NULL? */
                bNodeTree *ntree= tex->nodetree;
                if(ntree) {
                        EnumPropertyItem tmp= {0, "", 0, "", ""};
@@@ -1307,13 -1286,13 +1307,13 @@@ static void rna_def_texture_distorted_n
        RNA_def_property_update(prop, NC_TEXTURE, NULL);
  
        prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
+       RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
        RNA_def_property_enum_items(prop, prop_noise_basis_items);
        RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
        RNA_def_property_update(prop, NC_TEXTURE, NULL);
  
        prop= RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
+       RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
        RNA_def_property_enum_items(prop, prop_noise_basis_items);
        RNA_def_property_ui_text(prop, "Noise Distortion", "Sets the noise basis for the distortion");
        RNA_def_property_update(prop, NC_TEXTURE, NULL);
        RNA_def_property_update(prop, NC_TEXTURE, NULL);
  }
  
 +static void rna_def_texture_pointdensity(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +      
 +      static EnumPropertyItem point_source_items[] = {
 +              {TEX_PD_PSYS, "PARTICLE_SYSTEM", 0, "Particle System", "Generate point density from a particle system"},
 +              {TEX_PD_OBJECT, "OBJECT", 0, "Object Vertices", "Generate point density from an object's vertices"},
 +              {0, NULL, 0, NULL, NULL}};
 +      
 +      static EnumPropertyItem falloff_items[] = {
 +              {TEX_PD_FALLOFF_STD, "STANDARD", 0, "Standard", ""},
 +              {TEX_PD_FALLOFF_SMOOTH, "SMOOTH", 0, "Smooth", ""},
 +              {TEX_PD_FALLOFF_SOFT, "SOFT", 0, "Soft", ""},
 +              {TEX_PD_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", "Density is constant within lookup radius"},
 +              {TEX_PD_FALLOFF_ROOT, "ROOT", 0, "Root", ""},
 +              {0, NULL, 0, NULL, NULL}};
 +      
 +      static EnumPropertyItem color_source_items[] = {
 +              {TEX_PD_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""},
 +              {TEX_PD_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age", "Lifetime mapped as 0.0 - 1.0 intensity"},
 +              {TEX_PD_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed", "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"},
 +              {TEX_PD_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "XYZ velocity mapped to RGB colors"},
 +              {0, NULL, 0, NULL, NULL}};
 +      
 +      static EnumPropertyItem turbulence_influence_items[] = {
 +              {TEX_PD_NOISE_STATIC, "STATIC", 0, "Static", "Noise patterns will remain unchanged, faster and suitable for stills"},
 +              {TEX_PD_NOISE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "Turbulent noise driven by particle velocity"},
 +              {TEX_PD_NOISE_AGE, "PARTICLE_AGE", 0, "Particle Age", "Turbulent noise driven by the particle's age between birth and death"},
 +                      {TEX_PD_NOISE_TIME, "GLOBAL_TIME", 0, "Global Time", "Turbulent noise driven by the global current frame"},
 +              {0, NULL, 0, NULL, NULL}};
 +      
 +      srna= RNA_def_struct(brna, "PointDensity", NULL);
 +      RNA_def_struct_sdna(srna, "PointDensity");
 +      RNA_def_struct_ui_text(srna, "PointDensity", "Point density settings.");
 +      
 +      prop= RNA_def_property(srna, "point_source", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "source");
 +      RNA_def_property_enum_items(prop, point_source_items);
 +      RNA_def_property_ui_text(prop, "Point Source", "Point data to use as renderable point density");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "object");
 +      RNA_def_property_ui_text(prop, "Object", "Object to take point data from");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "psys");
 +      RNA_def_property_ui_text(prop, "Particle System", "Particle System to render as points");
 +      RNA_def_property_struct_type(prop, "ParticleSystem");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "radius");
 +      RNA_def_property_range(prop, 0.01, FLT_MAX);
 +      RNA_def_property_ui_text(prop, "Radius", "Radius from the shaded sample to look for points within");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "falloff_type");
 +      RNA_def_property_enum_items(prop, falloff_items);
 +      RNA_def_property_ui_text(prop, "Falloff", "Method of attenuating density by distance from the point");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "falloff_softness", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "falloff_softness");
 +      RNA_def_property_range(prop, 0.01, FLT_MAX);
 +      RNA_def_property_ui_text(prop, "Softness", "Softness of the 'soft' falloff option");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "color_source", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "color_source");
 +      RNA_def_property_enum_items(prop, color_source_items);
 +      RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "turbulence", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_TURBULENCE);
 +      RNA_def_property_ui_text(prop, "Turbulence", "Add directed noise to the density at render-time");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "turbulence_size", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "noise_size");
 +      RNA_def_property_range(prop, 0.01, FLT_MAX);
 +      RNA_def_property_ui_text(prop, "Size", "Scale of the added turbulent noise");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
 +      RNA_def_property_int_sdna(prop, NULL, "noise_depth");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "turbulence_influence", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "noise_influence");
 +      RNA_def_property_enum_items(prop, turbulence_influence_items);
 +      RNA_def_property_ui_text(prop, "Turbulence Influence", "Method for driving added turbulent noise");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +
 +      
 +      
 +      srna= RNA_def_struct(brna, "PointDensityTexture", "Texture");
 +      RNA_def_struct_sdna(srna, "Tex");
 +      RNA_def_struct_ui_text(srna, "Point Density", "Settings for the Point Density texture");
 +      
 +      prop= RNA_def_property(srna, "pointdensity", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "pd");
 +      RNA_def_property_struct_type(prop, "PointDensity");
 +      RNA_def_property_ui_text(prop, "Point Density", "The point density settings associated with this texture");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +}
 +
 +static void rna_def_texture_voxeldata(BlenderRNA *brna)
 +{
 +      StructRNA *srna;
 +      PropertyRNA *prop;
 +      
 +      static EnumPropertyItem interpolation_type_items[] = {
 +              {TEX_VD_NEARESTNEIGHBOR, "NEREASTNEIGHBOR", 0, "Nearest Neighbor", "No interpolation, fast but blocky and low quality."},
 +              {TEX_VD_LINEAR, "TRILINEAR", 0, "Trilinear", "Good smoothness and speed"},
 +              {TEX_VD_TRICUBIC, "TRICUBIC", 0, "Tricubic", "High quality interpolation, but slow"},
 +              {0, NULL, 0, NULL, NULL}};
 +      
 +      static EnumPropertyItem file_format_items[] = {
 +              {TEX_VD_BLENDERVOXEL, "BLENDER_VOXEL", 0, "Blender Voxel", "Default binary voxel file format"},
 +              {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit greyscale binary data"},
 +              {TEX_VD_IMAGE_SEQUENCE, "IMAGE_SEQUENCE", 0, "Image Sequence", "Generate voxels from a sequence of image slices"},
 +              {TEX_VD_SMOKE, "SMOKE", 0, "Smoke", "Render voxels from a Blender smoke simulation"},
 +              {0, NULL, 0, NULL, NULL}};
 +
 +      srna= RNA_def_struct(brna, "VoxelData", NULL);
 +      RNA_def_struct_sdna(srna, "VoxelData");
 +      RNA_def_struct_ui_text(srna, "VoxelData", "Voxel data settings.");
 +      
 +      prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "interp_type");
 +      RNA_def_property_enum_items(prop, interpolation_type_items);
 +      RNA_def_property_ui_text(prop, "Interpolation", "Method to interpolate/smooth values between voxel cells");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "int_multiplier");
 +      RNA_def_property_range(prop, 0.01, FLT_MAX);
 +      RNA_def_property_ui_text(prop, "Intensity", "Multiplier for intensity values");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_sdna(prop, NULL, "file_format");
 +      RNA_def_property_enum_items(prop, file_format_items);
 +      RNA_def_property_ui_text(prop, "File Format", "Format of the source data set to render  ");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "source_path", PROP_STRING, PROP_FILEPATH);
 +      RNA_def_property_string_sdna(prop, NULL, "source_path");
 +      RNA_def_property_ui_text(prop, "Source Path", "The external source data file to use");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE);
 +      RNA_def_property_int_sdna(prop, NULL, "resol");
 +      RNA_def_property_ui_text(prop, "Resolution", "Resolution of the voxel grid.");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "still", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_VD_STILL);
 +      RNA_def_property_ui_text(prop, "Still Frame Only", "Always render a still frame from the voxel data sequence");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "still_frame_number", PROP_INT, PROP_NONE);
 +      RNA_def_property_int_sdna(prop, NULL, "still_frame");
 +      RNA_def_property_range(prop, 0, INT_MAX);
 +      RNA_def_property_ui_text(prop, "Still Frame Number", "The frame number to always use");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +      
 +      prop= RNA_def_property(srna, "domain_object", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "object");
 +      RNA_def_property_ui_text(prop, "Domain Object", "Object used as the smoke simulation domain");
 +      RNA_def_property_flag(prop, PROP_EDITABLE);
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +
 +      
 +      srna= RNA_def_struct(brna, "VoxelDataTexture", "Texture");
 +      RNA_def_struct_sdna(srna, "Tex");
 +      RNA_def_struct_ui_text(srna, "Voxel Data", "Settings for the Voxel Data texture");
 +      
 +      prop= RNA_def_property(srna, "voxeldata", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "vd");
 +      RNA_def_property_struct_type(prop, "VoxelData");
 +      RNA_def_property_ui_text(prop, "Voxel Data", "The voxel data associated with this texture");
 +      RNA_def_property_update(prop, NC_TEXTURE, NULL);
 +}
 +
  static void rna_def_texture(BlenderRNA *brna)
  {
        StructRNA *srna;
                {TEX_MUSGRAVE, "MUSGRAVE", ICON_TEXTURE, "Musgrave", ""},
                {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", ""},
                {TEX_DISTNOISE, "DISTORTED_NOISE", ICON_TEXTURE, "Distorted Noise", ""},
 +              {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""},
 +              {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", ""},
                {0, NULL, 0, NULL, NULL}};
  
        srna= RNA_def_struct(brna, "Texture", "ID");
        //RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, prop_type_items);
 +      RNA_def_property_enum_funcs(prop, NULL, "rna_Texture_type_set", NULL);
        RNA_def_property_ui_text(prop, "Type", "");
        RNA_def_property_update(prop, NC_TEXTURE, NULL);
        
        rna_def_texture_musgrave(brna);
        rna_def_texture_voronoi(brna);
        rna_def_texture_distorted_noise(brna);
 +      rna_def_texture_pointdensity(brna);
 +      rna_def_texture_voxeldata(brna);
        /* XXX add more types here .. */
  }
  
index 0a12846e75809aff386cdad77df850a5fa99c79f,e6d6e78e27bd4a9c1a341846bed12c1845620e8d..c706c6ccc11e6046374260eeb5a67f9ff25735b7
@@@ -65,8 -65,6 +65,8 @@@
  #include "BKE_ipo.h"
  
  #include "envmap.h"
 +#include "pointdensity.h"
 +#include "voxeldata.h"
  #include "renderpipeline.h"
  #include "render_types.h"
  #include "rendercore.h"
@@@ -721,7 -719,7 +721,7 @@@ static int evalnodes(Tex *tex, float *t
        short rv = TEX_INT;
        bNodeTree *nodes = tex->nodetree;
        
-       ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, 0, thread, tex, which_output, R.r.cfra);
+       ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, thread, tex, which_output, R.r.cfra);
        
        if(texres->nor) rv |= TEX_NOR;
        rv |= TEX_RGB;
@@@ -1264,13 -1262,6 +1264,13 @@@ static int multitex(Tex *tex, float *te
                
                retval= mg_distNoiseTex(tex, tmpvec, texres);
                break;
 +      case TEX_POINTDENSITY:
 +              retval= pointdensitytex(tex, texvec, texres);
 +              break;
 +      case TEX_VOXELDATA:
 +              retval= voxeldatatex(tex, texvec, texres);  
 +              break;
 +
        }
  
        if (tex->flag & TEX_COLORBAND) {
                        texres->tg= col[1];
                        texres->tb= col[2];
                        texres->ta= col[3];
 -                      retval |= 1;
 +                      retval |= TEX_RGB;
                }
        }
        return retval;
@@@ -2257,187 -2248,6 +2257,187 @@@ void do_material_tex(ShadeInput *shi
        }
  }
  
 +
 +void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, float *val)
 +{
 +      MTex *mtex;
 +      Tex *tex;
 +      TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
 +      int tex_nr, rgbnor= 0;
 +      float co[3], texvec[3];
 +      float fact, stencilTin=1.0;
 +      
 +      if (R.r.scemode & R_NO_TEX) return;
 +      /* here: test flag if there's a tex (todo) */
 +      
 +      for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
 +              /* separate tex switching */
 +              if(shi->mat->septex & (1<<tex_nr)) continue;
 +              
 +              if(shi->mat->mtex[tex_nr]) {
 +                      mtex= shi->mat->mtex[tex_nr];
 +                      tex= mtex->tex;
 +                      if(tex==0) continue;
 +                      
 +                      /* only process if this texture is mapped 
 +                       * to one that we're interested in */
 +                      if (!(mtex->mapto & mapto_flag)) continue;
 +                      
 +                      /* which coords */
 +                      if(mtex->texco==TEXCO_OBJECT) { 
 +                              Object *ob= mtex->object;
 +                              ob= mtex->object;
 +                              if(ob) {                                                
 +                                      VECCOPY(co, xyz);       
 +                                      if(mtex->texflag & MTEX_OB_DUPLI_ORIG) {
 +                                              if(shi->obi && shi->obi->duplitexmat)
 +                                                      MTC_Mat4MulVecfl(shi->obi->duplitexmat, co);                                    
 +                                      } 
 +                                      MTC_Mat4MulVecfl(ob->imat, co);
 +                              }
 +                      }
 +                      /* not really orco, but 'local' */
 +                      else if(mtex->texco==TEXCO_ORCO) {
 +                              
 +                              if(mtex->texflag & MTEX_DUPLI_MAPTO) {
 +                                      VECCOPY(co, shi->duplilo);
 +                              }
 +                              else {
 +                                      Object *ob= shi->obi->ob;
 +                                      VECCOPY(co, xyz);
 +                                      MTC_Mat4MulVecfl(ob->imat, co);
 +                              }
 +                      }
 +                      else if(mtex->texco==TEXCO_GLOB) {                                                      
 +                         VECCOPY(co, xyz);
 +                         MTC_Mat4MulVecfl(R.viewinv, co);
 +                      }
 +                      else continue;  // can happen when texco defines disappear and it renders old files
 +
 +                      texres.nor= NULL;
 +                      
 +                      if(tex->type==TEX_IMAGE) {
 +                              continue;       /* not supported yet */                         
 +                              //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
 +                      }
 +                      else {
 +                              /* placement */
 +                              if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
 +                              else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
 +
 +                              if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
 +                              else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
 +
 +                              if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
 +                              else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
 +                      }
 +                      
 +                      rgbnor= multitex(tex, texvec, NULL, NULL, 0, &texres, 0, mtex->which_output);   /* NULL = dxt/dyt, 0 = shi->osatex - not supported */
 +                      
 +                      /* texture output */
 +
 +                      if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
 +                              texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
 +                              rgbnor-= TEX_RGB;
 +                      }
 +                      if(mtex->texflag & MTEX_NEGATIVE) {
 +                              if(rgbnor & TEX_RGB) {
 +                                      texres.tr= 1.0-texres.tr;
 +                                      texres.tg= 1.0-texres.tg;
 +                                      texres.tb= 1.0-texres.tb;
 +                              }
 +                              texres.tin= 1.0-texres.tin;
 +                      }
 +                      if(mtex->texflag & MTEX_STENCIL) {
 +                              if(rgbnor & TEX_RGB) {
 +                                      fact= texres.ta;
 +                                      texres.ta*= stencilTin;
 +                                      stencilTin*= fact;
 +                              }
 +                              else {
 +                                      fact= texres.tin;
 +                                      texres.tin*= stencilTin;
 +                                      stencilTin*= fact;
 +                              }
 +                      }
 +                      
 +                      
 +                      if((mapto_flag & (MAP_EMISSION_COL+MAP_ABSORPTION_COL)) && (mtex->mapto & (MAP_EMISSION_COL+MAP_ABSORPTION_COL))) {
 +                              float tcol[3], colfac;
 +                              
 +                              /* stencil maps on the texture control slider, not texture intensity value */
 +                              colfac= mtex->colfac*stencilTin;
 +                              
 +                              if((rgbnor & TEX_RGB)==0) {
 +                                      tcol[0]= mtex->r;
 +                                      tcol[1]= mtex->g;
 +                                      tcol[2]= mtex->b;
 +                              } else {
 +                                      tcol[0]=texres.tr;
 +                                      tcol[1]=texres.tg;
 +                                      tcol[2]=texres.tb;
 +                                      if(texres.talpha)
 +                                              texres.tin= texres.ta;
 +                              }
 +                              
 +                              /* inverse gamma correction */
 +                              if (R.r.color_mgt_flag & R_COLOR_MANAGEMENT) {
 +                                      color_manage_linearize(tcol, tcol);
 +                              }
 +                              
 +                              /* used for emit */
 +                              if((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) {
 +                                      texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype);
 +                              }
 +                              
 +                              /* MAP_COLMIR is abused for absorption colour at the moment */
 +                              if((mapto_flag & MAP_ABSORPTION_COL) && (mtex->mapto & MAP_ABSORPTION_COL)) {
 +                                      texture_rgb_blend(col, tcol, col, texres.tin, colfac, mtex->blendtype);
 +                              }
 +                      }
 +                      
 +                      if((mapto_flag & MAP_VARS) && (mtex->mapto & MAP_VARS)) {
 +                              /* stencil maps on the texture control slider, not texture intensity value */
 +                              float varfac= mtex->varfac*stencilTin;
 +                              
 +                              /* convert RGB to intensity if intensity info isn't provided */
 +                              if (!(rgbnor & TEX_INT)) {
 +                                      if (rgbnor & TEX_RGB) {
 +                                              if(texres.talpha) texres.tin= texres.ta;
 +                                              else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
 +                                      }
 +                              }
 +                              
 +                              if((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) {
 +                                      int flip= mtex->maptoneg & MAP_EMISSION;
 +
 +                                      *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip);
 +                                      if(*val<0.0) *val= 0.0;
 +                              }
 +                              if((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) {
 +                                      int flip= mtex->maptoneg & MAP_DENSITY;
 +
 +                                      *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip);
 +                                      CLAMP(*val, 0.0, 1.0);
 +                              }
 +                              if((mapto_flag & MAP_ABSORPTION) && (mtex->mapto & MAP_ABSORPTION)) {
 +                                      int flip= mtex->maptoneg & MAP_ABSORPTION;
 +                                      
 +                                      *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip);
 +                                      CLAMP(*val, 0.0, 1.0);
 +                              }
 +                              if((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) {
 +                                      int flip= mtex->maptoneg & MAP_SCATTERING;
 +                                      
 +                                      *val = texture_value_blend(mtex->def_var, *val, texres.tin, varfac, mtex->blendtype, flip);
 +                                      CLAMP(*val, 0.0, 1.0);
 +                              }
 +                      }
 +              }
 +      }
 +}
 +
 +
  /* ------------------------------------------------------------------------- */
  
  void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)