diff options
Diffstat (limited to 'source/blender')
28 files changed, 489 insertions, 104 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index f1f4653f092..398d203709f 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -53,6 +53,7 @@ int brush_clone_image_delete(struct Brush *brush); /* sampling */ float brush_sample_falloff(struct Brush *brush, float dist); +float brush_sample_falloff_noalpha(struct Brush *brush, float dist); void brush_sample_tex(struct Brush *brush, float *xy, float *rgba); void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size, struct ImBuf **imbuf); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index c84b690bc49..10791968f79 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -198,8 +198,12 @@ int CustomData_get_layer_index(const struct CustomData *data, int type); int CustomData_get_named_layer_index(const struct CustomData *data, int type, char *name); int CustomData_get_active_layer_index(const struct CustomData *data, int type); int CustomData_get_render_layer_index(const struct CustomData *data, int type); +int CustomData_get_clone_layer_index(const struct CustomData *data, int type); +int CustomData_get_mask_layer_index(const struct CustomData *data, int type); int CustomData_get_active_layer(const struct CustomData *data, int type); int CustomData_get_render_layer(const struct CustomData *data, int type); +int CustomData_get_clone_layer(const struct CustomData *data, int type); +int CustomData_get_mask_layer(const struct CustomData *data, int type); /* copies the data from source to the data element at index in the first * layer of type @@ -227,10 +231,14 @@ void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, voi /* sets the nth layer of type as active */ void CustomData_set_layer_active(struct CustomData *data, int type, int n); void CustomData_set_layer_render(struct CustomData *data, int type, int n); +void CustomData_set_layer_clone(struct CustomData *data, int type, int n); +void CustomData_set_layer_mask(struct CustomData *data, int type, int n); /* same as above but works with an index from CustomData_get_layer_index */ void CustomData_set_layer_active_index(struct CustomData *data, int type, int n); void CustomData_set_layer_render_index(struct CustomData *data, int type, int n); +void CustomData_set_layer_clone_index(struct CustomData *data, int type, int n); +void CustomData_set_layer_mask_index(struct CustomData *data, int type, int n); /* adds flag to the layer flags */ void CustomData_set_layer_flag(struct CustomData *data, int type, int flag); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index fa3a654c1c2..1c5b6b124b2 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -401,6 +401,8 @@ struct TexResult; #define TEX_NODE_ROTATE 114 #define TEX_NODE_VIEWER 115 #define TEX_NODE_TRANSLATE 116 +#define TEX_NODE_COORD 117 +#define TEX_NODE_DISTANCE 118 /* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ #define TEX_NODE_PROC 200 diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 1c53af97dbb..021f76fd2f1 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -328,6 +328,23 @@ float brush_sample_falloff(Brush *brush, float dist) return 0.0f; } +float brush_sample_falloff_noalpha(Brush *brush, float dist) +{ + float outer, inner; + + outer = brush->size >> 1; + inner = outer*brush->innerradius; + + if (dist <= inner) { + return 1.0f; + } + else if ((dist < outer) && (inner < outer)) { + return 1.0f - sqrt((dist - inner)/(outer - inner)); + } + else + return 0.0f; +} + void brush_sample_tex(Brush *brush, float *xy, float *rgba) { MTex *mtex= brush->mtex[brush->texact]; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 1a671dfe771..7fa4f406c7b 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -833,7 +833,6 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1"); resolu= (resolu*SEGMENTSU(nu)); - if((nu->flagu & CU_CYCLIC)==0) resolu++; if(resolu==0) { MEM_freeN(sum); @@ -1685,7 +1684,6 @@ void makeBevelList(Object *ob) else if((nu->type & 7)==CU_NURBS) { if(nu->pntsv==1) { len= (resolu*SEGMENTSU(nu)); - if((nu->flagu & CU_CYCLIC)==0) len++; bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList3"); BLI_addtail(&(cu->bev), bl); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e93266c85f3..05271aa59a7 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -606,7 +606,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, { const LayerTypeInfo *typeInfo; CustomDataLayer *layer, *newlayer; - int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0; + int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0; for(i = 0; i < source->totlayer; ++i) { layer = &source->layers[i]; @@ -618,6 +618,8 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, number = 0; lastactive = layer->active; lastrender = layer->active_rnd; + lastclone = layer->active_clone; + lastmask = layer->active_mask; lasttype = type; } else @@ -637,6 +639,8 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, if(newlayer) { newlayer->active = lastactive; newlayer->active_rnd = lastrender; + newlayer->active_clone = lastclone; + newlayer->active_mask = lastmask; } } } @@ -736,6 +740,28 @@ int CustomData_get_render_layer_index(const CustomData *data, int type) return -1; } +int CustomData_get_clone_layer_index(const CustomData *data, int type) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + return i + data->layers[i].active_clone; + + return -1; +} + +int CustomData_get_mask_layer_index(const CustomData *data, int type) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + return i + data->layers[i].active_mask; + + return -1; +} + int CustomData_get_active_layer(const CustomData *data, int type) { int i; @@ -758,6 +784,27 @@ int CustomData_get_render_layer(const CustomData *data, int type) return -1; } +int CustomData_get_clone_layer(const CustomData *data, int type) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + return data->layers[i].active_clone; + + return -1; +} + +int CustomData_get_mask_layer(const CustomData *data, int type) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + return data->layers[i].active_mask; + + return -1; +} void CustomData_set_layer_active(CustomData *data, int type, int n) { @@ -777,6 +824,24 @@ void CustomData_set_layer_render(CustomData *data, int type, int n) data->layers[i].active_rnd = n; } +void CustomData_set_layer_clone(CustomData *data, int type, int n) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + data->layers[i].active_clone = n; +} + +void CustomData_set_layer_mask(CustomData *data, int type, int n) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + data->layers[i].active_mask = n; +} + /* for using with an index from CustomData_get_active_layer_index and CustomData_get_render_layer_index */ void CustomData_set_layer_active_index(CustomData *data, int type, int n) { @@ -796,6 +861,23 @@ void CustomData_set_layer_render_index(CustomData *data, int type, int n) data->layers[i].active_rnd = n-i; } +void CustomData_set_layer_clone_index(CustomData *data, int type, int n) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + data->layers[i].active_clone = n-i; +} + +void CustomData_set_layer_mask_index(CustomData *data, int type, int n) +{ + int i; + + for(i=0; i < data->totlayer; ++i) + if(data->layers[i].type == type) + data->layers[i].active_mask = n-i; +} void CustomData_set_layer_flag(struct CustomData *data, int type, int flag) { @@ -882,9 +964,13 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, if(index > 0 && data->layers[index-1].type == type) { data->layers[index].active = data->layers[index-1].active; data->layers[index].active_rnd = data->layers[index-1].active_rnd; + data->layers[index].active_clone = data->layers[index-1].active_clone; + data->layers[index].active_mask = data->layers[index-1].active_mask; } else { data->layers[index].active = 0; data->layers[index].active_rnd = 0; + data->layers[index].active_clone = 0; + data->layers[index].active_mask = 0; } customData_update_offsets(data); @@ -944,6 +1030,8 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index) for (; i < data->totlayer && data->layers[i].type == type; i++) { data->layers[i].active--; data->layers[i].active_rnd--; + data->layers[i].active_clone--; + data->layers[i].active_mask--; } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 44aa439ee3e..84025204ee4 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -890,7 +890,6 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) } else if((nu->type & 7)==CU_NURBS) { len= (resolu*SEGMENTSU(nu)); - if((nu->flagu & CU_CYCLIC)==0) len++; dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); @@ -1384,7 +1383,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender) for (nu=nubase->first; nu; nu=nu->next) { if(forRender || nu->hide==0) { if(nu->pntsv==1) { - len= nu->pntsu*nu->resolu; + len= SEGMENTSU(nu)*nu->resolu; dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index e189891d884..0e43ecd61e1 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2886,6 +2886,8 @@ static void registerTextureNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &tex_node_curve_time); nodeRegisterType(ntypelist, &tex_node_invert); nodeRegisterType(ntypelist, &tex_node_hue_sat); + nodeRegisterType(ntypelist, &tex_node_coord); + nodeRegisterType(ntypelist, &tex_node_distance); nodeRegisterType(ntypelist, &tex_node_output); nodeRegisterType(ntypelist, &tex_node_viewer); diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h index e840ffd167a..ed202c11429 100644 --- a/source/blender/blenlib/BLI_linklist.h +++ b/source/blender/blenlib/BLI_linklist.h @@ -45,6 +45,7 @@ typedef struct LinkNode { } LinkNode; int BLI_linklist_length (struct LinkNode *list); +int BLI_linklist_index (struct LinkNode *list, void *ptr); void BLI_linklist_reverse (struct LinkNode **listp); diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index 34d732e1862..a2954f8fa0d 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -50,6 +50,7 @@ typedef struct MemArena MemArena; struct MemArena* BLI_memarena_new (int bufsize); void BLI_memarena_free (struct MemArena *ma); +void BLI_memarena_use_malloc (struct MemArena *ma); void BLI_memarena_use_calloc (struct MemArena *ma); void* BLI_memarena_alloc (struct MemArena *ma, int size); diff --git a/source/blender/blenlib/SConscript b/source/blender/blenlib/SConscript index 01a9a1eab0e..f664b75af5a 100644 --- a/source/blender/blenlib/SConscript +++ b/source/blender/blenlib/SConscript @@ -23,7 +23,7 @@ if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw'): +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross'): incs += ' ' + env['BF_PTHREADS_INC'] env.BlenderLib ( 'bf_blenlib', sources, Split(incs), Split(defs), libtype=['core', 'intern', 'player'], priority = [85,150,195], compileflags =cflags ) diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index 506a1036ed6..962bbeea373 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -50,6 +50,18 @@ int BLI_linklist_length(LinkNode *list) { } } +int BLI_linklist_index(struct LinkNode *list, void *ptr) +{ + int index; + + for (index = 0; list; list= list->next, index++) { + if (list->link == ptr) + return index; + } + + return -1; +} + void BLI_linklist_reverse(LinkNode **listp) { LinkNode *rhead= NULL, *cur= *listp; diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c index 69dd13cd335..87d2f0426b2 100644 --- a/source/blender/blenlib/intern/BLI_memarena.c +++ b/source/blender/blenlib/intern/BLI_memarena.c @@ -60,6 +60,10 @@ void BLI_memarena_use_calloc(MemArena *ma) { ma->use_calloc= 1; } +void BLI_memarena_use_malloc(MemArena *ma) { + ma->use_calloc= 0; +} + void BLI_memarena_free(MemArena *ma) { BLI_linklist_free(ma->bufs, (void(*)(void*)) MEM_freeN); MEM_freeN(ma); diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 0f2226fc872..a47d37eb69a 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -1351,8 +1351,8 @@ void Mat4ToQuat( float m[][4], float *q) void QuatOne(float *q) { - q[0]= q[2]= q[3]= 0.0; - q[1]= 1.0; + q[0]= 1.0; + q[1]= q[2]= q[3]= 0.0; } void NormalQuat(float *q) diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index ca7a376d3a2..8ba03ad1343 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -47,9 +47,9 @@ #include <time.h> #include <sys/stat.h> -#if defined (__sun__) || defined (__sun) +#if defined (__sun__) || defined (__sun) || defined (__sgi) #include <sys/statvfs.h> /* Other modern unix os's should probably use this also */ -#elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sgi) || defined(__sparc) || defined(__sparc__)) +#elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) #include <sys/statfs.h> #endif @@ -179,7 +179,7 @@ double BLI_diskfree(char *dir) return (double) (freec*bytesps*sectorspc); #else -#if defined (__sun__) || defined (__sun) +#if defined (__sun__) || defined (__sun) || defined (__sgi) struct statvfs disk; #else struct statfs disk; @@ -204,9 +204,9 @@ double BLI_diskfree(char *dir) return -1; #endif -#if defined (__sun__) || defined (__sun) +#if defined (__sun__) || defined (__sun) || defined (__sgi) if (statvfs(name, &disk)) return(-1); -#elif !defined(__FreeBSD__) && !defined(linux) && (defined (__sgi) || defined(__sparc) || defined(__sparc__)) +#elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) /* WARNING - This may not be supported by geeneric unix os's - Campbell */ if (statfs(name, &disk, sizeof(struct statfs), 0)) return(-1); #endif diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 9df8bbc81e3..07c02b8024f 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -42,7 +42,7 @@ /* for checking system threads - BLI_system_thread_count */ #ifdef WIN32 -#include "Windows.h" +#include "windows.h" #elif defined(__APPLE__) #include <sys/types.h> #include <sys/sysctl.h> diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fa44f00c607..df2c680c951 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8259,6 +8259,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) { + Scene *sce; + + /* Note, these will need to be added for painting */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->toolsettings->imapaint.seam_bleed = 2; + sce->toolsettings->imapaint.normal_angle = 80; + } + } + if (main->versionfile < 250) { bScreen *screen; diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index d4d8030bf10..8bc1439fd09 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -403,9 +403,14 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf); * * @attention defined in imageprocess.c */ -void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float x, float y, int xout, int yout); +void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); + +void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); +void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); +void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); + /** * Change the ordering of the color bytes pointed to by rect from * rgba to abgr. size * 4 color bytes are reordered. diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index d7f1ab4419d..fe7e26eac2b 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -80,6 +80,17 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf) } } } +static void pixel_from_buffer(struct ImBuf *ibuf, unsigned char **outI, float **outF, int x, int y) + +{ + int offset = ibuf->x * y * 4 + 4*x; + + if (ibuf->rect) + *outI= (unsigned char *)ibuf->rect + offset; + + if (ibuf->rect_float) + *outF= (float *)ibuf->rect_float + offset; +} /************************************************************************** * INTERPOLATIONS @@ -92,32 +103,40 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf) /* More info: http://wiki.blender.org/index.php/User:Damiles#Bicubic_pixel_interpolation */ /* function assumes out to be zero'ed, only does RGBA */ + +static float P(float k){ + float p1, p2, p3, p4; + p1 = MAX2(k+2.0f,0); + p2 = MAX2(k+1.0f,0); + p3 = MAX2(k,0); + p4 = MAX2(k-1.0f,0); + return (float)(1.0f/6.0f)*( p1*p1*p1 - 4.0f * p2*p2*p2 + 6.0f * p3*p3*p3 - 4.0f * p4*p4*p4); +} + + +#if 0 +/* older, slower function, works the same as above */ static float P(float k){ return (float)(1.0f/6.0f)*( pow( MAX2(k+2.0f,0) , 3.0f ) - 4.0f * pow( MAX2(k+1.0f,0) , 3.0f ) + 6.0f * pow( MAX2(k,0) , 3.0f ) - 4.0f * pow( MAX2(k-1.0f,0) , 3.0f)); } +#endif -void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout) +void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v) { int i,j,n,m,x1,y1; - unsigned char *dataI,*outI; - float a,b,w,wx,wy[4], outR,outG,outB,outA,*dataF,*outF; - int do_rect, do_float; - - if (in == NULL) return; - if (in->rect == NULL && in->rect_float == NULL) return; + unsigned char *dataI; + float a,b,w,wx,wy[4], outR,outG,outB,outA,*dataF; - do_rect= (out->rect != NULL); - do_float= (out->rect_float != NULL); + /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */ - i= (int)floor(x); - j= (int)floor(y); - a= x - i; - b= y - j; + i= (int)floor(u); + j= (int)floor(v); + a= u - i; + b= v - j; - outR= 0.0f; - outG= 0.0f; - outB= 0.0f; - outA= 0.0f; + outR = outG = outB = outA = 0.0f; + +/* Optimized and not so easy to read */ /* avoid calling multiple times */ wy[0] = P(b-(-1)); @@ -137,14 +156,14 @@ void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in /* except that would call P() 16 times per pixel therefor pow() 64 times, better precalc these */ w = wx * wy[m+1]; - if (do_float) { + if (outF) { dataF= in->rect_float + in->x * y1 * 4 + 4*x1; outR+= dataF[0] * w; outG+= dataF[1] * w; outB+= dataF[2] * w; outA+= dataF[3] * w; } - if (do_rect) { + if (outI) { dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1; outR+= dataI[0] * w; outG+= dataI[1] * w; @@ -155,15 +174,42 @@ void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in } } } - if (do_rect) { - outI= (unsigned char *)out->rect + out->x * yout * 4 + 4*xout; + +/* Done with optimized part */ + +#if 0 + /* older, slower function, works the same as above */ + for(n= -1; n<= 2; n++){ + for(m= -1; m<= 2; m++){ + x1= i+n; + y1= j+m; + if (x1>0 && x1 < in->x && y1>0 && y1<in->y) { + if (do_float) { + dataF= in->rect_float + in->x * y1 * 4 + 4*x1; + outR+= dataF[0] * P(n-a) * P(b-m); + outG+= dataF[1] * P(n-a) * P(b-m); + outB+= dataF[2] * P(n-a) * P(b-m); + outA+= dataF[3] * P(n-a) * P(b-m); + } + if (do_rect) { + dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1; + outR+= dataI[0] * P(n-a) * P(b-m); + outG+= dataI[1] * P(n-a) * P(b-m); + outB+= dataI[2] * P(n-a) * P(b-m); + outA+= dataI[3] * P(n-a) * P(b-m); + } + } + } + } +#endif + + if (outI) { outI[0]= (int)outR; outI[1]= (int)outG; outI[2]= (int)outB; outI[3]= (int)outA; } - if (do_float) { - outF= (float *)out->rect_float + out->x * yout * 4 + 4*xout; + if (outF) { outF[0]= outR; outF[1]= outG; outF[2]= outB; @@ -171,23 +217,33 @@ void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in } } + +void bicubic_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, int yout) +{ + + unsigned char *outI = NULL; + float *outF = NULL; + + if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) return; + + pixel_from_buffer(out, &outI, &outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */ + + bicubic_interpolation_color(in, outI, outF, u, v); +} + /* function assumes out to be zero'ed, only does RGBA */ /* BILINEAR INTERPOLATION */ -void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, int yout) +void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v) { - float *row1, *row2, *row3, *row4, a, b, *outF; - unsigned char *row1I, *row2I, *row3I, *row4I, *outI; + float *row1, *row2, *row3, *row4, a, b; + unsigned char *row1I, *row2I, *row3I, *row4I; float a_b, ma_b, a_mb, ma_mb; float empty[4]= {0.0f, 0.0f, 0.0f, 0.0f}; unsigned char emptyI[4]= {0, 0, 0, 0}; int y1, y2, x1, x2; - int do_rect, do_float; - - if (in==NULL) return; - if (in->rect==NULL && in->rect_float==NULL) return; - - do_rect= (out->rect != NULL); - do_float= (out->rect_float != NULL); + + + /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */ x1= (int)floor(u); x2= (int)ceil(u); @@ -197,16 +253,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i // sample area entirely outside image? if (x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1) return; - if (do_rect) - outI=(unsigned char *)out->rect + out->x * yout * 4 + 4*xout; - else - outI= NULL; - if (do_float) - outF=(float *)out->rect_float + out->x * yout * 4 + 4*xout; - else - outF= NULL; - - if (do_float) { + if (outF) { // sample including outside of edges of image if (x1<0 || y1<0) row1= empty; else row1= (float *)in->rect_float + in->x * y1 * 4 + 4*x1; @@ -229,7 +276,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i outF[2]= ma_mb*row1[2] + a_mb*row3[2] + ma_b*row2[2]+ a_b*row4[2]; outF[3]= ma_mb*row1[3] + a_mb*row3[3] + ma_b*row2[3]+ a_b*row4[3]; } - if (do_rect) { + if (outI) { // sample including outside of edges of image if (x1<0 || y1<0) row1I= emptyI; else row1I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1; @@ -254,45 +301,44 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i } } +void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, int yout) +{ + + unsigned char *outI = NULL; + float *outF = NULL; + + if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) return; + + pixel_from_buffer(out, &outI, &outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */ + + bilinear_interpolation_color(in, outI, outF, u, v); +} + /* function assumes out to be zero'ed, only does RGBA */ /* NEAREST INTERPOLATION */ -void neareast_interpolation(ImBuf *in, ImBuf *out, float u, float v,int xout, int yout) +void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v) { - float *outF,*dataF; - unsigned char *dataI,*outI; + float *dataF; + unsigned char *dataI; int y1, x1; - int do_rect, do_float; - - if (in==NULL) return; - if (in->rect==NULL && in->rect_float==NULL) return; - - do_rect= (out->rect != NULL); - do_float= (out->rect_float != NULL); + /* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */ + x1= (int)(u); y1= (int)(v); - if (do_rect) - outI=(unsigned char *)out->rect + out->x * yout * 4 + 4*xout; - else - outI= NULL; - if (do_float) - outF=(float *)out->rect_float + out->x * yout * 4 + 4*xout; - else - outF= NULL; - // sample area entirely outside image? if (x1<0 || x1>in->x-1 || y1<0 || y1>in->y-1) return; // sample including outside of edges of image if (x1<0 || y1<0) { - if (do_rect) { + if (outI) { outI[0]= 0; outI[1]= 0; outI[2]= 0; outI[3]= 0; } - if (do_float) { + if (outF) { outF[0]= 0.0f; outF[1]= 0.0f; outF[2]= 0.0f; @@ -300,14 +346,14 @@ void neareast_interpolation(ImBuf *in, ImBuf *out, float u, float v,int xout, in } } else { dataI= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1; - if (do_rect) { + if (outI) { outI[0]= dataI[0]; outI[1]= dataI[1]; outI[2]= dataI[2]; outI[3]= dataI[3]; } dataF= in->rect_float + in->x * y1 * 4 + 4*x1; - if (do_float) { + if (outF) { outF[0]= dataF[0]; outF[1]= dataF[1]; outF[2]= dataF[2]; @@ -315,3 +361,16 @@ void neareast_interpolation(ImBuf *in, ImBuf *out, float u, float v,int xout, in } } } + +void neareast_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout) +{ + + unsigned char *outI = NULL; + float *outF = NULL; + + if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) return; + + pixel_from_buffer(out, &outI, &outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */ + + neareast_interpolation_color(in, outI, outF, x, y); +} diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 6c098e220bb..e6b18641d2a 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -37,6 +37,8 @@ typedef struct CustomDataLayer { int flag; /* general purpose flag */ int active; /* number of the active layer of this type */ int active_rnd; /* number of the layer to render*/ + int active_clone; /* number of the layer to render*/ + int active_mask; /* number of the layer to render*/ char pad[4]; char name[32]; /* layer name */ void *data; /* layer data */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 5397d890789..859b3abd7e2 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -344,7 +344,9 @@ typedef struct TimeMarker { typedef struct ImagePaintSettings { struct Brush *brush; short flag, tool; - int pad3; + + /* for projection painting only */ + short seam_bleed,normal_angle; } ImagePaintSettings; typedef struct ParticleBrushData { @@ -826,6 +828,15 @@ typedef struct Scene { #define IMAGEPAINT_DRAW_TOOL 2 #define IMAGEPAINT_DRAW_TOOL_DRAWING 4 +/* projection painting only */ +#define IMAGEPAINT_PROJECT_DISABLE 8 /* Non projection 3D painting */ +#define IMAGEPAINT_PROJECT_XRAY 16 +#define IMAGEPAINT_PROJECT_BACKFACE 32 +#define IMAGEPAINT_PROJECT_FLAT 64 +#define IMAGEPAINT_PROJECT_LAYER_CLONE 128 +#define IMAGEPAINT_PROJECT_LAYER_MASK 256 +#define IMAGEPAINT_PROJECT_LAYER_MASK_INV 512 + /* toolsettings->uvcalc_flag */ #define UVCALC_FILLHOLES 1 #define UVCALC_NO_ASPECT_CORRECT 2 /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ diff --git a/source/blender/makesdna/DNA_scriptlink_types.h b/source/blender/makesdna/DNA_scriptlink_types.h index 95e20dd004d..9b50eb91a20 100644 --- a/source/blender/makesdna/DNA_scriptlink_types.h +++ b/source/blender/makesdna/DNA_scriptlink_types.h @@ -65,10 +65,12 @@ typedef struct ScriptLink { /* these are special scriptlinks that can be assigned to * a given space in a given ScrArea to: * - (EVENT type) handle events sent to that space; - * - (DRAW type) draw on the space after its own drawing function finishes + * - (EVENT_ALL type): handle release events, too; + * - (DRAW type) draw on the space after its own drawing function finishes. */ -#define SPACEHANDLER_VIEW3D_EVENT 1 -#define SPACEHANDLER_VIEW3D_DRAW 2 +#define SPACEHANDLER_VIEW3D_DRAW 1 +#define SPACEHANDLER_VIEW3D_EVENT 2 +#define SPACEHANDLER_VIEW3D_EVENT_ALL 3 #ifdef __cplusplus diff --git a/source/blender/makesdna/intern/SConscript b/source/blender/makesdna/intern/SConscript index b7d55a0ca1a..4aa8d6a9d54 100644 --- a/source/blender/makesdna/intern/SConscript +++ b/source/blender/makesdna/intern/SConscript @@ -18,9 +18,15 @@ makesdna_tool.Append (CPPPATH = ['#/intern/guardedalloc', '../../makesdna']) if env['OURPLATFORM'] == 'linuxcross': - makesdna_tool.Replace(CC='gcc') - makesdna_tool.Replace(AR='ar') - makesdna_tool.Replace(LINK='gcc') + USE_WINE = True # when cross compiling on linux 64bit this is useful +else: + USE_WINE = False + +if not USE_WINE: + if env['OURPLATFORM'] == 'linuxcross': + makesdna_tool.Replace(CC='gcc') + makesdna_tool.Replace(AR='ar') + makesdna_tool.Replace(LINK='gcc') if sys.platform != 'cygwin': makesdna_tool.Append (CCFLAGS = cflags) @@ -30,7 +36,7 @@ if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'): targetdir = '#'+targetdir makesdna_tool.Append (LIBPATH = targetdir) if env['BF_PROFILE']: - makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS']) + makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_LINKFLAGS']) targetdir = root_build_dir + '/makesdna' @@ -43,7 +49,10 @@ dna_dict = dna.Dictionary() dna.Depends ('dna.c', makesdna) dna.Depends ('dna.c', header_files) if env['OURPLATFORM'] != 'linuxcross': - dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET") + if USE_WINE: + dna.Command ('dna.c', '', 'wine ' + root_build_dir+os.sep+"makesdna $TARGET") + else: + dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET") else: dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET") obj = ['intern/dna.c', 'intern/dna_genfile.c'] diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 7f003cb2b42..7daf32361de 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -23,7 +23,7 @@ # # ***** END GPL LICENSE BLOCK ***** -FILE(GLOB SRC intern/*.c intern/CMP_nodes/*.c intern/SHD_nodes/*.c) +FILE(GLOB SRC intern/*.c intern/CMP_nodes/*.c intern/SHD_nodes/*.c intern/TEX_nodes/*.c) SET(INC . ../../../intern/guardedalloc ../editors/include ../blenlib ../makesdna diff --git a/source/blender/nodes/TEX_node.h b/source/blender/nodes/TEX_node.h index 6be2123b96d..40cb65eacce 100644 --- a/source/blender/nodes/TEX_node.h +++ b/source/blender/nodes/TEX_node.h @@ -52,6 +52,8 @@ extern bNodeType tex_node_curve_rgb; extern bNodeType tex_node_curve_time; extern bNodeType tex_node_invert; extern bNodeType tex_node_hue_sat; +extern bNodeType tex_node_coord; +extern bNodeType tex_node_distance; extern bNodeType tex_node_rotate; extern bNodeType tex_node_translate; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c new file mode 100644 index 00000000000..da487c190af --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c @@ -0,0 +1,66 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti@gmx.net>. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../TEX_util.h" + +static bNodeSocketType outputs[]= { + { SOCK_VECTOR, 0, "Coordinates", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, + { -1, 0, "" } +}; + +static void vectorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + out[0] = coord[0]; + out[1] = coord[1]; + out[2] = coord[2]; +} + +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &vectorfn); + + tex_do_preview(node, out[0], data); +} + +bNodeType tex_node_coord= { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_COORD, + /* name */ "Coordinates", + /* width+range */ 120, 110, 160, + /* class+opts */ NODE_CLASS_INPUT, NODE_OPTIONS, + /* input sock */ NULL, + /* output sock */ outputs, + /* storage */ "node_coord", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL +}; + diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c new file mode 100644 index 00000000000..ff9ec4db76b --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c @@ -0,0 +1,79 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti@gmx.net>. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <math.h> +#include "BLI_arithb.h" +#include "../TEX_util.h" + +static bNodeSocketType inputs[]= { + { SOCK_VECTOR, 1, "Coordinate 1", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, + { SOCK_VECTOR, 1, "Coordinate 2", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, + { -1, 0, "" } +}; + +static bNodeSocketType outputs[]= { + { SOCK_VALUE, 0, "Value", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; + +static void valuefn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + float coord1[3], coord2[3]; + float x, y, z; + + tex_input_vec(coord1, in[0], coord, thread); + tex_input_vec(coord2, in[1], coord, thread); + + *out = VecLenf(coord2, coord1); +} + +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &valuefn); + + tex_do_preview(node, out[0], data); +} + +bNodeType tex_node_distance= { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_DISTANCE, + /* name */ "Distance", + /* width+range */ 120, 110, 160, + /* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "node_distance", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL +}; + + diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 10fe3bab26c..562072328a8 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -46,25 +46,32 @@ void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread) dg->fn(out, coord, dg->node, dg->in, thread); } -void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread) +void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread) { TexDelegate *dg = in->data; if(dg) { - tex_call_delegate(dg, out, coord, thread); + tex_call_delegate(dg, in->vec, coord, thread); - if(in->hasoutput && in->sockettype == SOCK_VALUE) { - out[1] = out[2] = out[0]; - out[3] = 1; - } - } - else { - QUATCOPY(out, in->vec); + if(in->hasoutput && in->sockettype == SOCK_VALUE) + in->vec[1] = in->vec[2] = in->vec[0]; } + memcpy(out, in->vec, sz * sizeof(float)); +} + +void tex_input_vec(float *out, bNodeStack *in, float *coord, short thread) +{ + tex_input(out, 3, in, coord, thread); } void tex_input_rgba(float *out, bNodeStack *in, float *coord, short thread) { - tex_input_vec(out, in, coord, thread); + tex_input(out, 4, in, coord, thread); + + if(in->hasoutput && in->sockettype == SOCK_VALUE) + { + out[1] = out[2] = out[0]; + out[3] = 1; + } if(in->hasoutput && in->sockettype == SOCK_VECTOR) { out[0] = out[0] * .5f + .5f; @@ -83,8 +90,8 @@ float tex_input_value(bNodeStack *in, float *coord, short thread) static void init_preview(bNode *node) { - int xsize = node->prvr.xmax - node->prvr.xmin; - int ysize = node->prvr.ymax - node->prvr.ymin; + int xsize = (int)(node->prvr.xmax - node->prvr.xmin); + int ysize = (int)(node->prvr.ymax - node->prvr.ymin); if(xsize == 0) { xsize = PREV_RES; |