svn merge -r 21508:22111 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
authorAndre Susano Pinto <andresusanopinto@gmail.com>
Sat, 1 Aug 2009 10:21:26 +0000 (10:21 +0000)
committerAndre Susano Pinto <andresusanopinto@gmail.com>
Sat, 1 Aug 2009 10:21:26 +0000 (10:21 +0000)
1  2 
release/ui/buttons_scene.py
source/blender/blenkernel/BKE_utildefines.h
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/editors/armature/meshlaplacian.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/render/SConscript
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/shadeinput.c

@@@ -44,34 -135,123 +135,125 @@@ class SCENE_PT_shading(RenderButtonsPan
                split = layout.split()
                
                col = split.column()
-               col.itemR(rd, "file_extensions")                
-               col.itemR(rd, "fields", text="Fields")
-               colsub = col.column()
-               colsub.active = rd.fields
-               colsub.itemR(rd, "fields_still", text="Still")
-               colsub.row().itemR(rd, "field_order", expand=True)
+               col.itemR(rd, "render_textures", text="Textures")
+               col.itemR(rd, "render_shadows", text="Shadows")
+               col.itemR(rd, "render_sss", text="Subsurface Scattering")
+               col.itemR(rd, "render_envmaps", text="Environment Map")
                
                col = split.column()
-               col.itemR(rd, "color_mode")
-               col.itemR(rd, "alpha_mode")
-               col.itemL(text="Distributed Rendering:")
-               col.itemR(rd, "placeholders")
-               col.itemR(rd, "no_overwrite")
+               col.itemR(rd, "render_raytracing", text="Ray Tracing")
+               col.itemR(rd, "color_management")
+               col.itemR(rd, "alpha_mode", text="Alpha")
+ class SCENE_PT_performance(RenderButtonsPanel):
+       __label__ = "Performance"
+       __default_closed__ = True
+       COMPAT_ENGINES = set(['BLENDER_RENDER'])
+       def draw(self, context):
+               layout = self.layout
                
-               layout.itemR(rd, "file_format", text="Format")
+               rd = context.scene.render_data
+               split = layout.split()
                
+               col = split.column(align=True)
+               col.itemL(text="Threads:")
+               col.row().itemR(rd, "threads_mode", expand=True)
+               sub = col.column()
+               sub.enabled = rd.threads_mode == 'THREADS_FIXED'
+               sub.itemR(rd, "threads")
+               col = split.column(align=True)
+               col.itemL(text="Tiles:")
+               col.itemR(rd, "parts_x", text="X")
+               col.itemR(rd, "parts_y", text="Y")
                split = layout.split()
+               col = split.column()
+               col.itemL(text="Memory:")
+               row = col.row()
+               row.itemR(rd, "save_buffers")
+               row.enabled = not rd.full_sample
+               col = split.column()
+               col.active = rd.use_compositing
+               col.itemL()
+               col.itemR(rd, "free_image_textures")
+               row = layout.row()
+               row.active = rd.render_raytracing
+               row.itemR(rd, "octree_resolution", text="Ray Tracing Octree")
++              row.itemR(rd, "raytrace_structure", text="Structure")
++              row.itemR(rd, "raytrace_tree_type", text="Tree Type")
+ class SCENE_PT_post_processing(RenderButtonsPanel):
+       __label__ = "Post Processing"
+       __default_closed__ = True
+       COMPAT_ENGINES = set(['BLENDER_RENDER'])
+       def draw(self, context):
+               layout = self.layout
                
+               rd = context.scene.render_data
+               split = layout.split()
+               col = split.column()
+               col.itemR(rd, "use_compositing")
+               col.itemR(rd, "use_sequencer")
                col = split.column()
+               row = col.row()
+               row.itemR(rd, "fields", text="Fields")
+               sub = row.row()
+               sub.active = rd.fields
+               sub.itemR(rd, "fields_still", text="Still")
+               sub = col.row()
+               sub.active = rd.fields
+               sub.itemR(rd, "field_order", expand=True)
+               split = layout.split()
+               split.itemL()
+               split.itemR(rd, "dither_intensity", text="Dither", slider=True)
+               
+ class SCENE_PT_output(RenderButtonsPanel):
+       __label__ = "Output"
+       COMPAT_ENGINES = set(['BLENDER_RENDER'])
+       def draw(self, context):
+               layout = self.layout
                
+               rd = context.scene.render_data
+               
+               layout.itemR(rd, "output_path", text="")
+               split = layout.split()
+               col = split.column()
+               col.itemR(rd, "file_format", text="")
+               col.row().itemR(rd, "color_mode", text="Color", expand=True)
+               col = split.column()
+               col.itemR(rd, "file_extensions")
+               col.itemR(rd, "placeholders")
+               col.itemR(rd, "no_overwrite")
                if rd.file_format in ('AVIJPEG', 'JPEG'):
-                       col.itemR(rd, "quality", slider=True)
+                       split = layout.split()
+                       split.itemR(rd, "quality", slider=True)
                        
                elif rd.file_format == 'OPENEXR':
+                       split = layout.split()
+                       
+                       col = split.column()
                        col.itemR(rd, "exr_codec")
+                       subsplit = split.split()
+                       col = subsplit.column()
                        col.itemR(rd, "exr_half")
-                       col = split.column()
                        col.itemR(rd, "exr_zbuf")
+                       col = subsplit.column()
                        col.itemR(rd, "exr_preview")
                
                elif rd.file_format == 'JPEG2000':
@@@ -1425,12 -1404,10 +1425,11 @@@ int BLI_bvhtree_find_nearest(BVHTree *t
   * raycast is done by performing a DFS on the BVHTree and saving the closest hit
   */
  
 +
  //Determines the distance that the ray must travel to hit the bounding volume of the given node
- static float ray_nearest_hit(BVHRayCastData *data, BVHNode *node)
+ static float ray_nearest_hit(BVHRayCastData *data, float *bv)
  {
        int i;
-       const float *bv = node->bv;
  
        float low = 0, upper = data->hit.dist;
  
@@@ -237,11 -234,8 +236,11 @@@ typedef struct RenderData 
         */
        int mode;
  
-       /* render engine, octree resolution */
+       /* render engine (deprecated), octree resolution */
        short renderer, ocres;
 +      short raystructure;
 +      short raytrace_tree_type;
 +      short pad4[2];
  
        /**
         * What to do with the sky/background. Picks sky/premul/key
@@@ -3,9 -3,8 +3,9 @@@ Import ('env'
  
  cflags=''
  sources = env.Glob('intern/source/*.c')
 +raysources = env.Glob('intern/raytrace/*.cpp')
  
- incs = 'intern/include #/intern/guardedalloc ../blenlib ../makesdna'
+ incs = 'intern/include #/intern/guardedalloc ../blenlib ../makesdna ../makesrna'
  incs += ' extern/include ../blenkernel ../radiosity/extern/include ../imbuf'
  incs += ' ../include ../blenloader'
  
@@@ -107,186 -94,113 +107,186 @@@ static int vlr_check_intersect(Isect *i
        else
                return (is->lay & obi->lay);
  }
 +#endif
  
 -static float *vlr_get_transform(void *userdata, int i)
 +void freeraytree(Render *re)
  {
 -      ObjectInstanceRen *obi= RAY_OBJECT_GET((Render*)userdata, i);
 +      ObjectInstanceRen *obi;
 +      
 +      if(re->raytree)
 +      {
 +              RE_rayobject_free(re->raytree);
 +              re->raytree = NULL;
 +      }
 +      if(re->rayfaces)
 +      {
 +              MEM_freeN(re->rayfaces);
 +              re->rayfaces = NULL;
 +      }
  
 -      return (obi->flag & R_TRANSFORMED)? (float*)obi->mat: NULL;
 +      for(obi=re->instancetable.first; obi; obi=obi->next)
 +      {
 +              ObjectRen *obr = obi->obr;
 +              if(obr->raytree)
 +              {
 +                      RE_rayobject_free(obr->raytree);
 +                      obr->raytree = NULL;
 +              }
 +              if(obr->rayfaces)
 +              {
 +                      MEM_freeN(obr->rayfaces);
 +                      obr->rayfaces = NULL;
 +              }
 +              if(obi->raytree)
 +              {
 +                      RE_rayobject_free(obi->raytree);
 +                      obi->raytree = NULL;
 +              }
 +      }
 +      
 +#ifdef RE_RAYCOUNTER
 +      {
 +              RayCounter sum = {};
 +              int i;
 +              for(i=0; i<BLENDER_MAX_THREADS; i++)
 +                      RE_RC_MERGE(&sum, re_rc_counter+i);
 +              RE_RC_INFO(&sum);
 +      }
 +#endif
  }
  
 -void freeraytree(Render *re)
 +static int is_raytraceable_vlr(Render *re, VlakRen *vlr)
  {
 -      if(re->raytree) {
 -              RE_ray_tree_free(re->raytree);
 -              re->raytree= NULL;
 -      }
 +      if((re->flag & R_BAKE_TRACE) || (vlr->mat->mode & MA_TRACEBLE))
-       if((vlr->mat->mode & MA_WIRE)==0)
++      if(vlr->mat->material_type != MA_TYPE_WIRE)
 +              return 1;
 +      return 0;
  }
  
 -void makeraytree(Render *re)
 +static int is_raytraceable(Render *re, ObjectInstanceRen *obi)
  {
 -      ObjectInstanceRen *obi;
 -      ObjectRen *obr;
 -      VlakRen *vlr= NULL;
 -      float min[3], max[3], co1[3], co2[3], co3[3], co4[3];
 -      double lasttime= PIL_check_seconds_timer();
 -      int v, totv = 0, totface = 0;
 +      int v;
 +      ObjectRen *obr = obi->obr;
  
 -      INIT_MINMAX(min, max);
 -
 -      /* first min max raytree space */
 -      for(obi=re->instancetable.first; obi; obi=obi->next) {
 -              obr= obi->obr;
 -
 -              if(re->excludeob && obr->ob == re->excludeob)
 -                      continue;
 -
 -              for(v=0;v<obr->totvlak;v++) {
 -                      if((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak;
 -                      else vlr++;
 -                      /* baking selected to active needs non-traceable too */
 -                      if((re->flag & R_BAKE_TRACE) || (vlr->mat->mode & MA_TRACEBLE)) {       
 -                              if(vlr->mat->material_type != MA_TYPE_WIRE) {
 -                                      VECCOPY(co1, vlr->v1->co);
 -                                      VECCOPY(co2, vlr->v2->co);
 -                                      VECCOPY(co3, vlr->v3->co);
 -
 -                                      if(obi->flag & R_TRANSFORMED) {
 -                                              Mat4MulVecfl(obi->mat, co1);
 -                                              Mat4MulVecfl(obi->mat, co2);
 -                                              Mat4MulVecfl(obi->mat, co3);
 -                                      }
 +      if(re->excludeob && obr->ob == re->excludeob)
 +              return 0;
  
 -                                      DO_MINMAX(co1, min, max);
 -                                      DO_MINMAX(co2, min, max);
 -                                      DO_MINMAX(co3, min, max);
 +      for(v=0;v<obr->totvlak;v++)
 +      {
 +              VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
 +              if(is_raytraceable_vlr(re, vlr))
 +                      return 1;
 +      }
 +      return 0;
 +}
  
 -                                      if(vlr->v4) {
 -                                              VECCOPY(co4, vlr->v4->co);
 -                                              if(obi->flag & R_TRANSFORMED)
 -                                                      Mat4MulVecfl(obi->mat, co4);
 -                                              DO_MINMAX(co4, min, max);
 -                                      }
 +RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi)
 +{
 +      //TODO
 +      // out-of-memory safeproof
 +      // break render
 +      // update render stats
 +      ObjectRen *obr = obi->obr;
 +      
 +      if(obr->raytree == NULL)
 +      {
 +              RayObject *raytree;
 +              RayFace *face;
 +              int v;
 +              
 +              //Count faces
 +              int faces = 0;
 +              for(v=0;v<obr->totvlak;v++)
 +              {
 +                      VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
 +                      if(is_raytraceable_vlr(re, vlr))
 +                              faces++;
 +              }
 +              assert( faces > 0 );
  
 -                                      totface++;
 -                              }
 +              //Create Ray cast accelaration structure
 +              
 +              //TODO dynamic ocres
 +              if(re->r.raystructure == R_RAYSTRUCTURE_HIER_BVH_OCTREE)
 +                      raytree = obr->raytree = RE_rayobject_octree_create( re->r.ocres, faces );
 +              else //if(re->r.raystructure == R_RAYSTRUCTURE_HIER_BVH_BVH)
 +                      raytree = obr->raytree = RE_rayobject_tree_create( re->r.raytrace_tree_type, faces );
 +                      
 +              face = obr->rayfaces = (RayFace*)MEM_callocN(faces*sizeof(RayFace), "ObjectRen faces");
 +              obr->rayobi = obi;
 +              
 +              for(v=0;v<obr->totvlak;v++)
 +              {
 +                      VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
 +                      if(is_raytraceable_vlr(re, vlr))
 +                      {
 +                              face->v1 = vlr->v1->co;
 +                              face->v2 = vlr->v2->co;
 +                              face->v3 = vlr->v3->co;
 +                              face->v4 = vlr->v4 ? vlr->v4->co : NULL;
 +                              
 +                              face->ob   = obi;
 +                              face->face = vlr;
 +                              
 +                              RE_rayobject_add( raytree, RayObject_unalignRayFace(face) );
 +                              
 +                              face++;
                        }
                }
 +              RE_rayobject_done( raytree );
        }
  
 -      re->raytree= RE_ray_tree_create(re->r.ocres, totface, min, max,
 -              vlr_face_coords, vlr_check_intersect, vlr_get_transform, re);
  
 -      if(min[0] > max[0]) { /* empty raytree */
 -              RE_ray_tree_done(re->raytree);
 -              return; 
 +      if(obi->flag & R_TRANSFORMED)
 +      {
 +              obi->raytree = RE_rayobject_instance_create( obr->raytree, obi->mat, obi, obi->obr->rayobi );
        }
 +      
 +      if(obi->raytree) return obi->raytree;
 +      return obi->obr->raytree;
 +}
  
 -      for(obi=re->instancetable.first; obi; obi=obi->next) {
 -              obr= obi->obr;
 +/*
 + * create an hierarchic raytrace structure with all objects
 + *
 + * R_TRANSFORMED objects instances reuse the same tree by using the rayobject_instance
 + */
 +static void makeraytree_hier(Render *re)
 +{
 +      //TODO
 +      // out-of-memory safeproof
 +      // break render
 +      // update render stats
  
 -              if(re->excludeob && obr->ob == re->excludeob)
 -                      continue;
 +      ObjectInstanceRen *obi;
 +      int num_objects = 0;
  
 -              for(v=0; v<obr->totvlak; v++, totv++) {
 -                      if((v & 255)==0) {
 -                              double time= PIL_check_seconds_timer();
 +      re->i.infostr="Creating raytrace structure";
 +      re->stats_draw(re->sdh, &re->i);
  
 -                              vlr= obr->vlaknodes[v>>8].vlak;
 -                              if(re->test_break(re->tbh))
 -                                      break;
 -                              if(time-lasttime>1.0f) {
 -                                      char str[32];
 -                                      sprintf(str, "Filling Octree: %d", totv);
 -                                      re->i.infostr= str;
 -                                      re->stats_draw(re->sdh, &re->i);
 -                                      re->i.infostr= NULL;
 -                                      lasttime= time;
 -                              }
 -                      }
 -                      else vlr++;
 -                      
 -                      if((re->flag & R_BAKE_TRACE) || (vlr->mat->mode & MA_TRACEBLE))
 -                              if(vlr->mat->material_type != MA_TYPE_WIRE)
 -                                      RE_ray_tree_add_face(re->raytree, RAY_OBJECT_SET(re, obi), vlr);
 -              }
 -      }
 +      //Count number of objects
 +      for(obi=re->instancetable.first; obi; obi=obi->next)
 +      if(is_raytraceable(re, obi))
 +              num_objects++;
  
 -      RE_ray_tree_done(re->raytree);
 +      //Create raytree
 +      re->raytree = RE_rayobject_tree_create( re->r.raytrace_tree_type, num_objects );
        
 +      for(obi=re->instancetable.first; obi; obi=obi->next)
 +      if(is_raytraceable(re, obi))
 +      {
 +              RayObject *obj = makeraytree_object(re, obi);
 +              RE_rayobject_add( re->raytree, obj );
 +
 +              if(re->test_break(re->tbh))
 +                      break;
 +      }
 +
 +      if(!re->test_break(re->tbh))
 +      {
 +              RE_rayobject_done( re->raytree );
 +      }
 +
        re->i.infostr= NULL;
        re->stats_draw(re->sdh, &re->i);
  }