diff options
Diffstat (limited to 'source/blender/render')
18 files changed, 351 insertions, 405 deletions
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 0b659554d1a..8ba7dc123e7 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -29,7 +29,7 @@ FILE(GLOB SRC intern/source/*.c) SET(INC intern/include ../../../intern/guardedalloc ../blenlib ../makesdna extern/include ../blenkernel ../radiosity/extern/include ../imbuf - ../quicktime ../include ../../kernel/gen_messaging ../yafray ../blenloader + ../quicktime ../include ../../kernel/gen_messaging ../blenloader ) IF(WITH_OPENEXR) diff --git a/source/blender/render/SConscript b/source/blender/render/SConscript index 50c4b554193..173f5db8482 100644 --- a/source/blender/render/SConscript +++ b/source/blender/render/SConscript @@ -10,11 +10,6 @@ incs += ' ../include ../blenloader' defs = [] -if env['WITH_BF_YAFRAY']: - incs += ' ../yafray' -else: - defs.append('DISABLE_YAFRAY') - if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') incs += ' ../quicktime ' + env['BF_QUICKTIME_INC'] @@ -28,4 +23,4 @@ if env['WITH_BF_OPENEXR']: if env['OURPLATFORM']=='linux2': cflags='-pthread' -env.BlenderLib ( libname = 'blender_render', sources = sources, includes = Split(incs), defines=defs, libtype='core', priority=45, compileflags=cflags ) +env.BlenderLib ( libname = 'bf_render', sources = sources, includes = Split(incs), defines=defs, libtype='core', priority=145, compileflags=cflags ) diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 60557403143..04f7d264229 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -124,10 +124,11 @@ typedef struct RenderResult { typedef struct RenderStats { + int cfra; int totface, totvert, totstrand, tothalo, totlamp, totpart; short curfield, curblur, curpart, partsdone, convertdone; double starttime, lastframetime; - char *infostr; + char *infostr, scenename[32]; } RenderStats; @@ -138,6 +139,9 @@ typedef struct RenderStats { struct Render *RE_NewRender (const char *name); struct Render *RE_GetRender(const char *name); +/* returns 1 while render is working (or renders called from within render) */ +int RE_RenderInProgress(struct Render *re); + /* use free render as signal to do everything over (previews) */ void RE_FreeRender (struct Render *re); /* only called on exit */ @@ -195,18 +199,17 @@ struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty) void RE_MergeFullSample(struct Render *re, struct Scene *sce, struct bNodeTree *ntree); /* ancient stars function... go away! */ -void RE_make_stars(struct Render *re, void (*initfunc)(void), +void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void), void (*vertexfunc)(float*), void (*termfunc)(void)); /* display and event callbacks */ -void RE_display_init_cb (struct Render *re, void (*f)(RenderResult *rr)); -void RE_display_clear_cb(struct Render *re, void (*f)(RenderResult *rr)); -void RE_display_draw_cb (struct Render *re, void (*f)(RenderResult *rr, volatile struct rcti *rect)); -void RE_stats_draw_cb (struct Render *re, void (*f)(RenderStats *rs)); -void RE_timecursor_cb (struct Render *re, void (*f)(int)); -void RE_test_break_cb (struct Render *re, int (*f)(void)); -void RE_test_return_cb (struct Render *re, int (*f)(void)); -void RE_error_cb (struct Render *re, void (*f)(char *str)); +void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); +void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); +void RE_display_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile struct rcti *rect)); +void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderStats *rs)); +void RE_timecursor_cb (struct Render *re, void *handle, void (*f)(void *handle, int)); +void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle)); +void RE_error_cb (struct Render *re, void *handle, void (*f)(void *handle, char *str)); /* should move to kernel once... still unsure on how/where */ float RE_filter_value(int type, float x); @@ -226,6 +229,7 @@ void RE_Database_Baking(struct Render *re, struct Scene *scene, int type, struct void RE_DataBase_GetView(struct Render *re, float mat[][4]); void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4]); +struct Scene *RE_GetScene(struct Render *re); #endif /* RE_PIPELINE_H */ diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index e61de5bc3e6..20eea0c98bd 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -35,7 +35,10 @@ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* called by meshtools */ -void RE_make_sticky(void); +struct View3D; +struct Scene; + +void RE_make_sticky(struct Scene *scene, struct View3D *v3d); /* for radiosity module */ struct RadView; diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 1768b052b54..ab3758781ce 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -113,7 +113,7 @@ struct Render char name[RE_MAXNAME]; /* state settings */ - short flag, osa, ok, do_gamma; + short flag, osa, ok, result_ok; /* result of rendering */ RenderResult *result; @@ -208,16 +208,23 @@ struct Render struct MemArena *memArena; /* callbacks */ - void (*display_init)(RenderResult *rr); - void (*display_clear)(RenderResult *rr); - void (*display_draw)(RenderResult *rr, volatile rcti *rect); + void (*display_init)(void *handle, RenderResult *rr); + void *dih; + void (*display_clear)(void *handle, RenderResult *rr); + void *dch; + void (*display_draw)(void *handle, RenderResult *rr, volatile rcti *rect); + void *ddh; - void (*stats_draw)(RenderStats *ri); - void (*timecursor)(int i); + void (*stats_draw)(void *handle, RenderStats *ri); + void *sdh; + void (*timecursor)(void *handle, int i); + void *tch; - int (*test_break)(void); - int (*test_return)(void); - void (*error)(char *str); + int (*test_break)(void *handle); + void *tbh; + + void (*error)(void *handle, char *str); + void *erh; RenderStats i; }; @@ -505,7 +512,6 @@ typedef struct LampRen { #define R_LAMPHALO 8 #define R_GLOB_NOPUNOFLIP 16 #define R_NEED_TANGENT 32 -#define R_SKIP_MULTIRES 64 #define R_BAKE_TRACE 128 #define R_BAKING 256 diff --git a/source/blender/render/intern/source/Makefile b/source/blender/render/intern/source/Makefile index a86da71e40d..22680b26338 100644 --- a/source/blender/render/intern/source/Makefile +++ b/source/blender/render/intern/source/Makefile @@ -45,11 +45,10 @@ CPPFLAGS += -I../../../imbuf CPPFLAGS += -I../../../makesdna CPPFLAGS += -I../../../blenkernel CPPFLAGS += -I../../../quicktime -CPPFLAGS += -I../../../yafray CPPFLAGS += -I../../../../kernel/gen_messaging CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # not very neat: the rest of blender.. -CPPFLAGS += -I../../../include +CPPFLAGS += -I../../../editors/include CPPFLAGS += $(NAN_SDLCFLAGS) ifeq ($(WITH_QUICKTIME), true) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 3c6b872a16d..98e5819c0d3 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -31,7 +31,6 @@ #include <string.h> #include <limits.h> -#include "blendef.h" #include "MTC_matrixops.h" #include "MEM_guardedalloc.h" @@ -100,7 +99,6 @@ #include "IMB_imbuf_types.h" #include "envmap.h" -#include "multires.h" #include "occlusion.h" #include "render_types.h" #include "rendercore.h" @@ -116,18 +114,6 @@ #include "zbuf.h" #include "sunsky.h" -#ifndef DISABLE_YAFRAY /* disable yafray */ - -#include "YafRay_Api.h" - -/* yafray: Identity transform 'hack' removed, exporter now transforms vertices back to world. - * Same is true for lamp coords & vec. - * Duplicated data objects & dupliframe/duplivert objects are only stored once, - * only the matrix is stored for all others, in yafray these objects are instances of the original. - * The main changes are in RE_Database_FromScene(). - */ - -#endif /* disable yafray */ /* 10 times larger than normal epsilon, test it on default nurbs sphere with ray_transp (for quad detection) */ /* or for checking vertex normal flips */ @@ -164,7 +150,7 @@ static HaloRen *initstar(Render *re, ObjectRen *obr, float *vec, float hasize) * differ in clarity/color */ -void RE_make_stars(Render *re, void (*initfunc)(void), +void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), void (*vertexfunc)(float*), void (*termfunc)(void)) { extern unsigned char hash[512]; @@ -180,8 +166,8 @@ void RE_make_stars(Render *re, void (*initfunc)(void), int x, y, z, sx, sy, sz, ex, ey, ez, done = 0; if(initfunc) { - scene= G.scene; - wrld= G.scene->world; + scene= scenev3d; + wrld= scene->world; } else { scene= re->scene; @@ -871,7 +857,7 @@ static float *get_object_orco(Render *re, Object *ob) if (!orco) { if (ELEM(ob->type, OB_CURVE, OB_FONT)) { - orco = make_orco_curve(ob); + orco = make_orco_curve(re->scene, ob); } else if (ob->type==OB_SURF) { orco = make_orco_surf(ob); } else if (ob->type==OB_MBALL) { @@ -960,7 +946,7 @@ ParticleStrandData; static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, float *vec, float *vec1) { static VertRen *v1= NULL, *v2= NULL; - VlakRen *vlr; + VlakRen *vlr= NULL; float nor[3], cross[3], crosslen, w, dx, dy, width; static float anor[3], avec[3]; int flag, i; @@ -1389,7 +1375,7 @@ static void render_new_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mat if(ma->mode&MA_WIRE) static_particle_wire(obr, ma, loc, loc1, sd->first, sd->line); - else if(ma->mode & MA_HALO){ + else if(ma->material_type == MA_TYPE_HALO) { har= RE_inithalo_particle(re, obr, dm, ma, loc, loc1, sd->orco, sd->uvco, sd->size, 1.0, seed); if(har) har->lay= obr->ob->lay; } @@ -1453,7 +1439,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem RNG *rng= 0; float loc[3],loc1[3],loc0[3],vel[3],mat[4][4],nmat[3][3],co[3],nor[3],time; float strandlen=0.0f, curlen=0.0f; - float hasize, pa_size, pa_time, r_tilt, cfra=bsystem_time(ob,(float)CFRA,0.0); + float hasize, pa_size, pa_time, r_tilt, cfra=bsystem_time(re->scene, ob, (float)re->scene->r.cfra, 0.0); float random, simplify[2]; int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0; int totchild=0; @@ -1473,7 +1459,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(part==NULL || pars==NULL || !psys_check_enabled(ob, psys)) return 0; - if(part->draw_as==PART_DRAW_OB || part->draw_as==PART_DRAW_GR || part->draw_as==PART_DRAW_NOT) + if(part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT) return 1; /* 2. start initialising things */ @@ -1505,10 +1491,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 2.1 setup material stff */ ma= give_render_material(re, ob, part->omat); +#if 0 // XXX old animation system if(ma->ipo){ calc_ipo(ma->ipo, cfra); execute_ipo((ID *)ma, ma->ipo); } +#endif // XXX old animation system hasize = ma->hasize; seed = ma->seed1; @@ -1534,7 +1522,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sd.mcol = MEM_callocN(sd.totcol * sizeof(MCol), "particle_mcols"); /* 2.2 setup billboards */ - if(part->draw_as == PART_DRAW_BB) { + if(part->ren_as == PART_DRAW_BB) { int first_uv = CustomData_get_layer_index(&psmd->dm->faceData, CD_MTFACE); bb.uv[0] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[0]); @@ -1562,14 +1550,16 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem bb.uv_split = part->bb_uv_split; } +#if 0 // XXX old animation system /* 2.3 setup time */ if(part->flag&PART_ABS_TIME && part->ipo) { calc_ipo(part->ipo, cfra); execute_ipo((ID *)part, part->ipo); } +#endif // XXX old animation system if(part->flag & PART_GLOB_TIME) - cfra = bsystem_time(0, (float)CFRA, 0.0); + cfra = bsystem_time(re->scene, 0, (float)re->scene->r.cfra, 0.0); /* 2.4 setup reactors */ if(part->type == PART_REACTOR){ @@ -1587,11 +1577,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem Mat3Transp(nmat); /* 2.6 setup strand rendering */ - if(part->draw_as == PART_DRAW_PATH && psys->pathcache){ + if(part->ren_as == PART_DRAW_PATH && psys->pathcache){ path_nbr=(int)pow(2.0,(double) part->ren_step); if(path_nbr) { - if((ma->mode & (MA_HALO|MA_WIRE))==0) { + if((ma->material_type != MA_TYPE_HALO) && (ma->mode & MA_WIRE)==0) { sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); set_object_orco(re, psys, sd.orco); } @@ -1655,7 +1645,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } if(path_nbr == 0) - psys->lattice = psys_get_lattice(ob, psys); + psys->lattice = psys_get_lattice(re->scene, ob, psys); /* 3. start creating renderable things */ for(a=0,pa=pars; a<totpart+totchild; a++, pa++, seed++) { @@ -1665,7 +1655,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(pa->flag & PARS_UNEXIST) continue; pa_time=(cfra-pa->time)/pa->lifetime; - if((part->flag&PART_ABS_TIME) == 0) { + if((part->flag&PART_ABS_TIME) == 0){ +#if 0 // XXX old animation system if(ma->ipo) { /* correction for lifetime */ calc_ipo(ma->ipo, 100.0f * pa_time); @@ -1676,6 +1667,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem calc_ipo(part->ipo, 100.0f*pa_time); execute_ipo((ID *)part, part->ipo); } +#endif // XXX old animation system } hasize = ma->hasize; @@ -1723,7 +1715,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem pa_time = psys_get_child_time(psys, cpa, cfra); if((part->flag & PART_ABS_TIME) == 0) { - if(ma->ipo) { +#if 0 // XXX old animation system + if(ma->ipo){ /* correction for lifetime */ calc_ipo(ma->ipo, 100.0f * pa_time); execute_ipo((ID *)ma, ma->ipo); @@ -1733,6 +1726,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem calc_ipo(part->ipo, 100.0f * pa_time); execute_ipo((ID *)part, part->ipo); } +#endif // XXX old animation system } pa_size = psys_get_child_size(psys, cpa, cfra, &pa_time); @@ -1889,14 +1883,14 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* render normal particles */ time=0.0f; state.time=cfra; - if(psys_get_particle_state(ob,psys,a,&state,0)==0) + if(psys_get_particle_state(re->scene,ob,psys,a,&state,0)==0) continue; VECCOPY(loc,state.co); - if(part->draw_as!=PART_DRAW_BB) + if(part->ren_as!=PART_DRAW_BB) MTC_Mat4MulVecfl(re->viewmat,loc); - switch(part->draw_as) { + switch(part->ren_as) { case PART_DRAW_LINE: sd.line = 1; sd.time = 0.0f; @@ -1945,7 +1939,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(orco1==0) sd.orco+=3; - if(re->test_break()) + if(re->test_break(re->tbh)) break; } @@ -1953,8 +1947,10 @@ 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 0 // XXX old animation system + if(ma) do_mat_ipo(re->scene, ma); +#endif // XXX old animation system + if(orco1) MEM_freeN(sd.orco); @@ -1975,8 +1971,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem psys->flag &= ~PSYS_DRAWING; if(psys->lattice){ - end_latt_deform(); - psys->lattice=0; + end_latt_deform(psys->lattice); + psys->lattice= NULL; } if(path_nbr && (ma->mode_l & MA_TANGENT_STR)==0) @@ -2279,7 +2275,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) float *data, *nors, *orco, mat[4][4], imat[3][3], xn, yn, zn; int a, need_orco, vlakindex, *index; - if (ob!=find_basis_mball(ob)) + if (ob!=find_basis_mball(re->scene, ob)) return; MTC_Mat4MulMat4(mat, ob->obmat, re->viewmat); @@ -2293,7 +2289,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) need_orco= 1; } - makeDispListMBall(ob); + makeDispListMBall(re->scene, ob); dl= ob->disp.first; if(dl==0) return; @@ -2565,7 +2561,7 @@ static void init_render_surf(Render *re, ObjectRen *obr) if(need_orco) orcobase= orco= get_object_orco(re, ob); displist.first= displist.last= 0; - makeDispListSurf(ob, &displist, 1, 0); + makeDispListSurf(re->scene, ob, &displist, 1, 0); dl= displist.first; /* walk along displaylist and create rendervertices/-faces */ @@ -2605,7 +2601,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) /* test displist */ if(cu->disp.first==NULL) - makeDispListCurveTypes(ob, 0); + makeDispListCurveTypes(re->scene, ob, 0); dl= cu->disp.first; if(cu->disp.first==NULL) return; @@ -3008,14 +3004,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if(need_orco) mask |= CD_MASK_ORCO; - if(me->mr) { - if(re->flag & R_SKIP_MULTIRES) - me->mr->flag |= MULTIRES_NO_RENDER; - else - me->mr->flag &= ~MULTIRES_NO_RENDER; - } - - dm= mesh_create_derived_render(ob, mask); + dm= mesh_create_derived_render(re->scene, ob, mask); if(dm==NULL) return; /* in case duplicated object fails? */ if(mask & CD_MASK_ORCO) { @@ -3037,7 +3026,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) ma= give_render_material(re, ob, 1); - if(ma->mode & MA_HALO) { + if(ma->material_type == MA_TYPE_HALO) { make_render_halos(re, obr, me, totvert, mvert, ma, orco); } else { @@ -3470,22 +3459,6 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) } else lar->ray_totsamp= 0; -#ifndef DISABLE_YAFRAY - /* yafray: photonlight and other params */ - if (re->r.renderer==R_YAFRAY) { - lar->YF_numphotons = la->YF_numphotons; - lar->YF_numsearch = la->YF_numsearch; - lar->YF_phdepth = la->YF_phdepth; - lar->YF_useqmc = la->YF_useqmc; - lar->YF_causticblur = la->YF_causticblur; - lar->YF_ltradius = la->YF_ltradius; - lar->YF_bufsize = la->YF_bufsize; - lar->YF_glowint = la->YF_glowint; - lar->YF_glowofs = la->YF_glowofs; - lar->YF_glowtype = la->YF_glowtype; - } -#endif /* disable yafray */ - lar->spotsi= la->spotsize; if(lar->mode & LA_HALO) { if(lar->spotsi>170.0) lar->spotsi= 170.0; @@ -4164,7 +4137,7 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset) /* the emitter mesh wasn't rendered so the modifier stack wasn't * evaluated with render settings */ DerivedMesh *dm; - dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); dm->release(dm); } @@ -4286,7 +4259,7 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject re->i.totstrand= re->totstrand; re->i.tothalo= re->tothalo; re->i.totlamp= re->totlamp; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); } ob->flag |= OB_DONE; @@ -4403,13 +4376,13 @@ static int allow_render_dupli_instance(Render *re, DupliObject *dob, Object *obd if(totmaterial) { for(a= 0; a<*totmaterial; a++) { ma= give_current_material(obd, a); - if(ma && (ma->mode & MA_HALO)) + if(ma && (ma->material_type == MA_TYPE_HALO)) return 0; } } for(psys=obd->particlesystem.first; psys; psys=psys->next) - if(!ELEM5(psys->part->draw_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)) + if(!ELEM5(psys->part->ren_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)) return 0; /* don't allow lamp, animated duplis, or radio render */ @@ -4432,7 +4405,7 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in if(ob->transflag & OB_DUPLIPARTS) { for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(ELEM(psys->part->draw_as, PART_DRAW_OB, PART_DRAW_GR)) { + if(ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { if(enable) psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset); else @@ -4444,7 +4417,7 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ - dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); dm->release(dm); for(psys=ob->particlesystem.first; psys; psys=psys->next) @@ -4640,7 +4613,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp else init_render_object(re, obd, ob, dob, timeoffset, vectorlay); - if(re->test_break()) break; + if(re->test_break(re->tbh)) break; } free_object_duplilist(lb); @@ -4651,7 +4624,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp init_render_object(re, ob, NULL, 0, timeoffset, vectorlay); } - if(re->test_break()) break; + if(re->test_break(re->tbh)) break; } /* objects in groups with OB_RENDER_DUPLI set still need to be created, @@ -4668,7 +4641,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp } } - if(!re->test_break()) + if(!re->test_break(re->tbh)) RE_makeRenderInstances(re); } @@ -4684,7 +4657,9 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* per second, per object, stats print this */ re->i.infostr= "Preparing Scene data"; - + re->i.cfra= scene->r.cfra; + strncpy(re->i.scenename, scene->id.name+2, 20); + /* XXX add test if dbase was filled already? */ re->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE); @@ -4728,7 +4703,7 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* MAKE RENDER DATA */ database_init_objects(re, lay, 0, 0, 0, 0); - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { int tothalo; set_material_lightgroups(re); @@ -4743,17 +4718,17 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) re->i.totstrand= re->totstrand; re->i.tothalo= re->tothalo; re->i.totlamp= re->totlamp; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); /* don't sort stars */ tothalo= re->tothalo; - if(!re->test_break()) + if(!re->test_break(re->tbh)) if(re->wrld.mode & WO_STARS) - RE_make_stars(re, NULL, NULL, NULL); + RE_make_stars(re, NULL, NULL, NULL, NULL); sort_halos(re, tothalo); re->i.infostr= "Creating Shadowbuffers"; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); /* SHADOW BUFFER */ threaded_makeshadowbufs(re); @@ -4762,43 +4737,43 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view) /* although radio mode could be useful at some point, later */ if (re->r.renderer==R_INTERN) { /* RADIO (uses no R anymore) */ - if(!re->test_break()) + if(!re->test_break(re->tbh)) if(re->r.mode & R_RADIO) do_radio_render(re); /* raytree */ - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { if(re->r.mode & R_RAYTRACE) { makeraytree(re); } } /* ENVIRONMENT MAPS */ - if(!re->test_break()) + if(!re->test_break(re->tbh)) make_envmaps(re); } - if(!re->test_break()) + if(!re->test_break(re->tbh)) project_renderdata(re, projectverto, re->r.mode & R_PANORAMA, 0, 1); /* Occlusion */ - if((re->wrld.mode & WO_AMB_OCC) && !re->test_break()) + if((re->wrld.mode & WO_AMB_OCC) && !re->test_break(re->tbh)) if(re->wrld.ao_gather_method == WO_AOGATHER_APPROX) if(re->r.renderer==R_INTERN) if(re->r.mode & R_SHADOW) make_occ_tree(re); /* SSS */ - if((re->r.mode & R_SSS) && !re->test_break()) + if((re->r.mode & R_SSS) && !re->test_break(re->tbh)) if(re->r.renderer==R_INTERN) make_sss_tree(re); } - if(re->test_break()) + if(re->test_break(re->tbh)) RE_Database_Free(re); else re->i.convertdone= 1; re->i.infostr= NULL; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); } /* exported call to recalculate hoco for vertices, when winmat changed */ @@ -4837,8 +4812,8 @@ static void database_fromscene_vectors(Render *re, Scene *scene, int timeoffset) if(re->scene->lay & 0xFF000000) lay= re->scene->lay & 0xFF000000; else lay= re->scene->lay; - /* applies changes fully, still using G.scene for timing... */ - G.scene->r.cfra+=timeoffset; + /* applies changes fully */ + scene->r.cfra += timeoffset; scene_update_for_newframe(re->scene, lay); /* if no camera, viewmat should have been set! */ @@ -4851,11 +4826,11 @@ static void database_fromscene_vectors(Render *re, Scene *scene, int timeoffset) /* MAKE RENDER DATA */ database_init_objects(re, lay, 0, 0, 0, timeoffset); - if(!re->test_break()) + if(!re->test_break(re->tbh)) project_renderdata(re, projectverto, re->r.mode & R_PANORAMA, 0, 1); /* do this in end, particles for example need cfra */ - G.scene->r.cfra-=timeoffset; + scene->r.cfra -= timeoffset; } /* choose to use static, to prevent giving too many args to this call */ @@ -5224,7 +5199,7 @@ void RE_Database_FromScene_Vectors(Render *re, Scene *sce) RE_Database_Free(re); re->strandsurface= strandsurface; - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { /* creates entire dbase */ re->i.infostr= "Calculating next frame vectors"; @@ -5239,10 +5214,10 @@ void RE_Database_FromScene_Vectors(Render *re, Scene *sce) RE_Database_Free(re); re->strandsurface= strandsurface; - if(!re->test_break()) + if(!re->test_break(re->tbh)) RE_Database_FromScene(re, sce, 1); - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { for(step= 0; step<2; step++) { if(step) @@ -5311,7 +5286,7 @@ void RE_Database_FromScene_Vectors(Render *re, Scene *sce) } re->i.infostr= NULL; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); } @@ -5345,8 +5320,6 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob) re->flag |= R_GLOB_NOPUNOFLIP; re->flag |= R_BAKING; re->excludeob= actob; - if(type == RE_BAKE_LIGHT) - re->flag |= R_SKIP_MULTIRES; if(actob) re->flag |= R_BAKE_TRACE; @@ -5412,12 +5385,12 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob) threaded_makeshadowbufs(re); /* raytree */ - if(!re->test_break()) + if(!re->test_break(re->tbh)) if(re->r.mode & R_RAYTRACE) makeraytree(re); /* occlusion */ - if((re->wrld.mode & WO_AMB_OCC) && !re->test_break()) + if((re->wrld.mode & WO_AMB_OCC) && !re->test_break(re->tbh)) if(re->wrld.ao_gather_method == WO_AOGATHER_APPROX) if(re->r.mode & R_SHADOW) make_occ_tree(re); @@ -5427,7 +5400,7 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob) /* Sticky texture coords */ /* ------------------------------------------------------------------------- */ -void RE_make_sticky(void) +void RE_make_sticky(Scene *scene, View3D *v3d) { Object *ob; Base *base; @@ -5438,33 +5411,33 @@ void RE_make_sticky(void) float ho[4], mat[4][4]; int a; - if(G.vd==NULL) { + if(v3d==NULL) { printf("Need a 3d view to make sticky\n"); return; } - if(G.scene->camera==NULL) { + if(scene->camera==NULL) { printf("Need camera to make sticky\n"); return; } - if(G.obedit) { + if(scene->obedit) { printf("Unable to make sticky in Edit Mode\n"); return; } re= RE_NewRender("_make sticky_"); - RE_InitState(re, NULL, &G.scene->r, G.scene->r.xsch, G.scene->r.ysch, NULL); + RE_InitState(re, NULL, &scene->r, scene->r.xsch, scene->r.ysch, NULL); /* use renderdata and camera to set viewplane */ - RE_SetCamera(re, G.scene->camera); + RE_SetCamera(re, scene->camera); /* and set view matrix */ - Mat4Ortho(G.scene->camera->obmat); - Mat4Invert(mat, G.scene->camera->obmat); + Mat4Ortho(scene->camera->obmat); + Mat4Invert(mat, scene->camera->obmat); RE_SetView(re, mat); for(base= FIRSTBASE; base; base= base->next) { - if TESTBASELIB(base) { + if TESTBASELIB(v3d, base) { if(base->object->type==OB_MESH) { ob= base->object; @@ -5475,7 +5448,7 @@ void RE_make_sticky(void) me->msticky= CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_CALLOC, NULL, me->totvert); - where_is_object(ob); + where_is_object(scene, ob); Mat4MulMat4(mat, ob->obmat, re->viewmat); ms= me->msticky; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 13fa9b17b71..a57e38f47c8 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -142,7 +142,9 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) /* callbacks */ envre->display_draw= re->display_draw; + envre->ddh= re->ddh; envre->test_break= re->test_break; + envre->tbh= re->tbh; /* and for the evil stuff; copy the database... */ envre->totvlak= re->totvlak; @@ -369,7 +371,7 @@ static void env_set_imats(Render *re) Base *base; float mat[4][4]; - base= G.scene->base.first; + base= re->scene->base.first; while(base) { MTC_Mat4MulMat4(mat, base->object->obmat, re->viewmat); MTC_Mat4Invert(base->object->imat, mat); @@ -408,7 +410,7 @@ static void render_envmap(Render *re, EnvMap *env) if(env->type==ENV_PLANE && part!=1) continue; - re->display_clear(envre->result); + re->display_clear(re->dch, envre->result); MTC_Mat4CpyMat4(tmat, orthmat); envmap_transmatrix(tmat, part); @@ -429,7 +431,7 @@ static void render_envmap(Render *re, EnvMap *env) env_hideobject(envre, env->object); env_set_imats(envre); - if(re->test_break()==0) { + if(re->test_break(re->tbh)==0) { RE_TileProcessor(envre, 0, 0); } @@ -437,7 +439,7 @@ static void render_envmap(Render *re, EnvMap *env) env_showobjects(envre); env_rotate_scene(envre, tmat, 0); - if(re->test_break()==0) { + if(re->test_break(re->tbh)==0) { RenderLayer *rl= envre->result->layers.first; int y; char *alpha; @@ -455,15 +457,15 @@ static void render_envmap(Render *re, EnvMap *env) env->cube[part]= ibuf; } - if(re->test_break()) break; + if(re->test_break(re->tbh)) break; } - if(re->test_break()) BKE_free_envmapdata(env); + if(re->test_break(re->tbh)) BKE_free_envmapdata(env); else { if(envre->r.mode & R_OSA) env->ok= ENV_OSA; else env->ok= ENV_NORMAL; - env->lastframe= G.scene->r.cfra; /* hurmf */ + env->lastframe= re->scene->r.cfra; } /* restore */ @@ -486,7 +488,7 @@ void make_envmaps(Render *re) re->r.mode &= ~R_RAYTRACE; re->i.infostr= "Creating Environment maps"; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); /* 5 = hardcoded max recursion level */ while(depth<5) { @@ -496,7 +498,7 @@ void make_envmaps(Render *re) if(tex->env && tex->env->object) { EnvMap *env= tex->env; - if(env->object->lay & G.scene->lay) { + if(env->object->lay & re->scene->lay) { if(env->stype==ENV_LOAD) { float orthmat[4][4], mat[4][4], tmat[4][4]; @@ -547,8 +549,8 @@ void make_envmaps(Render *re) } if(do_init) { - re->display_init(re->result); - re->display_clear(re->result); + re->display_init(re->dih, re->result); + re->display_clear(re->dch, re->result); // re->flag |= R_REDRAW_PRV; } // restore diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 40c0edb6e5f..a0185a64659 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -458,10 +458,12 @@ void RE_SetCamera(Render *re, Object *camera) * Need to update the camera early because it's used for projection matrices * and other stuff BEFORE the animation update loop is done * */ +#if 0 // XXX old animation system if(cam->ipo) { - calc_ipo(cam->ipo, frame_to_float(re->r.cfra)); + calc_ipo(cam->ipo, frame_to_float(re->scene, re->r.cfra)); execute_ipo(&cam->id, cam->ipo); } +#endif // XXX old animation system lens= cam->lens; shiftx=cam->shiftx; shifty=cam->shifty; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index f9301bc0805..1cbf2523156 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -514,10 +514,6 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i OccFace *face; int a, b, totthread=0, offset[TOTCHILD], count[TOTCHILD]; - /* keep track of maximum depth for stack */ - if(depth > tree->maxdepth) - tree->maxdepth= depth; - /* add a new node */ node->occlusion= 1.0f; @@ -552,6 +548,10 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i child= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); node->child[b].node= child; + /* keep track of maximum depth for stack */ + if(depth+1 > tree->maxdepth) + tree->maxdepth= depth+1; + if(tree->dothreadedbuild) BLI_unlock_thread(LOCK_CUSTOM1); @@ -679,6 +679,7 @@ static OcclusionTree *occ_tree_build(Render *re) /* recurse */ tree->root= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + tree->maxdepth= 1; occ_build_recursive(tree, tree->root, 0, totface, 1); #if 0 @@ -1292,11 +1293,11 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) VECADDFAC(co, co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL); - if(re->test_break()) + if(re->test_break(re->tbh)) break; } - if(re->test_break()) + if(re->test_break(re->tbh)) break; for(i=0; i<tree->totface; i++) { @@ -1546,7 +1547,7 @@ void make_occ_tree(Render *re) R= *re; re->i.infostr= "Occlusion preprocessing"; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); re->occlusiontree= occ_tree_build(re); @@ -1738,7 +1739,7 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) sample->filled= 1; } - if(re->test_break()) + if(re->test_break(re->tbh)) break; } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 96edb4ee73c..07560edb76b 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -63,14 +63,6 @@ #include "RE_pipeline.h" #include "radio.h" -#include "BSE_sequence.h" /* <----------------- bad!!! */ - -#ifndef DISABLE_YAFRAY -/* yafray: include for yafray export/render */ -#include "YafRay_Api.h" - -#endif /* disable yafray */ - /* internal */ #include "render_types.h" #include "renderpipeline.h" @@ -124,26 +116,31 @@ static int commandline_threads= -1; static volatile int g_break= 0; -static int thread_break(void) +static int thread_break(void *unused) { return g_break; } /* default callbacks, set in each new render */ -static void result_nothing(RenderResult *rr) {} -static void result_rcti_nothing(RenderResult *rr, volatile struct rcti *rect) {} -static void stats_nothing(RenderStats *rs) {} -static void int_nothing(int val) {} -static int void_nothing(void) {return 0;} -static void print_error(char *str) {printf("ERROR: %s\n", str);} +static void result_nothing(void *unused, RenderResult *rr) {} +static void result_rcti_nothing(void *unused, RenderResult *rr, volatile struct rcti *rect) {} +static void stats_nothing(void *unused, RenderStats *rs) {} +static void int_nothing(void *unused, int val) {} +static int void_nothing(void *unused) {return 0;} +static void print_error(void *unused, char *str) {printf("ERROR: %s\n", str);} + +int RE_RenderInProgress(Render *re) +{ + return re->result_ok==0; +} -static void stats_background(RenderStats *rs) +static void stats_background(void *unused, RenderStats *rs) { uintptr_t mem_in_use= MEM_get_memory_in_use(); float megs_used_memory= mem_in_use/(1024.0*1024.0); char str[400], *spos= str; - spos+= sprintf(spos, "Fra:%d Mem:%.2fM ", G.scene->r.cfra, megs_used_memory); + spos+= sprintf(spos, "Fra:%d Mem:%.2fM ", rs->cfra, megs_used_memory); if(rs->curfield) spos+= sprintf(spos, "Field %d ", rs->curfield); @@ -155,11 +152,11 @@ static void stats_background(RenderStats *rs) } else { if(rs->tothalo) - spos+= sprintf(spos, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", G.scene->id.name+2, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); + spos+= sprintf(spos, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); else - spos+= sprintf(spos, "Sce: %s Ve:%d Fa:%d La:%d", G.scene->id.name+2, rs->totvert, rs->totface, rs->totlamp); + spos+= sprintf(spos, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); } - printf(str); printf("\n"); + printf("%s\n", str); } void RE_FreeRenderResult(RenderResult *res) @@ -924,6 +921,14 @@ RenderResult *RE_GetResult(Render *re) return NULL; } +/* displist.c util.... */ +Scene *RE_GetScene(Render *re) +{ + if(re) + return re->scene; + return NULL; +} + RenderLayer *render_get_active_layer(Render *re, RenderResult *rr) { RenderLayer *rl= BLI_findlink(&rr->layers, re->r.actlay); @@ -993,7 +998,6 @@ RenderStats *RE_GetStats(Render *re) return &re->i; } -/* Note, when rendering from a scene, ALWAYS use G.scene->id.name, else compositing wont work */ Render *RE_NewRender(const char *name) { Render *re; @@ -1008,18 +1012,24 @@ Render *RE_NewRender(const char *name) strncpy(re->name, name, RE_MAXNAME); } + /* prevent UI to draw old results */ + RE_FreeRenderResult(re->result); + re->result= NULL; + re->result_ok= 0; + /* set default empty callbacks */ re->display_init= result_nothing; re->display_clear= result_nothing; re->display_draw= result_rcti_nothing; re->timecursor= int_nothing; re->test_break= void_nothing; - re->test_return= void_nothing; re->error= print_error; if(G.background) re->stats_draw= stats_background; else re->stats_draw= stats_nothing; + /* clear callback handles */ + re->dih= re->dch= re->ddh= re->sdh= re->tch= re->tbh= re->erh= NULL; /* init some variables */ re->ycor= 1.0f; @@ -1078,7 +1088,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, int winx, int winy if(re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->imtype) && (re->rectx < 16 || re->recty < 16) )) { - re->error("Image too small"); + re->error(re->erh, "Image too small"); re->ok= 0; } else { @@ -1110,11 +1120,22 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, int winx, int winy /* always call, checks for gamma, gamma tables and jitter too */ make_sample_tables(re); - /* make empty render result, so display callbacks can initialize */ - RE_FreeRenderResult(re->result); - re->result= MEM_callocN(sizeof(RenderResult), "new render result"); - re->result->rectx= re->rectx; - re->result->recty= re->recty; + /* if preview render, we try to keep old result */ + if(re->r.scemode & R_PREVIEWBUTS) { + if(re->result && re->result->rectx==re->rectx && re->result->recty==re->recty); + else { + RE_FreeRenderResult(re->result); + re->result= NULL; + } + } + else { + + /* make empty render result, so display callbacks can initialize */ + RE_FreeRenderResult(re->result); + re->result= MEM_callocN(sizeof(RenderResult), "new render result"); + re->result->rectx= re->rectx; + re->result->recty= re->recty; + } /* we clip faces with a minimum of 2 pixel boundary outside of image border. see zbuf.c */ re->clipcrop= 1.0f + 2.0f/(float)(re->winx>re->winy?re->winy:re->winx); @@ -1168,39 +1189,41 @@ void RE_SetView(Render *re, float mat[][4]) } /* image and movie output has to move to either imbuf or kernel */ -void RE_display_init_cb(Render *re, void (*f)(RenderResult *rr)) +void RE_display_init_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)) { re->display_init= f; + re->dih= handle; } -void RE_display_clear_cb(Render *re, void (*f)(RenderResult *rr)) +void RE_display_clear_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)) { re->display_clear= f; + re->dch= handle; } -void RE_display_draw_cb(Render *re, void (*f)(RenderResult *rr, volatile rcti *rect)) +void RE_display_draw_cb(Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile rcti *rect)) { re->display_draw= f; + re->ddh= handle; } - -void RE_stats_draw_cb(Render *re, void (*f)(RenderStats *rs)) +void RE_stats_draw_cb(Render *re, void *handle, void (*f)(void *handle, RenderStats *rs)) { re->stats_draw= f; + re->sdh= handle; } -void RE_timecursor_cb(Render *re, void (*f)(int)) +void RE_timecursor_cb(Render *re, void *handle, void (*f)(void *handle, int)) { re->timecursor= f; + re->tch= handle; } -void RE_test_break_cb(Render *re, int (*f)(void)) +void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle)) { re->test_break= f; + re->tbh= handle; } -void RE_test_return_cb(Render *re, int (*f)(void)) -{ - re->test_return= f; -} -void RE_error_cb(Render *re, void (*f)(char *str)) +void RE_error_cb(Render *re, void *handle, void (*f)(void *handle, char *str)) { re->error= f; + re->erh= handle; } @@ -1248,7 +1271,7 @@ static void *do_part_thread(void *pa_v) RenderPart *pa= pa_v; /* need to return nicely all parts on esc */ - if(R.test_break()==0) { + if(R.test_break(R.tbh)==0) { if(!R.sss_points && (R.r.scemode & R_FULL_SAMPLE)) pa->result= new_full_sample_buffers(&R, &pa->fullresult, &pa->disprect, pa->crop); @@ -1270,8 +1293,11 @@ static void *do_part_thread(void *pa_v) save_render_result_tile(rr, rrpart); } - else if(render_display_draw_enabled(&R)) - merge_render_result(R.result, pa->result); + else if(render_display_draw_enabled(&R)) { + /* on break, don't merge in result for preview renders, looks nicer */ + if(R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)); + else merge_render_result(R.result, pa->result); + } } pa->ready= 1; @@ -1284,7 +1310,7 @@ static void render_tile_processor(Render *re, int firsttile) { RenderPart *pa; - if(re->test_break()) + if(re->test_break(re->tbh)) return; /* hrmf... exception, this is used for preview render, re-entrant, so render result has to be re-used */ @@ -1293,7 +1319,7 @@ static void render_tile_processor(Render *re, int firsttile) re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); } - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); if(re->result==NULL) return; @@ -1312,17 +1338,17 @@ static void render_tile_processor(Render *re, int firsttile) do_part_thread(pa); if(pa->result) { - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { if(render_display_draw_enabled(re)) - re->display_draw(pa->result, NULL); + re->display_draw(re->ddh, pa->result, NULL); re->i.partsdone++; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); } RE_FreeRenderResult(pa->result); pa->result= NULL; } - if(re->test_break()) + if(re->test_break(re->tbh)) break; } } @@ -1439,7 +1465,7 @@ static void print_part_stats(Render *re, RenderPart *pa) sprintf(str, "Part %d-%d", pa->nr, re->i.totpart); re->i.infostr= str; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); re->i.infostr= NULL; } @@ -1465,14 +1491,16 @@ static void threaded_tile_processor(Render *re) int rendering=1, counter= 1, drawtimer=0, hasdrawn, minx=0; /* first step; free the entire render result, make new, and/or prepare exr buffer saving */ - RE_FreeRenderResult(re->result); + if(re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { + RE_FreeRenderResult(re->result); - if(re->sss_points) - re->result= new_render_result(re, &re->disprect, 0, 0); - else if(re->r.scemode & R_FULL_SAMPLE) - re->result= new_full_sample_buffers_exr(re); - else - re->result= new_render_result(re, &re->disprect, 0, re->r.scemode & R_EXR_TILE_FILE); + if(re->sss_points) + re->result= new_render_result(re, &re->disprect, 0, 0); + else if(re->r.scemode & R_FULL_SAMPLE) + re->result= new_full_sample_buffers_exr(re); + else + re->result= new_render_result(re, &re->disprect, 0, re->r.scemode & R_EXR_TILE_FILE); + } if(re->result==NULL) return; @@ -1509,7 +1537,7 @@ static void threaded_tile_processor(Render *re) while(rendering) { - if(re->test_break()) + if(re->test_break(re->tbh)) PIL_sleep_ms(50); else if(nextpa && BLI_available_threads(&threads)) { drawtimer= 0; @@ -1542,7 +1570,7 @@ static void threaded_tile_processor(Render *re) if(pa->result) { if(render_display_draw_enabled(re)) - re->display_draw(pa->result, NULL); + re->display_draw(re->ddh, pa->result, NULL); print_part_stats(re, pa); free_render_result(&pa->fullresult, pa->result); @@ -1555,7 +1583,7 @@ static void threaded_tile_processor(Render *re) rendering= 1; if(pa->nr && pa->result && drawtimer>20) { if(render_display_draw_enabled(re)) - re->display_draw(pa->result, &pa->result->renrect); + re->display_draw(re->ddh, pa->result, &pa->result->renrect); hasdrawn= 1; } } @@ -1564,7 +1592,7 @@ static void threaded_tile_processor(Render *re) drawtimer= 0; /* on break, wait for all slots to get freed */ - if( (g_break=re->test_break()) && BLI_available_threads(&threads)==re->r.threads) + if( (g_break=re->test_break(re->tbh)) && BLI_available_threads(&threads)==re->r.threads) rendering= 0; } @@ -1610,7 +1638,7 @@ void RE_TileProcessor(Render *re, int firsttile, int threaded) if(!re->sss_points) re->i.lastframetime= PIL_check_seconds_timer()- re->i.starttime; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); } @@ -1631,7 +1659,7 @@ static void do_render_3d(Render *re) /* do left-over 3d post effects (flares) */ if(re->flag & R_HALO) - if(!re->test_break()) + if(!re->test_break(re->tbh)) add_halo_flare(re); @@ -1745,7 +1773,7 @@ static void do_render_blur_3d(Render *re) blurfac= 1.0f/(float)(re->r.osa-blur); merge_renderresult_blur(rres, re->result, blurfac, re->r.alphamode & R_ALPHAKEY); - if(re->test_break()) break; + if(re->test_break(re->tbh)) break; } /* swap results */ @@ -1757,7 +1785,7 @@ static void do_render_blur_3d(Render *re) /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay= render_get_active_layer(re, re->result); - re->display_draw(re->result, NULL); + re->display_draw(re->ddh, re->result, NULL); } @@ -1824,7 +1852,7 @@ static void do_render_fields_3d(Render *re) re->result= NULL; /* second field */ - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { re->i.curfield= 2; /* stats */ @@ -1863,7 +1891,7 @@ static void do_render_fields_3d(Render *re) /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay= render_get_active_layer(re, re->result); - re->display_draw(re->result, NULL); + re->display_draw(re->ddh, re->result, NULL); } static void load_backbuffer(Render *re) @@ -1882,7 +1910,7 @@ static void load_backbuffer(Render *re) BKE_image_signal(re->backbuf, NULL, IMA_SIGNAL_RELOAD); } - re->backbuf= BKE_add_image_file(name); + re->backbuf= BKE_add_image_file(name, re->r.cfra); ibuf= BKE_image_get_ibuf(re->backbuf, NULL); if(ibuf==NULL) { // error() doesnt work with render window open @@ -1946,8 +1974,8 @@ static void do_render_fields_blur_3d(Render *re) /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay= render_get_active_layer(re, re->result); - re->display_init(re->result); - re->display_draw(re->result, NULL); + re->display_init(re->dih, re->result); + re->display_draw(re->ddh, re->result, NULL); } } } @@ -1976,13 +2004,16 @@ static void render_scene(Render *re, Scene *sce, int cfra) /* still unsure entity this... */ resc->scene= sce; - /* ensure scene has depsgraph, base flags etc OK. Warning... also sets G.scene */ + /* ensure scene has depsgraph, base flags etc OK */ set_scene_bg(sce); /* copy callbacks */ resc->display_draw= re->display_draw; + resc->ddh= re->ddh; resc->test_break= re->test_break; + resc->tbh= re->tbh; resc->stats_draw= re->stats_draw; + resc->sdh= re->sdh; do_render_fields_blur_3d(resc); } @@ -2032,11 +2063,6 @@ static void ntree_render_scenes(Render *re) } } } - - /* still the global... */ - if(G.scene!=re->scene) - set_scene_bg(re->scene); - } /* helper call to detect if theres a composite with render-result node */ @@ -2058,10 +2084,10 @@ static int composite_needs_render(Scene *sce) } /* bad call... need to think over proper method still */ -static void render_composit_stats(char *str) +static void render_composit_stats(void *unused, char *str) { R.i.infostr= str; - R.stats_draw(&R.i); + R.stats_draw(R.sdh, &R.i); R.i.infostr= NULL; } @@ -2127,10 +2153,10 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) if(sample!=re->osa-1) { /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay= render_get_active_layer(re, re->result); - re->display_draw(re->result, NULL); + re->display_draw(re->ddh, re->result, NULL); } - if(re->test_break()) + if(re->test_break(re->tbh)) break; } @@ -2164,12 +2190,12 @@ void RE_MergeFullSample(Render *re, Scene *sce, bNodeTree *ntree) } /* own render result should be read/allocated */ - if(G.scene->id.flag & LIB_DOIT) - RE_ReadRenderResult(G.scene, G.scene); + if(re->scene->id.flag & LIB_DOIT) + RE_ReadRenderResult(re->scene, re->scene); /* and now we can draw (result is there) */ - re->display_init(re->result); - re->display_clear(re->result); + re->display_init(re->dih, re->result); + re->display_clear(re->dch, re->result); do_merge_fullsample(re, ntree); } @@ -2193,7 +2219,7 @@ static void do_render_composite_fields_blur_3d(Render *re) if(re->r.scemode & R_SINGLE_LAYER) pop_render_result(re); - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { if(ntree) { ntreeCompositTagRender(re->scene); @@ -2206,9 +2232,11 @@ static void do_render_composite_fields_blur_3d(Render *re) if((re->r.scemode & R_SINGLE_LAYER)==0) ntree_render_scenes(re); - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { ntree->stats_draw= render_composit_stats; ntree->test_break= re->test_break; + ntree->sdh= re->sdh; + ntree->tbh= re->tbh; /* in case it was never initialized */ R.stats_draw= re->stats_draw; @@ -2219,6 +2247,7 @@ static void do_render_composite_fields_blur_3d(Render *re) ntree->stats_draw= NULL; ntree->test_break= NULL; + ntree->tbh= ntree->sdh= NULL; } } else if(re->r.scemode & R_FULL_SAMPLE) @@ -2228,78 +2257,15 @@ static void do_render_composite_fields_blur_3d(Render *re) /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay= render_get_active_layer(re, re->result); - re->display_draw(re->result, NULL); + re->display_draw(re->ddh, re->result, NULL); } -#ifndef DISABLE_YAFRAY -/* yafray: main yafray render/export call */ -static void yafrayRender(Render *re) -{ - RE_FreeRenderResult(re->result); - re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); - - // need this too, for aspect/ortho/etc info - RE_SetCamera(re, re->scene->camera); - - // switch must be done before prepareScene() - if (!re->r.YFexportxml) - YAF_switchFile(); - else - YAF_switchPlugin(); - - printf("Starting scene conversion.\n"); - RE_Database_FromScene(re, re->scene, 1); - printf("Scene conversion done.\n"); - - re->i.starttime = PIL_check_seconds_timer(); - - YAF_exportScene(re); - - /* also needed for yafray border render, straight copy from do_render_fields_blur_3d() */ - /* when border render, check if we have to insert it in black */ - if(re->result) { - if(re->r.mode & R_BORDER) { - if((re->r.mode & R_CROP)==0) { - RenderResult *rres; - - /* sub-rect for merge call later on */ - re->result->tilerect= re->disprect; - - /* this copying sequence could become function? */ - re->disprect.xmin= re->disprect.ymin= 0; - re->disprect.xmax= re->winx; - re->disprect.ymax= re->winy; - re->rectx= re->winx; - re->recty= re->winy; - - rres= new_render_result(re, &re->disprect, 0, RR_USEMEM); - - merge_render_result(rres, re->result); - RE_FreeRenderResult(re->result); - re->result= rres; - - re->display_init(re->result); - re->display_draw(re->result, NULL); - } - } - } - - re->i.lastframetime = PIL_check_seconds_timer()- re->i.starttime; - re->stats_draw(&re->i); - - RE_Database_Free(re); -} - - - -#endif /* disable yafray */ - -static void renderresult_stampinfo() +static void renderresult_stampinfo(Scene *scene) { RenderResult rres; /* this is the basic trick to get the displayed float or char rect from render result */ - RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres); - BKE_stamp_buf((unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4); + RE_GetResultImage(RE_GetRender(scene->id.name), &rres); + BKE_stamp_buf(scene, (unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4); } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -2314,22 +2280,15 @@ static void do_render_all_options(Render *re) if(re->r.scemode & R_DOSEQ) { /* note: do_render_seq() frees rect32 when sequencer returns float images */ - if(!re->test_break()) - do_render_seq(re->result, re->r.cfra); + if(!re->test_break(re->tbh)) + ; //XXX do_render_seq(re->result, re->r.cfra); - re->stats_draw(&re->i); - re->display_draw(re->result, NULL); + re->stats_draw(re->sdh, &re->i); + re->display_draw(re->ddh, re->result, NULL); } else { -#ifndef DISABLE_YAFRAY - if(re->r.renderer==R_YAFRAY) - yafrayRender(re); - else - do_render_composite_fields_blur_3d(re); -#else do_render_composite_fields_blur_3d(re); -#endif } /* for UI only */ @@ -2337,12 +2296,12 @@ static void do_render_all_options(Render *re) re->i.lastframetime= PIL_check_seconds_timer()- re->i.starttime; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); /* stamp image info here */ - if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) { - renderresult_stampinfo(); - re->display_draw(re->result, NULL); + if((re->r.scemode & R_STAMP_INFO) && (re->r.stamp & R_STAMP_DRAW)) { + renderresult_stampinfo(re->scene); + re->display_draw(re->ddh, re->result, NULL); } } @@ -2353,11 +2312,11 @@ static int is_rendering_allowed(Render *re) /* forbidden combinations */ if(re->r.mode & R_PANORAMA) { if(re->r.mode & R_BORDER) { - re->error("No border supported for Panorama"); + re->error(re->erh, "No border supported for Panorama"); return 0; } if(re->r.mode & R_ORTHO) { - re->error("No Ortho render possible for Panorama"); + re->error(re->erh, "No Ortho render possible for Panorama"); return 0; } } @@ -2365,11 +2324,11 @@ static int is_rendering_allowed(Render *re) if(re->r.mode & R_BORDER) { if(re->r.border.xmax <= re->r.border.xmin || re->r.border.ymax <= re->r.border.ymin) { - re->error("No border area selected."); + re->error(re->erh, "No border area selected."); return 0; } if(re->r.scemode & R_EXR_TILE_FILE) { - re->error("Border render and Buffer-save not supported yet"); + re->error(re->erh, "Border render and Buffer-save not supported yet"); return 0; } } @@ -2380,7 +2339,7 @@ static int is_rendering_allowed(Render *re) render_unique_exr_name(re, str, 0); if (BLI_is_writable(str)==0) { - re->error("Can not save render buffers, check the temp default path"); + re->error(re->erh, "Can not save render buffers, check the temp default path"); return 0; } @@ -2390,7 +2349,7 @@ static int is_rendering_allowed(Render *re) /* no fullsample and edge */ if((re->r.scemode & R_FULL_SAMPLE) && (re->r.mode & R_EDGE)) { - re->error("Full Sample doesn't support Edge Enhance"); + re->error(re->erh, "Full Sample doesn't support Edge Enhance"); return 0; } @@ -2404,7 +2363,7 @@ static int is_rendering_allowed(Render *re) bNode *node; if(ntree==NULL) { - re->error("No Nodetree in Scene"); + re->error(re->erh, "No Nodetree in Scene"); return 0; } @@ -2414,7 +2373,7 @@ static int is_rendering_allowed(Render *re) if(node==NULL) { - re->error("No Render Output Node in Scene"); + re->error(re->erh, "No Render Output Node in Scene"); return 0; } } @@ -2426,7 +2385,7 @@ static int is_rendering_allowed(Render *re) if(!(re->r.scemode & (R_DOSEQ|R_DOCOMP))) { if(re->scene->camera==NULL) { - re->error("No camera"); + re->error(re->erh, "No camera"); return 0; } } @@ -2442,13 +2401,13 @@ static int is_rendering_allowed(Render *re) if(!(srl->layflag & SCE_LAY_DISABLE)) break; if(srl==NULL) { - re->error("All RenderLayers are disabled"); + re->error(re->erh, "All RenderLayers are disabled"); return 0; } /* renderer */ if(!ELEM(re->r.renderer, R_INTERN, R_YAFRAY)) { - re->error("Unknown render engine set"); + re->error(re->erh, "Unknown render engine set"); return 0; } return 1; @@ -2505,8 +2464,8 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim) if(!is_rendering_allowed(re)) return 0; - re->display_init(re->result); - re->display_clear(re->result); + re->display_init(re->dih, re->result); + re->display_clear(re->dch, re->result); return 1; } @@ -2514,9 +2473,9 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim) /* general Blender frame render call */ void RE_BlenderFrame(Render *re, Scene *scene, int frame) { - /* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */ - /* is also set by caller renderwin.c */ + /* ugly global still... is to prevent preview events and signal subsurfs etc to make full resol */ G.rendering= 1; + re->result_ok= 0; scene->r.cfra= frame; @@ -2526,6 +2485,7 @@ void RE_BlenderFrame(Render *re, Scene *scene, int frame) /* UGLY WARNING */ G.rendering= 0; + re->result_ok= 1; } static void do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh) @@ -2544,14 +2504,14 @@ static void do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh) dofree = 1; } RE_ResultGet32(re, (unsigned int *)rres.rect32); - mh->append_movie(scene->r.cfra, rres.rect32, rres.rectx, rres.recty); + mh->append_movie(&re->r, scene->r.cfra, rres.rect32, rres.rectx, rres.recty); if(dofree) { MEM_freeN(rres.rect32); } printf("Append frame %d", scene->r.cfra); } else { - BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype); + BKE_makepicstring(scene, name, scene->r.pic, scene->r.cfra, scene->r.imtype); if(re->r.imtype==R_MULTILAYER) { if(re->result) { @@ -2571,7 +2531,7 @@ static void do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh) /* float factor for random dither, imbuf takes care of it */ ibuf->dither= scene->r.dither_intensity; - ok= BKE_write_ibuf(ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); if(ok==0) { printf("Render error: cannot save %s\n", name); @@ -2583,9 +2543,9 @@ static void do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh) if(ok && scene->r.imtype==R_OPENEXR && (scene->r.subimtype & R_PREVIEW_JPG)) { if(BLI_testextensie(name, ".exr")) name[strlen(name)-4]= 0; - BKE_add_image_extension(name, R_JPEG90); + BKE_add_image_extension(scene, name, R_JPEG90); ibuf->depth= 24; - BKE_write_ibuf(ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality); + BKE_write_ibuf(scene, ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality); printf("\nSaved: %s", name); } @@ -2614,23 +2574,24 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) /* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */ /* is also set by caller renderwin.c */ G.rendering= 1; + re->result_ok= 0; if(BKE_imtype_is_movie(scene->r.imtype)) mh->start_movie(&re->r, re->rectx, re->recty); if (mh->get_next_frame) { while (!(G.afbreek == 1)) { - int nf = mh->get_next_frame(); + int nf = mh->get_next_frame(&re->r); if (nf >= 0 && nf >= scene->r.sfra && nf <= scene->r.efra) { scene->r.cfra = re->r.cfra = nf; do_render_all_options(re); - if(re->test_break() == 0) { + if(re->test_break(re->tbh) == 0) { do_write_image_or_movie(re, scene, mh); } } else { - re->test_break(); + re->test_break(re->tbh); } } } else { @@ -2659,15 +2620,14 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) /* Touch/NoOverwrite options are only valid for image's */ if(BKE_imtype_is_movie(scene->r.imtype) == 0) { - if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH) ) { - BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype); - } + if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) + BKE_makepicstring(scene, name, scene->r.pic, scene->r.cfra, scene->r.imtype); - if (scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) { + if(scene->r.mode & R_NO_OVERWRITE && BLI_exist(name)) { printf("skipping existing frame \"%s\"\n", name); continue; } - if (scene->r.mode & R_TOUCH && !BLI_exist(name)) { + if(scene->r.mode & R_TOUCH && !BLI_exist(name)) { BLI_make_existing_file(name); /* makes the dir if its not there */ BLI_touch(name); } @@ -2677,7 +2637,7 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) do_render_all_options(re); - if(re->test_break() == 0) { + if(re->test_break(re->tbh) == 0) { do_write_image_or_movie(re, scene, mh); } @@ -2702,6 +2662,7 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra, int tfra) /* UGLY WARNING */ G.rendering= 0; + re->result_ok= 1; } /* note; repeated win/disprect calc... solve that nicer, also in compo */ diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 75b9557f337..33b58cf9751 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -180,13 +180,13 @@ void makeraytree(Render *re) double time= PIL_check_seconds_timer(); vlr= obr->vlaknodes[v>>8].vlak; - if(re->test_break()) + 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->i); + re->stats_draw(re->sdh, &re->i); re->i.infostr= NULL; lasttime= time; } @@ -202,7 +202,7 @@ void makeraytree(Render *re) RE_ray_tree_done(re->raytree); re->i.infostr= NULL; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); } static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) @@ -1537,8 +1537,8 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac) float maxdist = R.wrld.aodist; float fac=0.0f, prev=0.0f; - float adapt_thresh = G.scene->world->ao_adapt_thresh; - float adapt_speed_fac = G.scene->world->ao_adapt_speed_fac; + float adapt_thresh = R.wrld.ao_adapt_thresh; + float adapt_speed_fac = R.wrld.ao_adapt_speed_fac; int samples=0; int max_samples = R.wrld.aosamp*R.wrld.aosamp; @@ -1685,7 +1685,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *shadfac) /* bias prevents smoothed faces to appear flat */ if(shi->vlr->flag & R_SMOOTH) { - bias= G.scene->world->aobias; + bias= R.wrld.aobias; nrm= shi->vn; } else { @@ -2141,6 +2141,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac) } +#if 0 /* only when face points away from lamp, in direction of lamp, trace ray and find first exit point */ static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float *co) { @@ -2183,4 +2184,5 @@ static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float *distfac= 0.0f; } +#endif diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 2793e238dc7..165cb88de71 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -314,7 +314,7 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) } } } - if(R.test_break() ) break; + if(R.test_break(R.tbh) ) break; } } @@ -430,7 +430,7 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) if(rd) rd++; } if(y&1) - if(R.test_break()) break; + if(R.test_break(R.tbh)) break; } } @@ -662,7 +662,7 @@ static void sky_tile(RenderPart *pa, RenderLayer *rl) } if(y&1) - if(R.test_break()) break; + if(R.test_break(R.tbh)) break; } } @@ -703,7 +703,7 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl) for(sample=0; sample<totsample; sample++) { float *zrect= RE_RenderLayerGetPass(rlpp[sample], SCE_PASS_Z) + od; float *rgbrect = rlpp[sample]->rectf + 4*od; - float rgb[3]; + float rgb[3] = {0}; int done= 0; for(go=R.lights.first; go; go= go->next) { @@ -760,7 +760,7 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) int samp; int x, y, seed, crop=0, offs=0, od; - if(R.test_break()) return; + if(R.test_break(R.tbh)) return; /* irregular shadowb buffer creation */ if(R.r.mode & R_SHADOW) @@ -821,7 +821,7 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) rectdaps+= pa->rectx; offs+= pa->rectx; - if(y&1) if(R.test_break()) break; + if(y&1) if(R.test_break(R.tbh)) break; } /* disable scanline updating */ @@ -1142,7 +1142,7 @@ void zbufshadeDA_tile(RenderPart *pa) sdata.psmlist= &psmlist; sdata.edgerect= edgerect; zbuffer_solid(pa, rl, make_pixelstructs, &sdata); - if(R.test_break()) break; + if(R.test_break(R.tbh)) break; } /* shades solid */ @@ -1280,7 +1280,7 @@ void zbufshade_tile(RenderPart *pa) zbuffer_solid(pa, rl, NULL, NULL); - if(!R.test_break()) { /* NOTE: this if() is not consistant */ + if(!R.test_break(R.tbh)) { /* NOTE: this if() is not consistant */ /* edges only for solid part, ztransp doesn't support it yet anti-aliased */ if(rl->layflag & SCE_LAY_EDGE) { @@ -1325,7 +1325,7 @@ void zbufshade_tile(RenderPart *pa) } } if(y&1) - if(R.test_break()) break; + if(R.test_break(R.tbh)) break; } if(R.occlusiontree) @@ -1377,7 +1377,7 @@ void zbufshade_tile(RenderPart *pa) if(rl->layflag & SCE_LAY_SKY) sky_tile(pa, rl); - if(!R.test_break()) { + if(!R.test_break(R.tbh)) { if(rl->layflag & SCE_LAY_EDGE) if(R.r.mode & R_EDGE) edge_enhance_add(pa, rl->rectf, edgerect); @@ -1717,7 +1717,7 @@ void zbufshade_sss_tile(RenderPart *pa) } if(y&1) - if(re->test_break()) break; + if(re->test_break(re->tbh)) break; } /* note: after adding we do not free these arrays, sss keeps them */ @@ -1797,7 +1797,7 @@ static void renderhalo_post(RenderResult *rr, float *rectf, HaloRen *har) /* pos rectft+= 4*rr->rectx; - if(R.test_break()) break; + if(R.test_break(R.tbh)) break; } } } @@ -1915,7 +1915,7 @@ void add_halo_flare(Render *re) if(do_draw) { /* weak... the display callback wants an active renderlayer pointer... */ rr->renlay= rl; - re->display_draw(rr, NULL); + re->display_draw(re->ddh, rr, NULL); } R.r.mode= mode; @@ -2334,7 +2334,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) ShadeInput *shi= ssamp->shi; /* fast threadsafe break test */ - if(R.test_break()) + if(R.test_break(R.tbh)) return; /* setup render coordinates */ @@ -2571,7 +2571,7 @@ static void *do_bake_thread(void *bs_v) shade_tface(bs); /* fast threadsafe break test */ - if(R.test_break()) + if(R.test_break(R.tbh)) break; } bs->ready= 1; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index c53a2b68c9c..71cd678233d 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -425,7 +425,7 @@ void makeshadowbuf(Render *re, LampRen *lar) /* create Z tiles (for compression): this system is 24 bits!!! */ compress_shadowbuf(shb, rectz, lar->mode & LA_SQUARE); - if(re->test_break()) + if(re->test_break(re->tbh)) break; } @@ -457,13 +457,13 @@ static void *do_shadow_thread(void *re_v) lar->thread_ready= 1; BLI_unlock_thread(LOCK_CUSTOM1); } - } while(lar && !re->test_break()); + } while(lar && !re->test_break(re->tbh)); return NULL; } static volatile int g_break= 0; -static int thread_break(void) +static int thread_break(void *unused) { return g_break; } @@ -473,7 +473,7 @@ void threaded_makeshadowbufs(Render *re) ListBase threads; LampRen *lar; int a, totthread= 0; - int (*test_break)(void); + int (*test_break)(void *); /* count number of threads to use */ if(G.rendering) { @@ -488,7 +488,7 @@ void threaded_makeshadowbufs(Render *re) if(totthread <= 1) { for(lar=re->lampren.first; lar; lar= lar->next) { - if(re->test_break()) break; + if(re->test_break(re->tbh)) break; if(lar->shb) { /* if type is irregular, this only sets the perspective matrix and autoclips */ makeshadowbuf(re, lar); @@ -512,7 +512,7 @@ void threaded_makeshadowbufs(Render *re) /* keep rendering as long as there are shadow buffers not ready */ do { - if((g_break=test_break())) + if((g_break=test_break(re->tbh))) break; PIL_sleep_ms(50); diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 9bde6675798..7bb2aef2e6e 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -852,7 +852,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) float (*co)[3] = NULL, (*color)[3] = NULL, *area = NULL; int totpoint = 0, osa, osaflag, partsdone; - if(re->test_break()) + if(re->test_break(re->tbh)) return; points.first= points.last= NULL; @@ -888,7 +888,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) return; /* merge points together into a single buffer */ - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { for(totpoint=0, p=points.first; p; p=p->next) totpoint += p->totpoint; @@ -913,7 +913,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) BLI_freelistN(&points); /* build tree */ - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { SSSData *sss= MEM_callocN(sizeof(*sss), "SSSData"); float ior= mat->sss_ior, cfac= mat->sss_colfac; float *col= mat->sss_col, *radius= mat->sss_radius; @@ -981,7 +981,7 @@ void make_sss_tree(Render *re) re->sss_hash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); re->i.infostr= "SSS preprocessing"; - re->stats_draw(&re->i); + re->stats_draw(re->sdh, &re->i); 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)) diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 05e36160f0e..3c8c1640b75 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -773,7 +773,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, RenderLayer *rl, APixstrand float z[4], bounds[4], winmat[4][4]; int a, b, c, i, totsegment, clip[4]; - if(re->test_break()) + if(re->test_break(re->tbh)) return 0; if(re->totstrand == 0) return 0; @@ -881,7 +881,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, RenderLayer *rl, APixstrand } } - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { /* convert list to array and sort */ sortsegments= MEM_mallocN(sizeof(StrandSortSegment)*totsegment, "StrandSortSegment"); for(a=0, sortseg=firstseg; a<totsegment; a++, sortseg=sortseg->next) @@ -893,11 +893,11 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, RenderLayer *rl, APixstrand spart.totapixbuf= MEM_callocN(sizeof(int)*pa->rectx*pa->recty, "totapixbuf"); - if(!re->test_break()) { + if(!re->test_break(re->tbh)) { /* render segments in sorted order */ sortseg= sortsegments; for(a=0; a<totsegment; a++, sortseg++) { - if(re->test_break()) + if(re->test_break(re->tbh)) break; obi= &re->objectinstance[sortseg->obi]; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index f2169ceea12..d9fc075c1c4 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -79,11 +79,9 @@ extern struct Render R; -/* note; this is called WITH RENDER IS NULL in src/drawview.c for animated - background image, option should move to kernel */ void init_render_texture(Render *re, Tex *tex) { - int cfra= G.scene->r.cfra; + int cfra= re->scene->r.cfra; if(re) cfra= re->r.cfra; @@ -95,7 +93,7 @@ void init_render_texture(Render *re, Tex *tex) if(tex->type==TEX_PLUGIN) { if(tex->plugin && tex->plugin->doit) { if(tex->plugin->cfra) { - *(tex->plugin->cfra)= frame_to_float(cfra); + *(tex->plugin->cfra)= (float)cfra; //frame_to_float(re->scene, cfra); // XXX old animsys - timing stuff to be fixed } } } @@ -718,7 +716,7 @@ static int evalnodes(Tex *tex, float *texvec, TexResult *texres, short thread, s short rv = TEX_INT; bNodeTree *nodes = tex->nodetree; - ntreeTexExecTree(nodes, texres, texvec, 0, thread, tex, which_output); + ntreeTexExecTree(nodes, texres, texvec, 0, thread, tex, which_output, R.r.cfra); if(texres->nor) rv |= TEX_NOR; rv |= TEX_RGB; diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 509ac81c58b..b68cecce7bd 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -2495,7 +2495,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int } } - if((a & 255)==255 && re->test_break()) + if((a & 255)==255 && re->test_break(re->tbh)) break; } @@ -2544,13 +2544,13 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int } } - if((a & 255)==255 && re->test_break()) + if((a & 255)==255 && re->test_break(re->tbh)) break; } } } - if(re->test_break()) + if(re->test_break(re->tbh)) break; } @@ -3512,13 +3512,13 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, Re } } if((v & 255)==255) - if(R.test_break()) + if(R.test_break(R.tbh)) break; } } } - if(R.test_break()) break; + if(R.test_break(R.tbh)) break; } for(zsample=0; zsample<samples; zsample++) { @@ -4013,7 +4013,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas unsigned short *ztramask= NULL, filled; /* looks nicer for calling code */ - if(R.test_break()) + if(R.test_break(R.tbh)) return NULL; if(R.osa>16) { /* MAX_OSA */ @@ -4096,7 +4096,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas apstrand= aprectstrand; od= offs; - if(R.test_break()) + if(R.test_break(R.tbh)) break; for(x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, ap++, apstrand++, pass+=4, od++) { |