diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-12-27 04:38:23 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-12-27 04:38:23 +0300 |
commit | 3ead3c4ff3a438202a9838843ed4000b26de62a7 (patch) | |
tree | 868c64cfcf2a5358a181f2cb88d8a534436ab9bd /source/blender/render | |
parent | 2d1bc90eedf933820bcff744706fd16a80d1d1cb (diff) | |
parent | c4a56fda6d64faa3de7d99b29843c8affb6d5156 (diff) |
Merged changes in the trunk up to revision 33894.
A note for branch users: CMake 2.8 on 64-bit Windows Vista raised
an error in line 948 of soc-2008-mxcurioni/CMakeLists.txt due to
an invalid argument for the blender_include_dirs macro:
blender_include_dirs(${OPENGL_INCLUDE_DIR})
The command above should be:
blender_include_dirs("${OPENGL_INCLUDE_DIR}")
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 4 | ||||
-rw-r--r-- | source/blender/render/intern/include/strand.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 19 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/renderdatabase.c | 16 | ||||
-rw-r--r-- | source/blender/render/intern/source/sss.c | 10 | ||||
-rw-r--r-- | source/blender/render/intern/source/strand.c | 38 | ||||
-rw-r--r-- | source/blender/render/intern/source/zbuf.c | 18 |
9 files changed, 78 insertions, 35 deletions
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 82e5b7511a4..ddb7d56ca71 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -128,4 +128,4 @@ if(APPLE) endif() endif() -blenderlib_nolist(bf_render "${SRC}" "${INC}") +blender_add_lib_nolist(bf_render "${SRC}" "${INC}") diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 8bdfab607f0..1de918de749 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -435,7 +435,9 @@ typedef struct StrandBuffer { int overrideuv; int flag, maxdepth; float adaptcos, minwidth, widthfade; - + + float maxwidth; /* for cliptest of strands in blender unit */ + float winmat[4][4]; int winx, winy; } StrandBuffer; diff --git a/source/blender/render/intern/include/strand.h b/source/blender/render/intern/include/strand.h index 66a5a7d1a0f..ffb2b8aa809 100644 --- a/source/blender/render/intern/include/strand.h +++ b/source/blender/render/intern/include/strand.h @@ -90,7 +90,7 @@ typedef struct StrandShadeCache StrandShadeCache; void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint); void render_strand_segment(struct Render *re, float winmat[][4], struct StrandPart *spart, struct ZSpan *zspan, int totzspan, StrandSegment *sseg); -void strand_minmax(struct StrandRen *strand, float *min, float *max); +void strand_minmax(struct StrandRen *strand, float *min, float *max, float width); struct StrandSurface *cache_strand_surface(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[][4], int timeoffset); void free_strand_surface(struct Render *re); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index b851728653a..adb386f80fb 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -924,7 +924,7 @@ static Material *give_render_material(Render *re, Object *ob, int nr) if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; - /* for light groups */ + /* for light groups and SSS */ ma->flag |= MA_IS_USED; if(ma->nodetree && ma->use_nodes) @@ -2380,7 +2380,10 @@ static void init_render_mball(Render *re, ObjectRen *obr) normalize_v3(ver->n); //if(ob->transflag & OB_NEG_SCALE) negate_v3(ver->n); - if(need_orco) ver->orco= orco+=3; + if(need_orco) { + ver->orco= orco; + orco+=3; + } } index= dl->index; @@ -4173,13 +4176,23 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset) } if(obr->strandbuf) { + float width; + + /* compute average bounding box of strandpoint itself (width) */ + if(obr->strandbuf->flag & R_STRAND_B_UNITS) + obr->strandbuf->maxwidth= MAX2(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end); + else + obr->strandbuf->maxwidth= 0.0f; + + width= obr->strandbuf->maxwidth; sbound= obr->strandbuf->bound; for(b=0; b<obr->strandbuf->totbound; b++, sbound++) { + INIT_MINMAX(smin, smax); for(a=sbound->start; a<sbound->end; a++) { strand= RE_findOrAddStrand(obr, a); - strand_minmax(strand, smin, smax); + strand_minmax(strand, smin, smax, width); } VECCOPY(sbound->boundbox[0], smin); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 1c0ce7de5d7..8af3c49213d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2061,7 +2061,7 @@ static void load_backbuffer(Render *re) char name[256]; strcpy(name, re->r.backbuf); - BLI_path_abs(name, G.main->name); + BLI_path_abs(name, re->main->name); BLI_path_frame(name, re->r.cfra, 0); if(re->backbuf) { @@ -2870,7 +2870,7 @@ static void update_physics_cache(Render *re, Scene *scene, int UNUSED(anim_init) baker.break_data = re->tbh; baker.progressbar = NULL; - BKE_ptcache_make_cache(&baker); + BKE_ptcache_bake(&baker); } /* evaluating scene options for general Blender render */ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, unsigned int lay, int anim, int anim_init) diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index db8b0b2c1fd..2da2f3633c3 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1398,19 +1398,21 @@ int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4]) fl= 0; if(bounds) { - if(vec[0] > bounds[1]*vec[3]) fl |= 1; - if(vec[0]< bounds[0]*vec[3]) fl |= 2; + if(vec[0] < bounds[0]*vec[3]) fl |= 1; + else if(vec[0] > bounds[1]*vec[3]) fl |= 2; + if(vec[1] > bounds[3]*vec[3]) fl |= 4; - if(vec[1]< bounds[2]*vec[3]) fl |= 8; + else if(vec[1]< bounds[2]*vec[3]) fl |= 8; } else { if(vec[0] < -vec[3]) fl |= 1; - if(vec[0] > vec[3]) fl |= 2; - if(vec[1] < -vec[3]) fl |= 4; - if(vec[1] > vec[3]) fl |= 8; + else if(vec[0] > vec[3]) fl |= 2; + + if(vec[1] > vec[3]) fl |= 4; + else if(vec[1] < -vec[3]) fl |= 8; } if(vec[2] < -vec[3]) fl |= 16; - if(vec[2] > vec[3]) fl |= 32; + else if(vec[2] > vec[3]) fl |= 32; flag &= fl; if(flag==0) return 0; diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 1e8709d09f7..4bccb46d3d8 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -56,6 +56,7 @@ #include "DNA_material_types.h" #include "BKE_colortools.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_node.h" @@ -995,6 +996,15 @@ void make_sss_tree(Render *re) for(mat= re->main->mat.first; mat; mat= mat->id.next) if(mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) sss_create_tree_mat(re, mat); + + /* XXX preview exception */ + /* localizing preview render data is not fun for node trees :( */ + if(re->main!=G.main) { + for(mat= G.main->mat.first; mat; mat= mat->id.next) + if(mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) + sss_create_tree_mat(re, mat); + } + } void free_sss(Render *re) diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index be17d640b66..fbbeceeea2c 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -578,7 +578,8 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float } } -static int strand_test_clip(float winmat[][4], ZSpan *zspan, float *bounds, float *co, float *zcomp) +/* width is calculated in hoco space, to ensure strands are visible */ +static int strand_test_clip(float winmat[][4], ZSpan *zspan, float *bounds, float *co, float *zcomp, float widthx, float widthy) { float hoco[4]; int clipflag= 0; @@ -588,10 +589,11 @@ static int strand_test_clip(float winmat[][4], ZSpan *zspan, float *bounds, floa /* we compare z without perspective division for segment sorting */ *zcomp= hoco[2]; - if(hoco[0] > bounds[1]*hoco[3]) clipflag |= 1; - else if(hoco[0]< bounds[0]*hoco[3]) clipflag |= 2; - else if(hoco[1] > bounds[3]*hoco[3]) clipflag |= 4; - else if(hoco[1]< bounds[2]*hoco[3]) clipflag |= 8; + if(hoco[0]+widthx < bounds[0]*hoco[3]) clipflag |= 1; + else if(hoco[0]-widthx > bounds[1]*hoco[3]) clipflag |= 2; + + if(hoco[1]-widthy > bounds[3]*hoco[3]) clipflag |= 4; + else if(hoco[1]+widthy < bounds[2]*hoco[3]) clipflag |= 8; clipflag |= testclip(hoco); @@ -826,6 +828,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa /* for all object instances */ for(obi=re->instancetable.first, i=0; obi; obi=obi->next, i++) { Material *ma; + float widthx, widthy; obr= obi->obr; @@ -848,6 +851,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa if(clip_render_object(obi->obr->boundbox, bounds, winmat)) continue; + + widthx= obr->strandbuf->maxwidth*obwinmat[0][0]; + widthy= obr->strandbuf->maxwidth*obwinmat[1][1]; /* for each bounding box containing a number of strands */ sbound= obr->strandbuf->bound; @@ -861,14 +867,14 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa svert= strand->vert; /* keep clipping and z depth for 4 control points */ - clip[1]= strand_test_clip(obwinmat, &zspan, bounds, svert->co, &z[1]); - clip[2]= strand_test_clip(obwinmat, &zspan, bounds, (svert+1)->co, &z[2]); + clip[1]= strand_test_clip(obwinmat, &zspan, bounds, svert->co, &z[1], widthx, widthy); + clip[2]= strand_test_clip(obwinmat, &zspan, bounds, (svert+1)->co, &z[2], widthx, widthy); clip[0]= clip[1]; z[0]= z[1]; for(b=0; b<strand->totvert-1; b++, svert++) { /* compute 4th point clipping and z depth */ if(b < strand->totvert-2) { - clip[3]= strand_test_clip(obwinmat, &zspan, bounds, (svert+2)->co, &z[3]); + clip[3]= strand_test_clip(obwinmat, &zspan, bounds, (svert+2)->co, &z[3], widthx, widthy); } else { clip[3]= clip[2]; z[3]= z[2]; @@ -1025,12 +1031,22 @@ void free_strand_surface(Render *re) BLI_freelistN(&re->strandsurface); } -void strand_minmax(StrandRen *strand, float *min, float *max) +void strand_minmax(StrandRen *strand, float *min, float *max, float width) { StrandVert *svert; + float vec[3], width2= 2.0f*width; int a; - for(a=0, svert=strand->vert; a<strand->totvert; a++, svert++) - DO_MINMAX(svert->co, min, max) + for(a=0, svert=strand->vert; a<strand->totvert; a++, svert++) { + VECCOPY(vec, svert->co); + DO_MINMAX(vec, min, max); + + if(width!=0.0f) { + vec[0]+= width; vec[1]+= width; vec[2]+= width; + DO_MINMAX(vec, min, max); + vec[0]-= width2; vec[1]-= width2; vec[2]-= width2; + DO_MINMAX(vec, min, max); + } + } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 1a52bc36482..1cdb93f0c1f 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -243,14 +243,14 @@ int testclip(float *v) prevents issues with vertices lying exact on borders */ abs4= fabs(v[3]) + FLT_EPSILON; - if(v[2]< -abs4) c=16; /* this used to be " if(v[2]<0) ", see clippz() */ - else if(v[2]> abs4) c+= 32; + if( v[0] < -abs4) c+=1; + else if( v[0] > abs4) c+=2; - if( v[0]>abs4) c+=2; - else if( v[0]< -abs4) c+=1; + if( v[1] > abs4) c+=4; + else if( v[1] < -abs4) c+=8; - if( v[1]>abs4) c+=4; - else if( v[1]< -abs4) c+=8; + if(v[2] < -abs4) c+=16; /* this used to be " if(v[2]<0) ", see clippz() */ + else if(v[2]> abs4) c+= 32; return c; } @@ -1782,10 +1782,10 @@ static int zbuf_part_project(ZbufProjectCache *cache, int index, float winmat[][ projectvert(co, winmat, ho); wco= ho[3]; - if(ho[0] > bounds[1]*wco) clipflag |= 1; - else if(ho[0]< bounds[0]*wco) clipflag |= 2; + if(ho[0] < bounds[0]*wco) clipflag |= 1; + else if(ho[0] > bounds[1]*wco) clipflag |= 2; if(ho[1] > bounds[3]*wco) clipflag |= 4; - else if(ho[1]< bounds[2]*wco) clipflag |= 8; + else if(ho[1] < bounds[2]*wco) clipflag |= 8; QUATCOPY(cache[cindex].ho, ho); cache[cindex].clip= clipflag; |