svn merge -r 16866:17042 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender-staging.git] / source / blender / render / intern / source / convertblender.c
index 2d229cb33878568cdbbaf1646121e06d4b08d595..4b663c6caa65e114f09372e6b63b99cbdd1b9958 100644 (file)
@@ -41,6 +41,7 @@
 #include "BLI_rand.h"
 #include "BLI_memarena.h"
 #include "BLI_ghash.h"
+#include "BLI_kdtree.h"
 
 #include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
 #include "envmap.h"
 #include "multires.h"
 #include "occlusion.h"
+#include "pointdensity.h"
 #include "render_types.h"
 #include "rendercore.h"
 #include "renderdatabase.h"
@@ -921,6 +923,28 @@ static void flag_render_node_material(Render *re, bNodeTree *ntree)
        }
 }
 
+static void check_material_is_textured(Material *ma)
+{
+       MTex *mtex;
+       Tex *tex;
+       int tex_nr;
+       
+       for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
+               if(ma->septex & (1<<tex_nr))
+                       continue;
+               
+               if(ma->mtex[tex_nr]) {
+                       mtex= ma->mtex[tex_nr];
+                       tex= mtex->tex;
+                       if(tex==NULL)
+                               continue;
+                       else
+                               ma->flag |= MA_IS_TEXTURED;
+                               return;
+               }
+       }
+}
+
 static Material *give_render_material(Render *re, Object *ob, int nr)
 {
        extern Material defmaterial;    /* material.c */
@@ -941,6 +965,10 @@ static Material *give_render_material(Render *re, Object *ob, int nr)
        if(ma->nodetree && ma->use_nodes)
                flag_render_node_material(re, ma->nodetree);
        
+       if (ma->material_type == MA_VOLUME) re->r.mode |= R_RAYTRACE;
+       
+       check_material_is_textured(ma);
+       
        return ma;
 }
 
@@ -2023,6 +2051,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset);
 
 /* 4. clean up */
+
        if(ma) do_mat_ipo(ma);
 
        if(orco1)
@@ -4408,6 +4437,8 @@ void RE_Database_Free(Render *re)
        end_radio_render();
        end_render_materials();
        
+       free_pointdensities(re);
+       
        if(re->wrld.aosphere) {
                MEM_freeN(re->wrld.aosphere);
                re->wrld.aosphere= NULL;
@@ -4858,6 +4889,10 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view)
                        /* ENVIRONMENT MAPS */
                        if(!re->test_break())
                                make_envmaps(re);
+                               
+                       /* point density texture */
+                       if(!re->test_break())
+                               make_pointdensities(re);
                }
                
                if(!re->test_break())