diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index de662b47c4d..21f856a1396 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -235,7 +235,8 @@ def enable(module_name, default_set=True): # reload if the mtime changes mod = sys.modules.get(module_name) - if mod: + # chances of the file _not_ existing are low, but it could be removed + if mod and os.path.exists(mod.__file__): mod.__addon_enabled__ = False mtime_orig = getattr(mod, "__time__", 0) mtime_new = os.path.getmtime(mod.__file__) @@ -252,6 +253,7 @@ def enable(module_name, default_set=True): # Split registering up into 3 steps so we can undo # if it fails par way through. + # 1) try import try: mod = __import__(module_name) diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index fa0e886b784..ecf74b1d8e1 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1178,8 +1178,7 @@ int object_remove_material_slot(Object *ob) } -/* r g b = current value, col = new value, fac==0 is no change */ -/* if g==NULL, it only does r channel */ +/* r_col = current value, col = new value, fac==0 is no change */ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) { float tmp, facm= 1.0f-fac; @@ -1187,165 +1186,137 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) switch (type) { case MA_RAMP_BLEND: r_col[0] = facm*(r_col[0]) + fac*col[0]; - if(r_col[1]) { - r_col[1] = facm*(r_col[1]) + fac*col[1]; - r_col[2] = facm*(r_col[2]) + fac*col[2]; - } - break; + r_col[1] = facm*(r_col[1]) + fac*col[1]; + r_col[2] = facm*(r_col[2]) + fac*col[2]; + break; case MA_RAMP_ADD: r_col[0] += fac*col[0]; - if(r_col[1]) { - r_col[1] += fac*col[1]; - r_col[2] += fac*col[2]; - } - break; + r_col[1] += fac*col[1]; + r_col[2] += fac*col[2]; + break; case MA_RAMP_MULT: r_col[0] *= (facm + fac*col[0]); - if(r_col[1]) { - r_col[1] *= (facm + fac*col[1]); - r_col[2] *= (facm + fac*col[2]); - } - break; + r_col[1] *= (facm + fac*col[1]); + r_col[2] *= (facm + fac*col[2]); + break; case MA_RAMP_SCREEN: r_col[0] = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - r_col[0]); - if(r_col[1]) { - r_col[1] = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - r_col[1]); - r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]); - } - break; + r_col[1] = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - r_col[1]); + r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]); + break; case MA_RAMP_OVERLAY: if(r_col[0] < 0.5f) r_col[0] *= (facm + 2.0f*fac*col[0]); else r_col[0] = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - r_col[0]); - if(r_col[1]) { - if(r_col[1] < 0.5f) - r_col[1] *= (facm + 2.0f*fac*col[1]); - else - r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]); - if(r_col[2] < 0.5f) - r_col[2] *= (facm + 2.0f*fac*col[2]); - else - r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]); - } - break; + if(r_col[1] < 0.5f) + r_col[1] *= (facm + 2.0f*fac*col[1]); + else + r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]); + if(r_col[2] < 0.5f) + r_col[2] *= (facm + 2.0f*fac*col[2]); + else + r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]); + break; case MA_RAMP_SUB: r_col[0] -= fac*col[0]; - if(r_col[1]) { - r_col[1] -= fac*col[1]; - r_col[2] -= fac*col[2]; - } - break; + r_col[1] -= fac*col[1]; + r_col[2] -= fac*col[2]; + break; case MA_RAMP_DIV: if(col[0]!=0.0f) r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0]; - if(r_col[1]) { - if(col[1]!=0.0f) - r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1]; - if(col[2]!=0.0f) - r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2]; - } - break; + if(col[1]!=0.0f) + r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1]; + if(col[2]!=0.0f) + r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2]; + break; case MA_RAMP_DIFF: r_col[0] = facm*(r_col[0]) + fac*fabsf(r_col[0]-col[0]); - if(r_col[1]) { - r_col[1] = facm*(r_col[1]) + fac*fabsf(r_col[1]-col[1]); - r_col[2] = facm*(r_col[2]) + fac*fabsf(r_col[2]-col[2]); - } - break; + r_col[1] = facm*(r_col[1]) + fac*fabsf(r_col[1]-col[1]); + r_col[2] = facm*(r_col[2]) + fac*fabsf(r_col[2]-col[2]); + break; case MA_RAMP_DARK: - tmp=col[0]+((1-col[0])*facm); + tmp=col[0]+((1-col[0])*facm); if(tmp < r_col[0]) r_col[0]= tmp; - if(r_col[1]) { - tmp=col[1]+((1-col[1])*facm); - if(tmp < r_col[1]) r_col[1]= tmp; - tmp=col[2]+((1-col[2])*facm); - if(tmp < r_col[2]) r_col[2]= tmp; - } - break; + tmp=col[1]+((1-col[1])*facm); + if(tmp < r_col[1]) r_col[1]= tmp; + tmp=col[2]+((1-col[2])*facm); + if(tmp < r_col[2]) r_col[2]= tmp; + break; case MA_RAMP_LIGHT: tmp= fac*col[0]; if(tmp > r_col[0]) r_col[0]= tmp; - if(r_col[1]) { - tmp= fac*col[1]; - if(tmp > r_col[1]) r_col[1]= tmp; - tmp= fac*col[2]; - if(tmp > r_col[2]) r_col[2]= tmp; - } - break; - case MA_RAMP_DODGE: - - + tmp= fac*col[1]; + if(tmp > r_col[1]) r_col[1]= tmp; + tmp= fac*col[2]; + if(tmp > r_col[2]) r_col[2]= tmp; + break; + case MA_RAMP_DODGE: if(r_col[0] !=0.0f){ tmp = 1.0f - fac*col[0]; if(tmp <= 0.0f) r_col[0] = 1.0f; else if ((tmp = (r_col[0]) / tmp)> 1.0f) r_col[0] = 1.0f; - else + else r_col[0] = tmp; } - if(r_col[1]) { - if(r_col[1] !=0.0f){ - tmp = 1.0f - fac*col[1]; - if(tmp <= 0.0f ) - r_col[1] = 1.0f; - else if ((tmp = (r_col[1]) / tmp) > 1.0f ) - r_col[1] = 1.0f; - else - r_col[1] = tmp; - } - if(r_col[2] !=0.0f){ - tmp = 1.0f - fac*col[2]; - if(tmp <= 0.0f) - r_col[2] = 1.0f; - else if ((tmp = (r_col[2]) / tmp) > 1.0f ) - r_col[2] = 1.0f; - else - r_col[2] = tmp; - } - + if(r_col[1] !=0.0f){ + tmp = 1.0f - fac*col[1]; + if(tmp <= 0.0f ) + r_col[1] = 1.0f; + else if ((tmp = (r_col[1]) / tmp) > 1.0f ) + r_col[1] = 1.0f; + else + r_col[1] = tmp; } - break; + if(r_col[2] !=0.0f){ + tmp = 1.0f - fac*col[2]; + if(tmp <= 0.0f) + r_col[2] = 1.0f; + else if ((tmp = (r_col[2]) / tmp) > 1.0f ) + r_col[2] = 1.0f; + else + r_col[2] = tmp; + } + break; case MA_RAMP_BURN: - tmp = facm + fac*col[0]; - + if(tmp <= 0.0f) r_col[0] = 0.0f; else if (( tmp = (1.0f - (1.0f - (r_col[0])) / tmp )) < 0.0f) r_col[0] = 0.0f; else if (tmp > 1.0f) r_col[0]=1.0f; - else + else r_col[0] = tmp; - if(r_col[1]) { - tmp = facm + fac*col[1]; - if(tmp <= 0.0f) + tmp = facm + fac*col[1]; + if(tmp <= 0.0f) + r_col[1] = 0.0f; + else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f ) r_col[1] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f ) - r_col[1] = 0.0f; - else if(tmp >1.0f) - r_col[1]=1.0f; - else - r_col[1] = tmp; + else if(tmp >1.0f) + r_col[1]=1.0f; + else + r_col[1] = tmp; - tmp = facm + fac*col[2]; - if(tmp <= 0.0f) + tmp = facm + fac*col[2]; + if(tmp <= 0.0f) + r_col[2] = 0.0f; + else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f ) r_col[2] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f ) - r_col[2] = 0.0f; - else if(tmp >1.0f) - r_col[2]= 1.0f; - else - r_col[2] = tmp; - } - break; - case MA_RAMP_HUE: - if(r_col[1]){ + else if(tmp >1.0f) + r_col[2]= 1.0f; + else + r_col[2] = tmp; + break; + case MA_RAMP_HUE: + { float rH,rS,rV; - float colH,colS,colV; + float colH,colS,colV; float tmpr,tmpg,tmpb; rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); if(colS!=0 ){ @@ -1356,9 +1327,9 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) r_col[2] = facm*(r_col[2]) + fac*tmpb; } } - break; - case MA_RAMP_SAT: - if(r_col[1]){ + break; + case MA_RAMP_SAT: + { float rH,rS,rV; float colH,colS,colV; rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); @@ -1367,18 +1338,18 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2); } } - break; - case MA_RAMP_VAL: - if(r_col[1]){ + break; + case MA_RAMP_VAL: + { float rH,rS,rV; float colH,colS,colV; rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2); } - break; - case MA_RAMP_COLOR: - if(r_col[1]){ + break; + case MA_RAMP_COLOR: + { float rH,rS,rV; float colH,colS,colV; float tmpr,tmpg,tmpb; @@ -1391,12 +1362,12 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) r_col[2] = facm*(r_col[2]) + fac*tmpb; } } - break; - case MA_RAMP_SOFT: - if (r_col[1]){ - float scr, scg, scb; + break; + case MA_RAMP_SOFT: + { + float scr, scg, scb; - /* first calculate non-fac based Screen mix */ + /* first calculate non-fac based Screen mix */ scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]); scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]); scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]); @@ -1404,25 +1375,23 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) r_col[0] = facm*(r_col[0]) + fac*(((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr)); r_col[1] = facm*(r_col[1]) + fac*(((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg)); r_col[2] = facm*(r_col[2]) + fac*(((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb)); - } - break; - case MA_RAMP_LINEAR: - if (col[0] > 0.5f) + } + break; + case MA_RAMP_LINEAR: + if (col[0] > 0.5f) r_col[0] = r_col[0] + fac*(2.0f*(col[0]-0.5f)); - else + else r_col[0] = r_col[0] + fac*(2.0f*(col[0]) - 1.0f); - if (r_col[1]){ - if (col[1] > 0.5f) - r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f)); - else - r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f); - if (col[2] > 0.5f) - r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f)); - else - r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f); - } - break; - } + if (col[1] > 0.5f) + r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f)); + else + r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f); + if (col[2] > 0.5f) + r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f)); + else + r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f); + break; + } } /* copy/paste buffer, if we had a propper py api that would be better */ diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index f98919fadd3..a46ba78aef0 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -55,6 +55,7 @@ void *BLI_mempool_calloc(BLI_mempool *pool); void BLI_mempool_free(BLI_mempool *pool, void *addr); void BLI_mempool_destroy(BLI_mempool *pool); int BLI_mempool_count(BLI_mempool *pool); +void *BLI_mempool_findelem(BLI_mempool *pool, const int index); /** iteration stuff. note: this may easy to produce bugs with **/ /*private structure*/ diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 19ae89da8ea..f8da524d097 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -68,8 +68,9 @@ typedef struct BLI_mempool_chunk { struct BLI_mempool { struct ListBase chunks; - int esize, csize, pchunk; /* size of elements and chunks in bytes - * and number of elements per chunk*/ + int esize; /* element size in bytes */ + int csize; /* chunk size in bytes */ + int pchunk; /* number of elements per chunk */ short use_sysmalloc, allow_iter; /* keeps aligned to 16 bits */ @@ -240,6 +241,23 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) } } +void *BLI_mempool_findelem(BLI_mempool *pool, const int index) +{ + if ((index >= 0) && (index < pool->totused)) { + BLI_mempool_chunk *mpchunk; + int i= 0; + + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + if (index < i + pool->pchunk) { + return ((char *)mpchunk->data) + (pool->esize * (index - i)); + } + i += pool->pchunk; + } + } + + return NULL; +} + void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) { if (!pool->allow_iter) { diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 6c68ba0ea71..c647ff3df53 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -383,6 +383,10 @@ static char *layer_menu(RenderResult *rr, short *UNUSED(curlay)) a+= sprintf(str+a, "|Composite %%x0"); nr= 1; } + else if(rr->rect32) { + a+= sprintf(str+a, "|Sequence %%x0"); + nr= 1; + } for(rl= rr->layers.first; rl; rl= rl->next, nr++) { a+= sprintf(str+a, "|%s %%x%d", rl->name, nr); } @@ -443,7 +447,10 @@ static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v) { RenderResult *rr= rr_v; ImageUser *iuser= iuser_v; - int tot= BLI_countlist(&rr->layers) + (rr->rectf?1:0); /* fake compo result layer */ + int tot= BLI_countlist(&rr->layers); + + if(rr->rectf || rr->rect32) + tot++; /* fake compo/sequencer layer */ if(iuser->layerlayer++; @@ -468,7 +475,11 @@ static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v) RenderLayer *rl= BLI_findlink(&rr->layers, iuser->layer); if(rl) { - int tot= BLI_countlist(&rl->passes) + (rl->rectf?1:0); /* builtin render result has no combined pass in list */ + int tot= BLI_countlist(&rl->passes); + + if(rr->rectf || rr->rect32) + tot++; /* fake compo/sequencer layer */ + if(iuser->passpass++; BKE_image_multilayer_index(rr, iuser); @@ -509,7 +520,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image uiBlock *block= uiLayoutGetBlock(layout); uiBut *but; RenderLayer *rl= NULL; - int wmenu1, wmenu2, wmenu3; + int wmenu1, wmenu2, wmenu3, layer; char *strp; uiLayoutRow(layout, 1); @@ -532,8 +543,12 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, UI_UNIT_Y, &iuser->layer, 0,0,0,0, "Select Layer"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); + + layer = iuser->layer; + if(rr->rectf || rr->rect32) + layer--; /* fake compo/sequencer layer */ - rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */ + rl= BLI_findlink(&rr->layers, layer); /* return NULL is meant to be */ strp= pass_menu(rl, &iuser->pass); but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu3, UI_UNIT_Y, &iuser->pass, 0,0,0,0, "Select Pass"); uiButSetFunc(but, image_multi_cb, rr, iuser); diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 73d954057c9..c31dadff3e1 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -151,9 +151,9 @@ PyObject *BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent) case IDP_GROUP: return idprop_py_from_idp_group(id, prop, parent); case IDP_ARRAY: - return idprop_py_from_idp_idparray(id, prop); + return idprop_py_from_idp_array(id, prop); case IDP_IDPARRAY: /* this could be better a internal type */ - idprop_py_from_idp_array(id, prop); + return idprop_py_from_idp_idparray(id, prop); default: Py_RETURN_NONE; } diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h index e521479bbcd..02a94e56462 100644 --- a/source/blender/render/extern/include/RE_engine.h +++ b/source/blender/render/extern/include/RE_engine.h @@ -107,6 +107,8 @@ void RE_engine_report(RenderEngine *engine, int type, const char *msg); int RE_engine_render(struct Render *re, int do_all); +int RE_engine_is_external(struct Render *re); + /* Engine Types */ void RE_engines_init(void); diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 38ace8d5121..2b44bad82ab 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -113,6 +113,12 @@ RenderEngineType *RE_engines_find(const char *idname) return type; } +int RE_engine_is_external(Render *re) +{ + RenderEngineType *type= RE_engines_find(re->r.engine); + return (type && type->render); +} + /* Create, Free */ RenderEngine *RE_engine_create(RenderEngineType *type) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index c5cea980b04..52fb1eb48dc 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2849,6 +2849,11 @@ static void validate_render_settings(Render *re) if(re->r.osa==0) re->r.scemode &= ~R_FULL_SAMPLE; } else re->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */ + + if(RE_engine_is_external(re)) { + /* not supported yet */ + re->r.scemode &= ~(R_EXR_TILE_FILE|R_FULL_SAMPLE); + } } static void update_physics_cache(Render *re, Scene *scene, int UNUSED(anim_init))