svn merge ^/trunk/blender -r42172:42182

This commit is contained in:
Campbell Barton 2011-11-27 01:42:56 +00:00
commit 7553440aa4
9 changed files with 173 additions and 155 deletions

@ -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)

@ -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 */

@ -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*/

@ -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) {

@ -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->layer<tot-1) {
iuser->layer++;
@ -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->pass<tot-1) {
iuser->pass++;
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);

@ -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;
}

@ -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);

@ -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)

@ -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))