diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-11-26 17:11:55 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-11-26 17:11:55 +0400 |
commit | b6569ee4e75de0a68d05278eee6fb10ecc3d7183 (patch) | |
tree | bd0304a2f9c387c4989901058848ffb9b534f0f0 /source | |
parent | 9bd9b7e958b86f4dda24d6d2af3bf42a751cd79a (diff) | |
parent | df22957bfce70b704b6b93958814c1ca8b2211f5 (diff) |
Merged changes in the trunk up to revision 42116.
Diffstat (limited to 'source')
213 files changed, 3014 insertions, 2246 deletions
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 4da67f59ff7..b82393fad92 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -129,7 +129,7 @@ void BLF_dir_free(char **dirs, int count) char *blf_dir_search(const char *file) { DirBLF *dir; - char full_path[FILE_MAXDIR+FILE_MAXFILE]; + char full_path[FILE_MAX]; char *s= NULL; for(dir=global_font_dir.first; dir; dir= dir->next) { diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 15fdc2fe307..84f1bf75a3f 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -526,7 +526,7 @@ int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct E int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); -void weight_to_rgb(float input, float *fr, float *fg, float *fb); +void weight_to_rgb(float r_rgb[3], const float weight); /* convert layers requested by a GLSL material to actually available layers in * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */ diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index a3e0b5b6d5a..c829fc69b05 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -43,6 +43,7 @@ struct Tex; struct anim; struct Scene; struct Object; +struct ImageFormatData; /* call from library */ void free_image(struct Image *me); @@ -50,13 +51,22 @@ void free_image(struct Image *me); void BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels); int BKE_alphatest_ibuf(struct ImBuf *ibuf); -int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); -int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); -void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, int imtype, const short use_ext, const short use_frames); -int BKE_add_image_extension(char *string, int imtype); -int BKE_ftype_to_imtype(int ftype); -int BKE_imtype_to_ftype(int imtype); -int BKE_imtype_is_movie(int imtype); +int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); +int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); +int BKE_write_ibuf_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy); +void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, char imtype, const short use_ext, const short use_frames); +int BKE_add_image_extension(char *string, const char imtype); +char BKE_ftype_to_imtype(const int ftype); +int BKE_imtype_to_ftype(char imtype); + +int BKE_imtype_is_movie(const char imtype); +int BKE_imtype_supports_zbuf(const char imtype); +int BKE_imtype_supports_compress(const char imtype); +int BKE_imtype_supports_quality(const char imtype); +char BKE_imtype_valid_channels(const char imtype); +char BKE_imtype_valid_depths(const char imtype); + +char BKE_imtype_from_arg(const char *arg); struct anim *openanim(const char *name, int flags, int streamindex); @@ -105,6 +115,10 @@ struct RenderResult; /* image-user gets a new image, check settings */ #define IMA_SIGNAL_USER_NEW_IMAGE 6 +#define IMA_CHAN_FLAG_BW 1 +#define IMA_CHAN_FLAG_RGB 2 +#define IMA_CHAN_FLAG_ALPHA 4 + /* depending Image type, and (optional) ImageUser setting it returns ibuf */ /* always call to make signals work */ struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 8e7645d721e..0079ecb7d9c 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -91,7 +91,7 @@ void end_render_materials(struct Main *); int material_in_material(struct Material *parmat, struct Material *mat); -void ramp_blend(int type, float *r, float *g, float *b, float fac, const float col[3]); +void ramp_blend(int type, float r_col[3], const float fac, const float col[3]); /* copy/paste */ void clear_matcopybuf(void); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index c66e49f2906..f491761f3f2 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -217,7 +217,7 @@ typedef struct ParticleDrawData { float *ndata, *nd; /* normal data */ float *cdata, *cd; /* color data */ float *vedata, *ved; /* velocity data */ - float *ma_r, *ma_g, *ma_b; + float *ma_col; int tot_vec_size, flag; int totpoint, totve; } ParticleDrawData; diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 9f4fae7dc2e..d1b0acf7142 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -127,6 +127,9 @@ typedef struct PTCacheID { unsigned int stack_index; unsigned int flag; + unsigned int default_step; + unsigned int max_step; + /* flags defined in DNA_object_force.h */ unsigned int data_types, info_types; diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index f2502cf25f7..01a16be18ca 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -50,7 +50,7 @@ typedef struct bMovieHandle { void (*get_movie_path)(char *string, struct RenderData *rd); /* optional */ } bMovieHandle; -bMovieHandle *BKE_get_movie_handle(int imtype); +bMovieHandle *BKE_get_movie_handle(const char imtype); void BKE_makeanimstring(char *string, struct RenderData *rd); #ifdef __cplusplus diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 4793e83df53..140f596f78c 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -2301,14 +2301,16 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in /* zero */ for (i=0; i<numEffectedV; i++) { CCGVert *v = effectedV[i]; - VertDataZero(VERT_getCo(v, lvl)); + if(v->numFaces) + VertDataZero(VERT_getCo(v, lvl)); } for (i=0; i<numEffectedE; i++) { CCGEdge *e = effectedE[i]; - for (x=0; x<edgeSize; x++) - VertDataZero(EDGE_getCo(e, lvl, x)); + if(e->numFaces) + for (x=0; x<edgeSize; x++) + VertDataZero(EDGE_getCo(e, lvl, x)); } /* add */ @@ -2349,7 +2351,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in /* average */ for (i=0; i<numEffectedV; i++) { CCGVert *v = effectedV[i]; - VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces); + if(v->numFaces) + VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces); } for (i=0; i<numEffectedE; i++) { @@ -2358,8 +2361,9 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl)); VertDataCopy(EDGE_getCo(e, lvl, edgeSize-1), VERT_getCo(e->v1, lvl)); - for (x=1; x<edgeSize-1; x++) - VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces); + if(e->numFaces) + for (x=1; x<edgeSize-1; x++) + VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces); } /* copy */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a76ea1852de..216dbf8b2c2 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1777,31 +1777,29 @@ static void add_orco_dm(Object *ob, EditMesh *em, DerivedMesh *dm, DerivedMesh * * happens on enter/exit wpaint. */ -void weight_to_rgb(float input, float *fr, float *fg, float *fb) +void weight_to_rgb(float r_rgb[3], const float weight) { - float blend; - - blend= ((input/2.0f)+0.5f); - - if (input<=0.25f){ // blue->cyan - *fr= 0.0f; - *fg= blend*input*4.0f; - *fb= blend; + const float blend= ((weight/2.0f)+0.5f); + + if (weight<=0.25f){ // blue->cyan + r_rgb[0]= 0.0f; + r_rgb[1]= blend*weight*4.0f; + r_rgb[2]= blend; } - else if (input<=0.50f){ // cyan->green - *fr= 0.0f; - *fg= blend; - *fb= blend*(1.0f-((input-0.25f)*4.0f)); + else if (weight<=0.50f){ // cyan->green + r_rgb[0]= 0.0f; + r_rgb[1]= blend; + r_rgb[2]= blend*(1.0f-((weight-0.25f)*4.0f)); } - else if (input <= 0.75f){ // green->yellow - *fr= blend * ((input-0.50f)*4.0f); - *fg= blend; - *fb= 0.0f; + else if (weight <= 0.75f){ // green->yellow + r_rgb[0]= blend * ((weight-0.50f)*4.0f); + r_rgb[1]= blend; + r_rgb[2]= 0.0f; } - else if (input <= 1.0f){ // yellow->red - *fr= blend; - *fg= blend * (1.0f-((input-0.75f)*4.0f)); - *fb= 0.0f; + else if (weight <= 1.0f){ // yellow->red + r_rgb[0]= blend; + r_rgb[1]= blend * (1.0f-((weight-0.75f)*4.0f)); + r_rgb[2]= 0.0f; } } @@ -1866,7 +1864,7 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u if(coba) do_colorband(coba, input, colf); else - weight_to_rgb(input, colf, colf+1, colf+2); + weight_to_rgb(colf, input); col[3] = (unsigned char)(colf[0] * 255.0f); col[2] = (unsigned char)(colf[1] * 255.0f); @@ -2131,9 +2129,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_face_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); - range_vni(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0); - range_vni(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0); - range_vni(DM_get_face_data_layer(dm, CD_ORIGINDEX), dm->numFaceData, 0); + range_vn_i(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0); + range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0); + range_vn_i(DM_get_face_data_layer(dm, CD_ORIGINDEX), dm->numFaceData, 0); } } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 0e8d598da3d..a8644618945 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -451,7 +451,7 @@ int blender_test_break(void) #define MAXUNDONAME 64 typedef struct UndoElem { struct UndoElem *next, *prev; - char str[FILE_MAXDIR+FILE_MAXFILE]; + char str[FILE_MAX]; char name[MAXUNDONAME]; MemFile memfile; uintptr_t undosize; @@ -536,7 +536,7 @@ void BKE_write_undo(bContext *C, const char *name) /* disk save version */ if(UNDO_DISK) { static int counter= 0; - char filepath[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAX]; char numstr[32]; int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */ @@ -702,7 +702,7 @@ void BKE_undo_save_quit(void) UndoElem *uel; MemFileChunk *chunk; int file; - char str[FILE_MAXDIR+FILE_MAXFILE]; + char str[FILE_MAX]; if( (U.uiflag & USER_GLOBALUNDO)==0) return; diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index f1e6de9a0c4..0211dcdf42c 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -159,7 +159,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) ibuf->userdata = bmfont; ibuf->userflags |= IB_BITMAPFONT; - if (ibuf->depth < 32) { + if (ibuf->planes < 32) { // we're going to fake alpha here: calcAlpha(ibuf); } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 8a6e8faf29a..358c63b4f9f 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -169,6 +169,7 @@ Curve *add_curve(const char *name, int type) cu->texflag= CU_AUTOSPACE; cu->smallcaps_scale= 0.75f; cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... + cu->type= type; cu->bb= unit_boundbox(); @@ -303,16 +304,23 @@ ListBase *curve_editnurbs(Curve *cu) short curve_type(Curve *cu) { Nurb *nu; + int type= cu->type; + if(cu->vfont) { return OB_FONT; } - for (nu= cu->nurb.first; nu; nu= nu->next) { - if(nu->pntsv>1) { - return OB_SURF; + + if(!cu->type) { + type= OB_CURVE; + + for (nu= cu->nurb.first; nu; nu= nu->next) { + if(nu->pntsv>1) { + type= OB_SURF; + } } } - - return OB_CURVE; + + return type; } void update_curve_dimension(Curve *cu) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 9cbed451c09..6efd0a2727f 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -818,7 +818,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 4: CD_MFACE */ {sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL}, /* 5: CD_MTFACE */ - {sizeof(MTFace), "MTFace", 1, "UVTex", layerCopy_tface, NULL, + {sizeof(MTFace), "MTFace", 1, "UVMap", layerCopy_tface, NULL, layerInterp_tface, layerSwap_tface, layerDefault_tface}, /* 6: CD_MCOL */ /* 4 MCol structs per face */ @@ -838,7 +838,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 12: CD_PROP_STR */ {sizeof(MStringProperty), "MStringProperty",1,"String",NULL,NULL,NULL,NULL}, /* 13: CD_ORIGSPACE */ - {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVTex", layerCopy_origspace_face, NULL, + {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVMap", layerCopy_origspace_face, NULL, layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face}, /* 14: CD_ORCO */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 36ae764198a..519ac1cf534 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -976,7 +976,7 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett surface->wave_timescale = 1.0f; surface->wave_spring = 0.20f; - modifier_path_init(surface->image_output_path, sizeof(surface->image_output_path), "dynamicpaint"); + modifier_path_init(surface->image_output_path, sizeof(surface->image_output_path), "cache_dynamicpaint"); dynamicPaintSurface_setUniqueName(surface, "Surface"); @@ -1307,7 +1307,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) if (!tex) return; - /* get uv layer */ + /* get uv map */ CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, surface->init_layername, uvname); tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname); if (!tface) return; @@ -1681,7 +1681,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData for (; j<((mface[i].v4)?4:3); j++) { int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4; - weight_to_rgb(weight[index], temp_color, temp_color+1, temp_color+2); + weight_to_rgb(temp_color, weight[index]); col[i*4+j].r = FTOCHAR(temp_color[2]); col[i*4+j].g = FTOCHAR(temp_color[1]); col[i*4+j].b = FTOCHAR(temp_color[0]); @@ -2094,7 +2094,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) numOfFaces = dm->getNumFaces(dm); mface = dm->getFaceArray(dm); - /* get uv layer */ + /* get uv map */ CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, surface->uvlayer_name, uvname); tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname); @@ -2527,13 +2527,13 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam PaintSurfaceData *sData = surface->data; ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data; /* OpenEXR or PNG */ - int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_OPENEXR : R_PNG; + int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG; char output_file[FILE_MAX]; if (!sData || !sData->type_data) {setError(surface->canvas, "Image save failed: Invalid surface.");return;} /* if selected format is openexr, but current build doesnt support one */ #ifndef WITH_OPENEXR - if (format == R_OPENEXR) format = R_PNG; + if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG; #endif BLI_strncpy(output_file, filename, sizeof(output_file)); BKE_add_image_extension(output_file, format); @@ -2622,7 +2622,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam /* Set output format, png in case exr isnt supported */ ibuf->ftype= PNG|95; #ifdef WITH_OPENEXR - if (format == R_OPENEXR) { /* OpenEXR 32-bit float */ + if (format == R_IMF_IMTYPE_OPENEXR) { /* OpenEXR 32-bit float */ ibuf->ftype = OPENEXR | OPENEXR_COMPRESS; } #endif diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a61ae705020..c7f74f37a2d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -556,13 +556,13 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n if (ima) { ImBuf *ibuf; - BLI_strncpy(ima->name, name, FILE_MAX); + /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* dont do this, this writes in ain invalid filepath! */ ima->gen_x= width; ima->gen_y= height; ima->gen_type= uvtestgrid; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color); + ibuf= add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok= IMA_OK_LOADED; @@ -601,7 +601,7 @@ void BKE_image_memorypack(Image *ima) } ibuf->ftype= PNG; - ibuf->depth= 32; + ibuf->planes= R_IMF_PLANES_RGBA; IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem); if(ibuf->encodedbuffer==NULL) { @@ -800,175 +800,302 @@ void BKE_image_all_free_anim_ibufs(int cfra) /* *********** READ AND WRITE ************** */ -int BKE_imtype_to_ftype(int imtype) +int BKE_imtype_to_ftype(const char imtype) { - if(imtype==R_TARGA) + if(imtype==R_IMF_IMTYPE_TARGA) return TGA; - else if(imtype==R_RAWTGA) + else if(imtype==R_IMF_IMTYPE_RAWTGA) return RAWTGA; - else if(imtype== R_IRIS) + else if(imtype== R_IMF_IMTYPE_IRIS) return IMAGIC; #ifdef WITH_HDR - else if (imtype==R_RADHDR) + else if (imtype==R_IMF_IMTYPE_RADHDR) return RADHDR; #endif - else if (imtype==R_PNG) + else if (imtype==R_IMF_IMTYPE_PNG) return PNG; #ifdef WITH_DDS - else if (imtype==R_DDS) + else if (imtype==R_IMF_IMTYPE_DDS) return DDS; #endif - else if (imtype==R_BMP) + else if (imtype==R_IMF_IMTYPE_BMP) return BMP; #ifdef WITH_TIFF - else if (imtype==R_TIFF) + else if (imtype==R_IMF_IMTYPE_TIFF) return TIF; #endif - else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) + else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) return OPENEXR; #ifdef WITH_CINEON - else if (imtype==R_CINEON) + else if (imtype==R_IMF_IMTYPE_CINEON) return CINEON; - else if (imtype==R_DPX) + else if (imtype==R_IMF_IMTYPE_DPX) return DPX; #endif #ifdef WITH_OPENJPEG - else if(imtype==R_JP2) + else if(imtype==R_IMF_IMTYPE_JP2) return JP2; #endif else return JPG|90; } -int BKE_ftype_to_imtype(int ftype) +char BKE_ftype_to_imtype(const int ftype) { if(ftype==0) - return TGA; + return R_IMF_IMTYPE_TARGA; else if(ftype == IMAGIC) - return R_IRIS; + return R_IMF_IMTYPE_IRIS; #ifdef WITH_HDR else if (ftype & RADHDR) - return R_RADHDR; + return R_IMF_IMTYPE_RADHDR; #endif else if (ftype & PNG) - return R_PNG; + return R_IMF_IMTYPE_PNG; #ifdef WITH_DDS else if (ftype & DDS) - return R_DDS; + return R_IMF_IMTYPE_DDS; #endif else if (ftype & BMP) - return R_BMP; + return R_IMF_IMTYPE_BMP; #ifdef WITH_TIFF else if (ftype & TIF) - return R_TIFF; + return R_IMF_IMTYPE_TIFF; #endif else if (ftype & OPENEXR) - return R_OPENEXR; + return R_IMF_IMTYPE_OPENEXR; #ifdef WITH_CINEON else if (ftype & CINEON) - return R_CINEON; + return R_IMF_IMTYPE_CINEON; else if (ftype & DPX) - return R_DPX; + return R_IMF_IMTYPE_DPX; #endif else if (ftype & TGA) - return R_TARGA; + return R_IMF_IMTYPE_TARGA; else if(ftype & RAWTGA) - return R_RAWTGA; + return R_IMF_IMTYPE_RAWTGA; #ifdef WITH_OPENJPEG else if(ftype & JP2) - return R_JP2; + return R_IMF_IMTYPE_JP2; #endif else - return R_JPEG90; + return R_IMF_IMTYPE_JPEG90; +} + + +int BKE_imtype_is_movie(const char imtype) +{ + switch(imtype) { + case R_IMF_IMTYPE_AVIRAW: + case R_IMF_IMTYPE_AVIJPEG: + case R_IMF_IMTYPE_AVICODEC: + case R_IMF_IMTYPE_QUICKTIME: + case R_IMF_IMTYPE_FFMPEG: + case R_IMF_IMTYPE_H264: + case R_IMF_IMTYPE_THEORA: + case R_IMF_IMTYPE_XVID: + case R_IMF_IMTYPE_FRAMESERVER: + return 1; + } + return 0; +} + +int BKE_imtype_supports_zbuf(const char imtype) +{ + switch(imtype) { + case R_IMF_IMTYPE_IRIZ: + case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ + return 1; + } + return 0; } +int BKE_imtype_supports_compress(const char imtype) +{ + switch(imtype) { + case R_IMF_IMTYPE_PNG: + return 1; + } + return 0; +} -int BKE_imtype_is_movie(int imtype) +int BKE_imtype_supports_quality(const char imtype) { switch(imtype) { - case R_AVIRAW: - case R_AVIJPEG: - case R_AVICODEC: - case R_QUICKTIME: - case R_FFMPEG: - case R_H264: - case R_THEORA: - case R_XVID: - case R_FRAMESERVER: + case R_IMF_IMTYPE_JPEG90: + case R_IMF_IMTYPE_JP2: + case R_IMF_IMTYPE_AVIJPEG: return 1; } return 0; } -int BKE_add_image_extension(char *string, int imtype) +char BKE_imtype_valid_channels(const char imtype) +{ + char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */ + + /* alpha */ + switch(imtype) { + case R_IMF_IMTYPE_TARGA: + case R_IMF_IMTYPE_IRIS: + case R_IMF_IMTYPE_PNG: + /* case R_IMF_IMTYPE_BMP: */ /* read but not write */ + case R_IMF_IMTYPE_RADHDR: + case R_IMF_IMTYPE_TIFF: + case R_IMF_IMTYPE_OPENEXR: + case R_IMF_IMTYPE_MULTILAYER: + case R_IMF_IMTYPE_DDS: + case R_IMF_IMTYPE_JP2: + chan_flag |= IMA_CHAN_FLAG_ALPHA; + } + + /* bw */ + switch(imtype) { + case R_IMF_IMTYPE_PNG: + case R_IMF_IMTYPE_JPEG90: + case R_IMF_IMTYPE_TARGA: + case R_IMF_IMTYPE_RAWTGA: + case R_IMF_IMTYPE_TIFF: + case R_IMF_IMTYPE_IRIS: + chan_flag |= IMA_CHAN_FLAG_BW; + } + + return chan_flag; +} + +char BKE_imtype_valid_depths(const char imtype) +{ + switch (imtype) { + case R_IMF_IMTYPE_RADHDR: + return R_IMF_CHAN_DEPTH_32; + case R_IMF_IMTYPE_TIFF: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16; + case R_IMF_IMTYPE_OPENEXR: + return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32; + case R_IMF_IMTYPE_MULTILAYER: + return R_IMF_CHAN_DEPTH_32; + /* eeh, cineone does some strange 10bits per channel */ + case R_IMF_IMTYPE_DPX: + case R_IMF_IMTYPE_CINEON: + return R_IMF_CHAN_DEPTH_12; + case R_IMF_IMTYPE_JP2: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; + /* most formats are 8bit only */ + default: + return R_IMF_CHAN_DEPTH_8; + } +} + + +/* string is from command line --render-format arg, keep in sync with + * creator.c help info */ +char BKE_imtype_from_arg(const char *imtype_arg) +{ + if (!strcmp(imtype_arg,"TGA")) return R_IMF_IMTYPE_TARGA; + else if (!strcmp(imtype_arg,"IRIS")) return R_IMF_IMTYPE_IRIS; +#ifdef WITH_DDS + else if (!strcmp(imtype_arg,"DDS")) return R_IMF_IMTYPE_DDS; +#endif + else if (!strcmp(imtype_arg,"JPEG")) return R_IMF_IMTYPE_JPEG90; + else if (!strcmp(imtype_arg,"IRIZ")) return R_IMF_IMTYPE_IRIZ; + else if (!strcmp(imtype_arg,"RAWTGA")) return R_IMF_IMTYPE_RAWTGA; + else if (!strcmp(imtype_arg,"AVIRAW")) return R_IMF_IMTYPE_AVIRAW; + else if (!strcmp(imtype_arg,"AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG; + else if (!strcmp(imtype_arg,"PNG")) return R_IMF_IMTYPE_PNG; + else if (!strcmp(imtype_arg,"AVICODEC")) return R_IMF_IMTYPE_AVICODEC; + else if (!strcmp(imtype_arg,"QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME; + else if (!strcmp(imtype_arg,"BMP")) return R_IMF_IMTYPE_BMP; +#ifdef WITH_HDR + else if (!strcmp(imtype_arg,"HDR")) return R_IMF_IMTYPE_RADHDR; +#endif +#ifdef WITH_TIFF + else if (!strcmp(imtype_arg,"TIFF")) return R_IMF_IMTYPE_TIFF; +#endif +#ifdef WITH_OPENEXR + else if (!strcmp(imtype_arg,"EXR")) return R_IMF_IMTYPE_OPENEXR; + else if (!strcmp(imtype_arg,"MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER; +#endif + else if (!strcmp(imtype_arg,"MPEG")) return R_IMF_IMTYPE_FFMPEG; + else if (!strcmp(imtype_arg,"FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER; +#ifdef WITH_CINEON + else if (!strcmp(imtype_arg,"CINEON")) return R_IMF_IMTYPE_CINEON; + else if (!strcmp(imtype_arg,"DPX")) return R_IMF_IMTYPE_DPX; +#endif +#ifdef WITH_OPENJPEG + else if (!strcmp(imtype_arg,"JP2")) return R_IMF_IMTYPE_JP2; +#endif + else return R_IMF_IMTYPE_INVALID; +} + +int BKE_add_image_extension(char *string, const char imtype) { const char *extension= NULL; - if(imtype== R_IRIS) { + if(imtype== R_IMF_IMTYPE_IRIS) { if(!BLI_testextensie(string, ".rgb")) extension= ".rgb"; } - else if(imtype==R_IRIZ) { + else if(imtype==R_IMF_IMTYPE_IRIZ) { if(!BLI_testextensie(string, ".rgb")) extension= ".rgb"; } #ifdef WITH_HDR - else if(imtype==R_RADHDR) { + else if(imtype==R_IMF_IMTYPE_RADHDR) { if(!BLI_testextensie(string, ".hdr")) extension= ".hdr"; } #endif - else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) { + else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) { if(!BLI_testextensie(string, ".png")) extension= ".png"; } #ifdef WITH_DDS - else if(imtype==R_DDS) { + else if(imtype==R_IMF_IMTYPE_DDS) { if(!BLI_testextensie(string, ".dds")) extension= ".dds"; } #endif - else if(imtype==R_RAWTGA) { + else if(imtype==R_IMF_IMTYPE_RAWTGA) { if(!BLI_testextensie(string, ".tga")) extension= ".tga"; } - else if(imtype==R_BMP) { + else if(imtype==R_IMF_IMTYPE_BMP) { if(!BLI_testextensie(string, ".bmp")) extension= ".bmp"; } #ifdef WITH_TIFF - else if(imtype==R_TIFF) { + else if(imtype==R_IMF_IMTYPE_TIFF) { if(!BLI_testextensie(string, ".tif") && !BLI_testextensie(string, ".tiff")) extension= ".tif"; } #endif #ifdef WITH_OPENEXR - else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) { + else if( ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { if(!BLI_testextensie(string, ".exr")) extension= ".exr"; } #endif #ifdef WITH_CINEON - else if(imtype==R_CINEON){ + else if(imtype==R_IMF_IMTYPE_CINEON){ if (!BLI_testextensie(string, ".cin")) extension= ".cin"; } - else if(imtype==R_DPX){ + else if(imtype==R_IMF_IMTYPE_DPX){ if (!BLI_testextensie(string, ".dpx")) extension= ".dpx"; } #endif - else if(imtype==R_TARGA) { + else if(imtype==R_IMF_IMTYPE_TARGA) { if(!BLI_testextensie(string, ".tga")) extension= ".tga"; } #ifdef WITH_OPENJPEG - else if(imtype==R_JP2) { + else if(imtype==R_IMF_IMTYPE_JP2) { if(!BLI_testextensie(string, ".jp2")) extension= ".jp2"; } #endif - else { // R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc + else { // R_IMF_IMTYPE_AVICODEC, R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) extension= ".jpg"; } @@ -1371,98 +1498,102 @@ int BKE_alphatest_ibuf(ImBuf *ibuf) return FALSE; } -int BKE_write_ibuf(ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) +/* note: imf->planes is ignored here, its assumed the image channels + * are already set */ +int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) { + char imtype= imf->imtype; + char compress= imf->compress; + char quality= imf->quality; + int ok; - (void)subimtype; /* quies unused warnings */ if(imtype == -1) { /* use whatever existing image type is set by 'ibuf' */ } - else if(imtype== R_IRIS) { + else if(imtype== R_IMF_IMTYPE_IRIS) { ibuf->ftype= IMAGIC; } #ifdef WITH_HDR - else if (imtype==R_RADHDR) { + else if (imtype==R_IMF_IMTYPE_RADHDR) { ibuf->ftype= RADHDR; } #endif - else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) { + else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) { ibuf->ftype= PNG; - if(imtype==R_PNG) - ibuf->ftype |= quality; /* quality is actually compression 0-100 --> 0-9 */ + if(imtype==R_IMF_IMTYPE_PNG) + ibuf->ftype |= compress; } #ifdef WITH_DDS - else if (imtype==R_DDS) { + else if (imtype==R_IMF_IMTYPE_DDS) { ibuf->ftype= DDS; } #endif - else if (imtype==R_BMP) { + else if (imtype==R_IMF_IMTYPE_BMP) { ibuf->ftype= BMP; } #ifdef WITH_TIFF - else if (imtype==R_TIFF) { + else if (imtype==R_IMF_IMTYPE_TIFF) { ibuf->ftype= TIF; - if(subimtype & R_TIFF_16BIT) + if(imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= TIF_16BIT; } #endif #ifdef WITH_OPENEXR - else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) { + else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) { ibuf->ftype= OPENEXR; - if(subimtype & R_OPENEXR_HALF) + if(imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= OPENEXR_HALF; ibuf->ftype |= (quality & OPENEXR_COMPRESS); - if(!(subimtype & R_OPENEXR_ZBUF)) + if(!(imf->flag & R_IMF_FLAG_ZBUF)) ibuf->zbuf_float = NULL; /* signal for exr saving */ } #endif #ifdef WITH_CINEON - else if (imtype==R_CINEON) { + else if (imtype==R_IMF_IMTYPE_CINEON) { ibuf->ftype = CINEON; } - else if (imtype==R_DPX) { + else if (imtype==R_IMF_IMTYPE_DPX) { ibuf->ftype = DPX; } #endif - else if (imtype==R_TARGA) { + else if (imtype==R_IMF_IMTYPE_TARGA) { ibuf->ftype= TGA; } - else if(imtype==R_RAWTGA) { + else if(imtype==R_IMF_IMTYPE_RAWTGA) { ibuf->ftype= RAWTGA; } #ifdef WITH_OPENJPEG - else if(imtype==R_JP2) { + else if(imtype==R_IMF_IMTYPE_JP2) { if(quality < 10) quality= 90; ibuf->ftype= JP2|quality; - if (subimtype & R_JPEG2K_16BIT) { + if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->ftype |= JP2_16BIT; - } else if (subimtype & R_JPEG2K_12BIT) { + } else if (imf->depth == R_IMF_CHAN_DEPTH_12) { ibuf->ftype |= JP2_12BIT; } - if (subimtype & R_JPEG2K_YCC) { + if (imf->jp2_flag & R_IMF_JP2_FLAG_YCC) { ibuf->ftype |= JP2_YCC; } - - if (subimtype & R_JPEG2K_CINE_PRESET) { + + if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_PRESET) { ibuf->ftype |= JP2_CINE; - if (subimtype & R_JPEG2K_CINE_48FPS) + if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_48) ibuf->ftype |= JP2_CINE_48FPS; } } #endif else { - /* R_JPEG90, etc. default we save jpegs */ + /* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */ if(quality < 10) quality= 90; ibuf->ftype= JPG|quality; - if(ibuf->depth==32) ibuf->depth= 24; /* unsupported feature only confuses other s/w */ } BLI_make_existing_file(name); @@ -1475,16 +1606,39 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, int imtype, int subimtype, int return(ok); } -int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) +/* same as BKE_write_ibuf_as but crappy workaround not to perminantly modify + * _some_, values in the imbuf */ +int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, + const short save_copy) +{ + ImBuf ibuf_back= *ibuf; + int ok; + + /* all data is rgba anyway, + * this just controls how to save for some formats */ + ibuf->planes= imf->planes; + + ok= BKE_write_ibuf(ibuf, name, imf); + + if (save_copy) { + /* note that we are not restoring _all_ settings */ + ibuf->planes= ibuf_back.planes; + ibuf->ftype= ibuf_back.ftype; + } + + return ok; +} + +int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf) { if(scene && scene->r.stamp & R_STAMP_ALL) BKE_stamp_info(scene, camera, ibuf); - return BKE_write_ibuf(ibuf, name, imtype, subimtype, quality); + return BKE_write_ibuf(ibuf, name, imf); } -void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, int imtype, const short use_ext, const short use_frames) +void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, const char imtype, const short use_ext, const short use_frames) { if (string==NULL) return; BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ @@ -2414,13 +2568,13 @@ int BKE_image_has_alpha(struct Image *image) { ImBuf *ibuf; void *lock; - int depth; + int planes; ibuf= BKE_image_acquire_ibuf(image, NULL, &lock); - depth = (ibuf?ibuf->depth:0); + planes = (ibuf?ibuf->planes:0); BKE_image_release_ibuf(image, lock); - if (depth == 32) + if (planes == 32) return 1; else return 0; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 6c8a72825c7..9d196a1104b 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1181,129 +1181,129 @@ 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 */ -void ramp_blend(int type, float *r, float *g, float *b, float fac, const float col[3]) +void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) { float tmp, facm= 1.0f-fac; switch (type) { case MA_RAMP_BLEND: - *r = facm*(*r) + fac*col[0]; - if(g) { - *g = facm*(*g) + fac*col[1]; - *b = facm*(*b) + fac*col[2]; + 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; case MA_RAMP_ADD: - *r += fac*col[0]; - if(g) { - *g += fac*col[1]; - *b += fac*col[2]; + r_col[0] += fac*col[0]; + if(r_col[1]) { + r_col[1] += fac*col[1]; + r_col[2] += fac*col[2]; } break; case MA_RAMP_MULT: - *r *= (facm + fac*col[0]); - if(g) { - *g *= (facm + fac*col[1]); - *b *= (facm + fac*col[2]); + 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; case MA_RAMP_SCREEN: - *r = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - *r); - if(g) { - *g = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - *g); - *b = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - *b); + 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; case MA_RAMP_OVERLAY: - if(*r < 0.5f) - *r *= (facm + 2.0f*fac*col[0]); + if(r_col[0] < 0.5f) + r_col[0] *= (facm + 2.0f*fac*col[0]); else - *r = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - *r); - if(g) { - if(*g < 0.5f) - *g *= (facm + 2.0f*fac*col[1]); + 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 - *g = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - *g); - if(*b < 0.5f) - *b *= (facm + 2.0f*fac*col[2]); + 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 - *b = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - *b); + r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]); } break; case MA_RAMP_SUB: - *r -= fac*col[0]; - if(g) { - *g -= fac*col[1]; - *b -= fac*col[2]; + r_col[0] -= fac*col[0]; + if(r_col[1]) { + r_col[1] -= fac*col[1]; + r_col[2] -= fac*col[2]; } break; case MA_RAMP_DIV: if(col[0]!=0.0f) - *r = facm*(*r) + fac*(*r)/col[0]; - if(g) { + r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0]; + if(r_col[1]) { if(col[1]!=0.0f) - *g = facm*(*g) + fac*(*g)/col[1]; + r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1]; if(col[2]!=0.0f) - *b = facm*(*b) + fac*(*b)/col[2]; + r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2]; } break; case MA_RAMP_DIFF: - *r = facm*(*r) + fac*fabsf(*r-col[0]); - if(g) { - *g = facm*(*g) + fac*fabsf(*g-col[1]); - *b = facm*(*b) + fac*fabsf(*b-col[2]); + 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; case MA_RAMP_DARK: tmp=col[0]+((1-col[0])*facm); - if(tmp < *r) *r= tmp; - if(g) { + if(tmp < r_col[0]) r_col[0]= tmp; + if(r_col[1]) { tmp=col[1]+((1-col[1])*facm); - if(tmp < *g) *g= tmp; + if(tmp < r_col[1]) r_col[1]= tmp; tmp=col[2]+((1-col[2])*facm); - if(tmp < *b) *b= tmp; + if(tmp < r_col[2]) r_col[2]= tmp; } break; case MA_RAMP_LIGHT: tmp= fac*col[0]; - if(tmp > *r) *r= tmp; - if(g) { + if(tmp > r_col[0]) r_col[0]= tmp; + if(r_col[1]) { tmp= fac*col[1]; - if(tmp > *g) *g= tmp; + if(tmp > r_col[1]) r_col[1]= tmp; tmp= fac*col[2]; - if(tmp > *b) *b= tmp; + if(tmp > r_col[2]) r_col[2]= tmp; } break; case MA_RAMP_DODGE: - if(*r !=0.0f){ + if(r_col[0] !=0.0f){ tmp = 1.0f - fac*col[0]; if(tmp <= 0.0f) - *r = 1.0f; - else if ((tmp = (*r) / tmp)> 1.0f) - *r = 1.0f; + r_col[0] = 1.0f; + else if ((tmp = (r_col[0]) / tmp)> 1.0f) + r_col[0] = 1.0f; else - *r = tmp; + r_col[0] = tmp; } - if(g) { - if(*g !=0.0f){ + if(r_col[1]) { + if(r_col[1] !=0.0f){ tmp = 1.0f - fac*col[1]; if(tmp <= 0.0f ) - *g = 1.0f; - else if ((tmp = (*g) / tmp) > 1.0f ) - *g = 1.0f; + r_col[1] = 1.0f; + else if ((tmp = (r_col[1]) / tmp) > 1.0f ) + r_col[1] = 1.0f; else - *g = tmp; + r_col[1] = tmp; } - if(*b !=0.0f){ + if(r_col[2] !=0.0f){ tmp = 1.0f - fac*col[2]; if(tmp <= 0.0f) - *b = 1.0f; - else if ((tmp = (*b) / tmp) > 1.0f ) - *b = 1.0f; + r_col[2] = 1.0f; + else if ((tmp = (r_col[2]) / tmp) > 1.0f ) + r_col[2] = 1.0f; else - *b = tmp; + r_col[2] = tmp; } } @@ -1313,114 +1313,114 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, const float c tmp = facm + fac*col[0]; if(tmp <= 0.0f) - *r = 0.0f; - else if (( tmp = (1.0f - (1.0f - (*r)) / tmp )) < 0.0f) - *r = 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=1.0f; + r_col[0]=1.0f; else - *r = tmp; + r_col[0] = tmp; - if(g) { + if(r_col[1]) { tmp = facm + fac*col[1]; if(tmp <= 0.0f) - *g = 0.0f; - else if (( tmp = (1.0f - (1.0f - (*g)) / tmp )) < 0.0f ) - *g = 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) - *g=1.0f; + r_col[1]=1.0f; else - *g = tmp; + r_col[1] = tmp; tmp = facm + fac*col[2]; if(tmp <= 0.0f) - *b = 0.0f; - else if (( tmp = (1.0f - (1.0f - (*b)) / tmp )) < 0.0f ) - *b = 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) - *b= 1.0f; + r_col[2]= 1.0f; else - *b = tmp; + r_col[2] = tmp; } break; case MA_RAMP_HUE: - if(g){ + if(r_col[1]){ float rH,rS,rV; float colH,colS,colV; float tmpr,tmpg,tmpb; rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); if(colS!=0 ){ - rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV); + rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); hsv_to_rgb( colH , rS, rV, &tmpr, &tmpg, &tmpb); - *r = facm*(*r) + fac*tmpr; - *g = facm*(*g) + fac*tmpg; - *b = facm*(*b) + fac*tmpb; + r_col[0] = facm*(r_col[0]) + fac*tmpr; + r_col[1] = facm*(r_col[1]) + fac*tmpg; + r_col[2] = facm*(r_col[2]) + fac*tmpb; } } break; case MA_RAMP_SAT: - if(g){ + if(r_col[1]){ float rH,rS,rV; float colH,colS,colV; - rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV); + rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); if(rS!=0){ rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); - hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r, g, b); + hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2); } } break; case MA_RAMP_VAL: - if(g){ + if(r_col[1]){ float rH,rS,rV; float colH,colS,colV; - rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV); + 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, g, b); + hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2); } break; case MA_RAMP_COLOR: - if(g){ + if(r_col[1]){ float rH,rS,rV; float colH,colS,colV; float tmpr,tmpg,tmpb; rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); if(colS!=0){ - rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV); + rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); hsv_to_rgb( colH, colS, rV, &tmpr, &tmpg, &tmpb); - *r = facm*(*r) + fac*tmpr; - *g = facm*(*g) + fac*tmpg; - *b = facm*(*b) + fac*tmpb; + r_col[0] = facm*(r_col[0]) + fac*tmpr; + r_col[1] = facm*(r_col[1]) + fac*tmpg; + r_col[2] = facm*(r_col[2]) + fac*tmpb; } } break; case MA_RAMP_SOFT: - if (g){ + if (r_col[1]){ float scr, scg, scb; /* first calculate non-fac based Screen mix */ - scr = 1.0f - (1.0f - col[0]) * (1.0f - *r); - scg = 1.0f - (1.0f - col[1]) * (1.0f - *g); - scb = 1.0f - (1.0f - col[2]) * (1.0f - *b); + 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]); - *r = facm*(*r) + fac*(((1.0f - *r) * col[0] * (*r)) + (*r * scr)); - *g = facm*(*g) + fac*(((1.0f - *g) * col[1] * (*g)) + (*g * scg)); - *b = facm*(*b) + fac*(((1.0f - *b) * col[2] * (*b)) + (*b * scb)); + 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) - *r = *r + fac*(2.0f*(col[0]-0.5f)); + r_col[0] = r_col[0] + fac*(2.0f*(col[0]-0.5f)); else - *r = *r + fac*(2.0f*(col[0]) - 1.0f); - if (g){ + r_col[0] = r_col[0] + fac*(2.0f*(col[0]) - 1.0f); + if (r_col[1]){ if (col[1] > 0.5f) - *g = *g + fac*(2.0f*(col[1]-0.5f)); + r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f)); else - *g = *g + fac*(2.0f*(col[1]) -1.0f); + r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f); if (col[2] > 0.5f) - *b = *b + fac*(2.0f*(col[2]-0.5f)); + r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f)); else - *b = *b + fac*(2.0f*(col[2]) - 1.0f); + r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f); } break; } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 540d757f0c9..382e1d70387 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -895,7 +895,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, int undistorted) { - char name[FILE_MAXFILE+FILE_MAXDIR]; + char name[FILE_MAX]; int quality, rectx, recty; int size= size= rendersize_to_number(proxy_render_size); ImBuf *scaleibuf; @@ -913,8 +913,8 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i scaleibuf->ftype= JPG | quality; /* unsupported feature only confuses other s/w */ - if(scaleibuf->depth==32) - scaleibuf->depth= 24; + if(scaleibuf->planes==32) + scaleibuf->planes= 24; BLI_lock_thread(LOCK_MOVIECLIP); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b25c130590e..d0858ea032a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1795,6 +1795,7 @@ static void give_parvert(Object *par, int nr, float *vec) dm->getVertCo(dm, 0, vec); } } + else fprintf(stderr, "%s: DerivedMesh is needed to solve parenting, object position can be wrong now\n", __func__); if(em) BKE_mesh_end_editmesh(me, em); diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 85b9b0fbf22..ae622358fd2 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -313,8 +313,8 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float float uu,vv; // first wrap the texture so 0 <= (u,v) < 1 - u = fmod(u,1.0f); - v = fmod(v,1.0f); + u = fmodf(u,1.0f); + v = fmodf(v,1.0f); if (u < 0) u += 1.0f; if (v < 0) v += 1.0f; @@ -1018,7 +1018,23 @@ static void cache_filename(char *string, const char *path, const char *relbase, BLI_join_dirfile(cachepath, sizeof(cachepath), path, fname); - BKE_makepicstring(string, cachepath, relbase, frame, R_OPENEXR, 1, TRUE); + BKE_makepicstring(string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, 1, TRUE); +} + +/* silly functions but useful to inline when the args do a lot of indirections */ +MINLINE void rgb_to_rgba_unit_alpha(float r_rgba[4], const float rgb[3]) +{ + r_rgba[0]= rgb[0]; + r_rgba[1]= rgb[1]; + r_rgba[2]= rgb[2]; + r_rgba[3]= 1.0f; +} +MINLINE void value_to_rgba_unit_alpha(float r_rgba[4], const float value) +{ + r_rgba[0]= value; + r_rgba[1]= value; + r_rgba[2]= value; + r_rgba[3]= 1.0f; } void BKE_free_ocean_cache(struct OceanCache *och) @@ -1076,9 +1092,7 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in if (och->ibufs_disp[f]) { ibuf_sample(och->ibufs_disp[f], u, v, (1.0f/(float)res_x), (1.0f/(float)res_y), result); - ocr->disp[0] = result[0]; - ocr->disp[1] = result[1]; - ocr->disp[2] = result[2]; + copy_v3_v3(ocr->disp, result); } if (och->ibufs_foam[f]) { @@ -1088,34 +1102,31 @@ void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, in if (och->ibufs_norm[f]) { ibuf_sample(och->ibufs_norm[f], u, v, (1.0f/(float)res_x), (1.0f/(float)res_y), result); - ocr->normal[0] = result[0]; - ocr->normal[1] = result[1]; - ocr->normal[2] = result[2]; + copy_v3_v3(ocr->normal, result); } } void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j) { - int res_x = och->resolution_x; - int res_y = och->resolution_y; + const int res_x = och->resolution_x; + const int res_y = och->resolution_y; - i = abs(i) % res_x; - j = abs(j) % res_y; + if (i < 0) i= -i; + if (j < 0) j= -j; + + i = i % res_x; + j = j % res_y; if (och->ibufs_disp[f]) { - ocr->disp[0] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 0]; - ocr->disp[1] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 1]; - ocr->disp[2] = och->ibufs_disp[f]->rect_float[4*(res_x*j + i) + 2]; + copy_v3_v3(ocr->disp, &och->ibufs_disp[f]->rect_float[4*(res_x*j + i)]); } if (och->ibufs_foam[f]) { - ocr->foam = och->ibufs_foam[f]->rect_float[4*(res_x*j + i) + 0]; + ocr->foam = och->ibufs_foam[f]->rect_float[4*(res_x*j + i)]; } if (och->ibufs_norm[f]) { - ocr->normal[0] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 0]; - ocr->normal[1] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 1]; - ocr->normal[2] = och->ibufs_norm[f]->rect_float[4*(res_x*j + i) + 2]; + copy_v3_v3(ocr->normal, &och->ibufs_norm[f]->rect_float[4*(res_x*j + i)]); } } @@ -1185,6 +1196,8 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v * before use - campbell */ OceanResult ocr; + ImageFormatData imf= {0}; + int f, i=0, x, y, cancel=0; float progress; @@ -1201,6 +1214,11 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v BLI_srand(0); + /* setup image format */ + imf.imtype= R_IMF_IMTYPE_OPENEXR; + imf.depth= R_IMF_CHAN_DEPTH_16; + imf.exr_codec= R_IMF_EXR_CODEC_ZIP; + for (f=och->start, i=0; f<=och->end; f++, i++) { /* create a new imbuf to store image for this frame */ @@ -1219,10 +1237,7 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v BKE_ocean_eval_ij(o, &ocr, x, y); /* add to the image */ - ibuf_disp->rect_float[4*(res_x*y + x) + 0] = ocr.disp[0]; - ibuf_disp->rect_float[4*(res_x*y + x) + 1] = ocr.disp[1]; - ibuf_disp->rect_float[4*(res_x*y + x) + 2] = ocr.disp[2]; - ibuf_disp->rect_float[4*(res_x*y + x) + 3] = 1.0f; + rgb_to_rgba_unit_alpha(&ibuf_disp->rect_float[4*(res_x*y + x)], ocr.disp); if (o->_do_jacobian) { /* TODO, cleanup unused code - campbell */ @@ -1275,35 +1290,29 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v prev_foam[res_x*y + x] = foam_result; - ibuf_foam->rect_float[4*(res_x*y + x) + 0] = foam_result; - ibuf_foam->rect_float[4*(res_x*y + x) + 1] = foam_result; - ibuf_foam->rect_float[4*(res_x*y + x) + 2] = foam_result; - ibuf_foam->rect_float[4*(res_x*y + x) + 3] = 1.0; + value_to_rgba_unit_alpha(&ibuf_foam->rect_float[4*(res_x*y + x)], foam_result); } if (o->_do_normals) { - ibuf_normal->rect_float[4*(res_x*y + x) + 0] = ocr.normal[0]; - ibuf_normal->rect_float[4*(res_x*y + x) + 1] = ocr.normal[1]; - ibuf_normal->rect_float[4*(res_x*y + x) + 2] = ocr.normal[2]; - ibuf_normal->rect_float[4*(res_x*y + x) + 3] = 1.0; + rgb_to_rgba_unit_alpha(&ibuf_normal->rect_float[4*(res_x*y + x)], ocr.normal); } } } /* write the images */ cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); - if(0 == BKE_write_ibuf(ibuf_disp, string, R_OPENEXR, R_OPENEXR_HALF, 2)) // 2 == ZIP exr codec + if(0 == BKE_write_ibuf(ibuf_disp, string, &imf)) printf("Cannot save Displacement File Output to %s\n", string); if (o->_do_jacobian) { cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); - if(0 == BKE_write_ibuf(ibuf_foam, string, R_OPENEXR, R_OPENEXR_HALF, 2)) // 2 == ZIP exr codec + if(0 == BKE_write_ibuf(ibuf_foam, string, &imf)) printf("Cannot save Foam File Output to %s\n", string); } if (o->_do_normals) { cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); - if(0 == BKE_write_ibuf(ibuf_normal, string, R_OPENEXR, R_OPENEXR_HALF, 2)) // 2 == ZIP exr codec + if(0 == BKE_write_ibuf(ibuf_normal, string, &imf)) printf("Cannot save Normal File Output to %s\n", string); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index ea1dbec8a27..7be8aefc883 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -168,7 +168,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char { PackedFile *pf = NULL; int file, filelen; - char name[FILE_MAXDIR+FILE_MAXFILE]; + char name[FILE_MAX]; void *data; /* render result has no filename and can be ignored @@ -245,7 +245,7 @@ void packAll(Main *bmain, ReportList *reports) static char *find_new_name(char *name) { - char tempname[FILE_MAXDIR + FILE_MAXFILE]; + char tempname[FILE_MAX]; char *newname; size_t len; @@ -268,8 +268,8 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i { int file, number, remove_tmp = FALSE; int ret_value = RET_OK; - char name[FILE_MAXDIR + FILE_MAXFILE]; - char tempname[FILE_MAXDIR + FILE_MAXFILE]; + char name[FILE_MAX]; + char tempname[FILE_MAX]; /* void *data; */ if (guimode) {} //XXX waitcursor(1); @@ -337,7 +337,7 @@ int checkPackedFile(const char *filename, PackedFile *pf) struct stat st; int ret_val, i, len, file; char buf[4096]; - char name[FILE_MAXDIR + FILE_MAXFILE]; + char name[FILE_MAX]; BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, G.main->name); @@ -394,8 +394,8 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na char *newname = NULL; const char *temp = NULL; - // char newabs[FILE_MAXDIR + FILE_MAXFILE]; - // char newlocal[FILE_MAXDIR + FILE_MAXFILE]; + // char newabs[FILE_MAX]; + // char newlocal[FILE_MAX]; if (pf != NULL) { switch (how) { @@ -445,7 +445,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na int unpackVFont(ReportList *reports, VFont *vfont, int how) { - char localname[FILE_MAXDIR + FILE_MAXFILE], fi[FILE_MAXFILE]; + char localname[FILE_MAX], fi[FILE_MAXFILE]; char *newname; int ret_value = RET_ERROR; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 220068780a7..7c71df9fece 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3170,13 +3170,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf float t2; if(k==0) { - weight_to_rgb(pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); + weight_to_rgb(ca->col, pind.hkey[1]->weight); } else { float w1[3], w2[3]; keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - weight_to_rgb(pind.hkey[0]->weight, w1, w1+1, w1+2); - weight_to_rgb(pind.hkey[1]->weight, w2, w2+1, w2+2); + weight_to_rgb(w1, pind.hkey[0]->weight); + weight_to_rgb(w2, pind.hkey[1]->weight); interp_v3_v3v3(ca->col, w1, w2, keytime); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index dbfda18942a..5445c990a9b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -770,6 +770,9 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) pid->info_types= 0; pid->stack_index = pid->cache->index; + + pid->default_step = 10; + pid->max_step = 20; } void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) { @@ -820,6 +823,9 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p pid->data_types|= (1<<BPHYS_DATA_ROTATION); pid->info_types= (1<<BPHYS_DATA_TIMES); + + pid->default_step = 10; + pid->max_step = 20; } void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd) { @@ -850,6 +856,9 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY) | (1<<BPHYS_DATA_XCONST); pid->info_types= 0; + + pid->default_step = 1; + pid->max_step = 1; } void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) { @@ -890,6 +899,9 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW); if(sds->wt) pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH); + + pid->default_step = 1; + pid->max_step = 1; } void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface) @@ -923,6 +935,9 @@ void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSu pid->info_types= 0; pid->stack_index = pid->cache->index; + + pid->default_step = 1; + pid->max_step = 1; } void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis) @@ -1018,7 +1033,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup */ #define MAX_PTCACHE_PATH FILE_MAX -#define MAX_PTCACHE_FILE ((FILE_MAXDIR+FILE_MAXFILE)*2) +#define MAX_PTCACHE_FILE ((FILE_MAX)*2) static int ptcache_path(PTCacheID *pid, char *filename) { @@ -1112,7 +1127,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) { PTCacheFile *pf; FILE *fp = NULL; - char filename[(FILE_MAXDIR+FILE_MAXFILE)*2]; + char filename[(FILE_MAX)*2]; #ifndef DURIAN_POINTCACHE_LIB_OK /* don't allow writing for linked objects */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index ae958db3d4a..33fb15faa56 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -354,9 +354,11 @@ Scene *add_scene(const char *name) sce->r.mblur_samples= 1; sce->r.filtertype= R_FILTER_MITCH; sce->r.size= 50; - sce->r.planes= 24; - sce->r.imtype= R_PNG; - sce->r.quality= 90; + + sce->r.im_format.planes= R_IMF_PLANES_RGB; + sce->r.im_format.imtype= R_IMF_IMTYPE_PNG; + sce->r.im_format.quality= 90; + sce->r.displaymode= R_OUTPUT_AREA; sce->r.framapto= 100; sce->r.images= 100; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5d35867d9c3..249555578f0 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -652,7 +652,7 @@ void calc_sequence(Scene *scene, Sequence *seq) /* note: caller should run calc_sequence(scene, seq) after */ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) { - char str[FILE_MAXDIR+FILE_MAXFILE]; + char str[FILE_MAX]; int prev_startdisp=0, prev_enddisp=0; /* note: dont rename the strip, will break animation curves */ @@ -1156,7 +1156,7 @@ static IMB_Proxy_Size seq_rendersize_to_proxysize(int size) static void seq_open_anim_file(Sequence * seq) { - char name[FILE_MAXDIR+FILE_MAXFILE]; + char name[FILE_MAX]; StripProxy * proxy; if(seq->anim != NULL) { @@ -1327,8 +1327,8 @@ static void seq_proxy_build_frame(SeqRenderData context, ibuf->ftype= JPG | quality; /* unsupported feature only confuses other s/w */ - if(ibuf->depth==32) - ibuf->depth= 24; + if(ibuf->planes==32) + ibuf->planes= 24; BLI_make_existing_file(name); @@ -1729,7 +1729,7 @@ static ImBuf * input_preprocess( } if(seq->flag & SEQ_MAKE_PREMUL) { - if(ibuf->depth == 32 && ibuf->zbuf == NULL) { + if(ibuf->planes == 32 && ibuf->zbuf == NULL) { IMB_premultiply_alpha(ibuf); } } @@ -2057,7 +2057,7 @@ static ImBuf * seq_render_scene_strip_impl( static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfra) { ImBuf * ibuf = NULL; - char name[FILE_MAXDIR+FILE_MAXFILE]; + char name[FILE_MAX]; int use_preprocess = input_have_to_preprocess(context, seq, cfra); float nr = give_stripelem_index(seq, cfra); /* all effects are handled similarly with the exception of speed effect */ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 001d2abab01..1ad811c6580 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1173,8 +1173,6 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(drawAllEdges)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); - CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); int totedge = ccgSubSurf_getNumEdges(ss); int gridSize = ccgSubSurf_getGridSize(ss); @@ -1212,8 +1210,10 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw } if (ccgdm->drawInteriorEdges) { - for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { - CCGFace *f = ccgFaceIterator_getCurrent(fi); + int totface = ccgSubSurf_getNumFaces(ss); + + for(j = 0; j < totface; j++) { + CCGFace *f = ccgdm->faceMap[j].face; int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); for (S=0; S<numVerts; S++) { @@ -1238,18 +1238,15 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw } } } - - ccgFaceIterator_free(fi); - ccgEdgeIterator_free(ei); } static void ccgDM_drawLooseEdges(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); - int i, edgeSize = ccgSubSurf_getEdgeSize(ss); + int totedge = ccgSubSurf_getNumEdges(ss); + int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); - for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { - CCGEdge *e = ccgEdgeIterator_getCurrent(ei); + for (j=0; j< totedge; j++) { + CCGEdge *e = ccgdm->edgeMap[j].edge; DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); if (!ccgSubSurf_getEdgeNumFaces(e)) { @@ -1261,8 +1258,6 @@ static void ccgDM_drawLooseEdges(DerivedMesh *dm) { glEnd(); } } - - ccgEdgeIterator_free(ei); } static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) @@ -1283,10 +1278,11 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGFaceIterator *fi; int gridSize = ccgSubSurf_getGridSize(ss); char *faceFlags = ccgdm->faceFlags; int step = (fast)? gridSize-1: 1; + int i, totface = ccgSubSurf_getNumFaces(ss); + int drawcurrent = 0, matnr = -1, shademodel = -1; ccgdm_pbvh_update(ccgdm); @@ -1304,30 +1300,37 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) return; } - fi = ccgSubSurf_getFaceIterator(ss); - for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { - CCGFace *f = ccgFaceIterator_getCurrent(fi); + for(i = 0; i < totface; i++) { + CCGFace *f = ccgdm->faceMap[i].face; int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(ss, f)); - int drawSmooth, mat_nr; + int new_matnr, new_shademodel; if(faceFlags) { - drawSmooth = (faceFlags[index*2] & ME_SMOOTH); - mat_nr= faceFlags[index*2 + 1]; + new_shademodel = (faceFlags[index*2] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT; + new_matnr= faceFlags[index*2 + 1]; } else { - drawSmooth = 1; - mat_nr= 0; + new_shademodel = GL_SMOOTH; + new_matnr= 0; } - if (!setMaterial(mat_nr+1, NULL)) + if(shademodel != new_shademodel || matnr != new_matnr) { + matnr= new_matnr; + shademodel= new_shademodel; + + drawcurrent= setMaterial(matnr+1, NULL); + + glShadeModel(shademodel); + } + + if(!drawcurrent) continue; - glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT); for (S=0; S<numVerts; S++) { DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); - if (drawSmooth) { + if (shademodel == GL_SMOOTH) { for (y=0; y<gridSize-1; y+=step) { glBegin(GL_QUAD_STRIP); for (x=0; x<gridSize; x+=step) { @@ -1362,15 +1365,12 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) } } } - - ccgFaceIterator_free(fi); } /* Only used by non-editmesh types */ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), int (*setDrawOptions)(void *userData, int index), void *userData) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); GPUVertexAttribs gattribs; DMVertexAttribs attribs= {{{NULL}}}; /* MTFace *tf = dm->getFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */ @@ -1503,8 +1503,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v } #undef PASSATTRIB - - ccgFaceIterator_free(fi); } static void ccgDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs)) { @@ -1515,7 +1513,6 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *a static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); GPUVertexAttribs gattribs; DMVertexAttribs attribs= {{{NULL}}}; int gridSize = ccgSubSurf_getGridSize(ss); @@ -1655,18 +1652,15 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * } #undef PASSATTRIB - - ccgFaceIterator_free(fi); } static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), unsigned char *col1, unsigned char *col2) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); int gridSize = ccgSubSurf_getGridSize(ss); unsigned char *cp1, *cp2; - int useTwoSide=1; + int useTwoSide=1, i, totface; ccgdm_pbvh_update(ccgdm); @@ -1685,8 +1679,9 @@ static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), uns } glBegin(GL_QUADS); - for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { - CCGFace *f = ccgFaceIterator_getCurrent(fi); + totface = ccgSubSurf_getNumFaces(ss); + for(i = 0; i < totface; i++) { + CCGFace *f = ccgdm->faceMap[i].face; int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); for (S=0; S<numVerts; S++) { @@ -1725,8 +1720,6 @@ static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), uns } } glEnd(); - - ccgFaceIterator_free(fi); } static void ccgDM_drawFacesTex_common(DerivedMesh *dm, diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 5735a95764b..28d68892a2a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -237,12 +237,12 @@ int reopen_text(Text *text) int i, llen, len; unsigned char *buffer; TextLine *tmp; - char str[FILE_MAXDIR+FILE_MAXFILE]; + char str[FILE_MAX]; struct stat st; if (!text || !text->name) return 0; - BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(str, text->name, FILE_MAX); BLI_path_abs(str, G.main->name); fp= fopen(str, "r"); @@ -334,10 +334,10 @@ Text *add_text(const char *file, const char *relpath) unsigned char *buffer; TextLine *tmp; Text *ta; - char str[FILE_MAXDIR+FILE_MAXFILE]; + char str[FILE_MAX]; struct stat st; - BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(str, file, FILE_MAX); if (relpath) /* can be NULL (bg mode) */ BLI_path_abs(str, relpath); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 49e6d598ea2..474b00e626b 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -231,9 +231,12 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, float x, flo void BKE_tracking_insert_marker(MovieTrackingTrack *track, MovieTrackingMarker *marker) { - MovieTrackingMarker *old_marker= BKE_tracking_get_marker(track, marker->framenr); + MovieTrackingMarker *old_marker= NULL; - if(old_marker && old_marker->framenr==marker->framenr) { + if(track->markersnr) + old_marker= BKE_tracking_exact_marker(track, marker->framenr); + + if(old_marker) { *old_marker= *marker; } else { int a= track->markersnr; @@ -324,7 +327,7 @@ MovieTrackingMarker *BKE_tracking_ensure_marker(MovieTrackingTrack *track, int f { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); - if(marker && marker->framenr!=framenr) { + if(marker->framenr!=framenr) { MovieTrackingMarker marker_new; marker_new= *marker; @@ -341,7 +344,7 @@ MovieTrackingMarker *BKE_tracking_exact_marker(MovieTrackingTrack *track, int fr { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); - if(marker && marker->framenr!=framenr) + if(marker->framenr!=framenr) return NULL; return marker; @@ -440,7 +443,6 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio int BKE_tracking_test_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track) { int a= 0, b= 0; - /* int tot= dst_track->markersnr+src_track->markersnr; */ /* UNUSED */ int count= 0; while(a<src_track->markersnr || b<dst_track->markersnr) { @@ -858,13 +860,11 @@ static unsigned char *get_search_bytebuf(ImBuf *ibuf, MovieTrackingTrack *track, static ImBuf *get_frame_ibuf(MovieTrackingContext *context, int framenr) { ImBuf *ibuf; - int framenr_old= context->user.framenr; - - context->user.framenr= framenr; + MovieClipUser user= context->user; - ibuf= BKE_movieclip_get_ibuf_flag(context->clip, &context->user, 0); + user.framenr= framenr; - context->user.framenr= framenr_old; + ibuf= BKE_movieclip_get_ibuf_flag(context->clip, &user, 0); return ibuf; } @@ -1050,9 +1050,9 @@ int BKE_tracking_next(MovieTrackingContext *context) for(a= 0; a<context->num_tracks; a++) { TrackContext *track_context= &context->track_context[a]; MovieTrackingTrack *track= track_context->track; - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, curfra); + MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, curfra); - if(marker && (marker->flag&MARKER_DISABLED)==0 && marker->framenr==curfra) { + if(marker && (marker->flag&MARKER_DISABLED)==0) { #ifdef WITH_LIBMV int width, height, origin[2], tracked= 0, need_readjust= 0; float pos[2], margin[2]; @@ -1921,10 +1921,8 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width, while(track) { if(track->flag&TRACK_USE_2D_STAB || ((stab->flag&TRACKING_STABILIZE_ROTATION) && track==stab->rot_track)) { - if(track->markersnr) { - sfra= MIN2(sfra, track->markers[0].framenr); - efra= MAX2(efra, track->markers[track->markersnr-1].framenr); - } + sfra= MIN2(sfra, track->markers[0].framenr); + efra= MAX2(efra, track->markers[track->markersnr-1].framenr); } track= track->next; @@ -2024,7 +2022,7 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill) } } else { - cacheibuf= IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->depth, flags); + cacheibuf= IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags); cacheibuf->profile= srcibuf->profile; } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 03091a08c58..8cd30912840 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -67,7 +67,7 @@ static void filepath_avi(char *string, RenderData *rd); #include "BKE_writeframeserver.h" -bMovieHandle *BKE_get_movie_handle(int imtype) +bMovieHandle *BKE_get_movie_handle(const char imtype) { static bMovieHandle mh; @@ -80,14 +80,14 @@ bMovieHandle *BKE_get_movie_handle(int imtype) /* do the platform specific handles */ #if defined(_WIN32) && !defined(FREE_WINDOWS) - if (imtype == R_AVICODEC) { + if (imtype == R_IMF_IMTYPE_AVICODEC) { //XXX mh.start_movie= start_avi_codec; //XXX mh.append_movie= append_avi_codec; //XXX mh.end_movie= end_avi_codec; } #endif #ifdef WITH_QUICKTIME - if (imtype == R_QUICKTIME) { + if (imtype == R_IMF_IMTYPE_QUICKTIME) { mh.start_movie= start_qt; mh.append_movie= append_qt; mh.end_movie= end_qt; @@ -95,7 +95,7 @@ bMovieHandle *BKE_get_movie_handle(int imtype) } #endif #ifdef WITH_FFMPEG - if (ELEM4(imtype, R_FFMPEG, R_H264, R_XVID, R_THEORA)) { + if (ELEM4(imtype, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_THEORA)) { mh.start_movie = start_ffmpeg; mh.append_movie = append_ffmpeg; mh.end_movie = end_ffmpeg; @@ -103,7 +103,7 @@ bMovieHandle *BKE_get_movie_handle(int imtype) } #endif #ifdef WITH_FRAMESERVER - if (imtype == R_FRAMESERVER) { + if (imtype == R_IMF_IMTYPE_FRAMESERVER) { mh.start_movie = start_frameserver; mh.append_movie = append_frameserver; mh.end_movie = end_frameserver; @@ -154,7 +154,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL x = rectx; y = recty; - quality= rd->quality; + quality= rd->im_format.quality; framerate= (double) rd->frs_sec / (double) rd->frs_sec_base; avi = MEM_mallocN (sizeof(AviMovie), "avimovie"); @@ -162,7 +162,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL /* RPW 11-21-2002 if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB; */ - if (rd->imtype != R_AVIJPEG ) format = AVI_FORMAT_AVI_RGB; + if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG ) format = AVI_FORMAT_AVI_RGB; else format = AVI_FORMAT_MJPEG; if (AVI_open_compress (name, avi, 1, format) != AVI_ERROR_NONE) { @@ -233,7 +233,7 @@ static void end_avi(void) /* similar to BKE_makepicstring() */ void BKE_makeanimstring(char *string, RenderData *rd) { - bMovieHandle *mh= BKE_get_movie_handle(rd->imtype); + bMovieHandle *mh= BKE_get_movie_handle(rd->im_format.imtype); if(mh->get_movie_path) mh->get_movie_path(string, rd); else diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 3af724b4e30..aa7d71b1577 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1337,7 +1337,7 @@ void ffmpeg_verify_image_type(RenderData *rd) { int audio= 0; - if(rd->imtype == R_FFMPEG) { + if(rd->imtype == R_IMF_IMTYPE_FFMPEG) { if(rd->ffcodecdata.type <= 0 || rd->ffcodecdata.codec <= 0 || rd->ffcodecdata.audio_codec <= 0 || @@ -1353,19 +1353,19 @@ void ffmpeg_verify_image_type(RenderData *rd) audio= 1; } - else if(rd->imtype == R_H264) { + else if(rd->imtype == R_IMF_IMTYPE_H264) { if(rd->ffcodecdata.codec != CODEC_ID_H264) { ffmpeg_set_preset(rd, FFMPEG_PRESET_H264); audio= 1; } } - else if(rd->imtype == R_XVID) { + else if(rd->imtype == R_IMF_IMTYPE_XVID) { if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) { ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID); audio= 1; } } - else if(rd->imtype == R_THEORA) { + else if(rd->imtype == R_IMF_IMTYPE_THEORA) { if(rd->ffcodecdata.codec != CODEC_ID_THEORA) { ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA); audio= 1; diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 2b9d6d2d6d6..d8e880a9dec 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -194,17 +194,20 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]); /***************************** Array Functions *******************************/ /* attempted to follow fixed length vertex functions. names could be improved*/ -void range_vni(int *array, const int size, const int start); +double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size); +float normalize_vn_vn(float *array_tar, const float *array_src, const int size); +float normalize_vn(float *array_tar, const int size); +void range_vn_i(int *array_tar, const int size, const int start); void negate_vn(float *array_tar, const int size); void negate_vn_vn(float *array_tar, const float *array_src, const int size); -void mul_vn_fl(float *array, const int size, const float f); +void mul_vn_fl(float *array_tar, const int size, const float f); void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f); void add_vn_vn(float *array_tar, const float *array_src, const int size); void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size); void sub_vn_vn(float *array_tar, const float *array_src, const int size); void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size); -void fill_vni(int *array_tar, const int size, const int val); -void fill_vn(float *array_tar, const int size, const float val); +void fill_vn_i(int *array_tar, const int size, const int val); +void fill_vn_fl(float *array_tar, const int size, const float val); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index 69b5612b118..6eba7d5eb49 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -32,6 +32,7 @@ extern "C" { #endif char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy); +char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy); int BLI_utf8_invalid_byte(const char *str, int length); int BLI_utf8_invalid_strip(char *str, int length); diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 4507d70e339..b7df06bbf24 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -287,20 +287,28 @@ static DLRBT_Node *get_grandparent (DLRBT_Node *node) return NULL; } -/* get the 'uncle' - the sibling of the parent - of the given node */ -static DLRBT_Node *get_uncle (DLRBT_Node *node) +/* get the sibling node (e.g. if node is left child of parent, return right child of parent) */ +static DLRBT_Node *get_sibling(DLRBT_Node *node) { - DLRBT_Node *gpn= get_grandparent(node); - - /* return the child of the grandparent which isn't the node's parent */ - if (gpn) { - if (gpn->left == node->parent) - return gpn->right; + if (node && node->parent) { + if (node == node->parent->left) + return node->parent->right; else - return gpn->left; + return node->parent->left; } + + /* sibling not found */ + return NULL; +} + +/* get the 'uncle' - the sibling of the parent - of the given node */ +static DLRBT_Node *get_uncle (DLRBT_Node *node) +{ + if (node) + /* return the child of the grandparent which isn't the node's parent */ + return get_sibling(node->parent); - /* not found */ + /* uncle not found */ return NULL; } diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 01c3e112cd8..a9ea90ef555 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -378,7 +378,37 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]) /***************************** Array Functions *******************************/ -void range_vni(int *array_tar, const int size, const int start) +double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size) +{ + double d= 0.0f; + const float *array_pt_a= array_src_a + (size-1); + const float *array_pt_b= array_src_b + (size-1); + int i= size; + while(i--) { d += *(array_pt_a--) * *(array_pt_b--); } + return d; +} + +float normalize_vn_vn(float *array_tar, const float *array_src, const int size) +{ + double d= dot_vn_vn(array_tar, array_src, size); + float d_sqrt; + if (d > 1.0e-35) { + d_sqrt= (float)sqrt(d); + mul_vn_vn_fl(array_tar, array_src, size, 1.0f/d_sqrt); + } + else { + fill_vn_fl(array_tar, size, 0.0f); + d_sqrt= 0.0f; + } + return d_sqrt; +} + +float normalize_vn(float *array_tar, const int size) +{ + return normalize_vn_vn(array_tar, array_tar, size); +} + +void range_vn_i(int *array_tar, const int size, const int start) { int *array_pt= array_tar + (size-1); int j= start + (size-1); @@ -450,14 +480,14 @@ void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_ while(i--) { *(tar--) = *(src_a--) - *(src_b--); } } -void fill_vni(int *array_tar, const int size, const int val) +void fill_vn_i(int *array_tar, const int size, const int val) { int *tar= array_tar + (size-1); int i= size; while(i--) { *(tar--) = val; } } -void fill_vn(float *array_tar, const int size, const float val) +void fill_vn_fl(float *array_tar, const int size, const float val) { float *tar= array_tar + (size-1); int i= size; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 08d9dfaeb9e..e79d850caa5 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -44,6 +44,7 @@ #include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "BKE_utildefines.h" @@ -220,16 +221,25 @@ int BLI_uniquename_cb(int (*unique_check)(void *, const char *), void *arg, cons } if(unique_check(arg, name)) { + char numstr[16]; char tempname[UNIQUE_NAME_MAX]; char left[UNIQUE_NAME_MAX]; int number; int len= BLI_split_name_num(left, &number, name, delim); do { - int newlen= BLI_snprintf(tempname, name_len, "%s%c%03d", left, delim, ++number); - if(newlen >= name_len) { - len -= ((newlen + 1) - name_len); - if(len < 0) len= number= 0; - left[len]= '\0'; + int numlen= BLI_snprintf(numstr, sizeof(numstr), "%c%03d", delim, ++number); + + /* highly unlikely the string only has enough room for the number + * but support anyway */ + if ((len == 0) || (numlen >= name_len)) { + /* number is know not to be utf-8 */ + BLI_strncpy(tempname, numstr, name_len); + } + else { + char *tempname_buf; + tempname[0]= '\0'; + tempname_buf =BLI_strncat_utf8(tempname, left, name_len - numlen); + memcpy(tempname_buf, numstr, numlen + 1); } } while(unique_check(arg, tempname)); @@ -416,8 +426,8 @@ void BLI_cleanup_file(const char *relabase, char *dir) void BLI_path_rel(char *file, const char *relfile) { char * lslash; - char temp[FILE_MAXDIR+FILE_MAXFILE]; - char res[FILE_MAXDIR+FILE_MAXFILE]; + char temp[FILE_MAX]; + char res[FILE_MAX]; /* if file is already relative, bail out */ if(file[0]=='/' && file[1]=='/') return; @@ -435,9 +445,9 @@ void BLI_path_rel(char *file, const char *relfile) if (relfile[0] != '\\' && relfile[0] != '/') { ptemp++; } - BLI_strncpy(ptemp, relfile, FILE_MAXDIR + FILE_MAXFILE-3); + BLI_strncpy(ptemp, relfile, FILE_MAX-3); } else { - BLI_strncpy(temp, relfile, FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(temp, relfile, FILE_MAX); } if (BLI_strnlen(file, 3) > 2) { @@ -529,7 +539,7 @@ int BLI_has_parent(char *path) int BLI_parent_dir(char *path) { static char parent_dir[]= {'.', '.', SEP, '\0'}; /* "../" or "..\\" */ - char tmp[FILE_MAXDIR+FILE_MAXFILE+4]; + char tmp[FILE_MAX+4]; BLI_strncpy(tmp, path, sizeof(tmp)-4); BLI_add_slash(tmp); strcat(tmp, parent_dir); @@ -734,7 +744,7 @@ int BLI_path_cwd(char *path) #endif if (wasrelative==1) { - char cwd[FILE_MAXDIR + FILE_MAXFILE]= ""; + char cwd[FILE_MAX]= ""; BLI_current_working_dir(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */ if (cwd[0] == '\0') { @@ -747,8 +757,8 @@ int BLI_path_cwd(char *path) * blend file which isnt a feature we want to use in this case since were dealing * with a path from the command line, rather than from inside Blender */ - char origpath[FILE_MAXDIR + FILE_MAXFILE]; - BLI_strncpy(origpath, path, FILE_MAXDIR + FILE_MAXFILE); + char origpath[FILE_MAX]; + BLI_strncpy(origpath, path, FILE_MAX); BLI_make_file_string(NULL, path, cwd, origpath); } @@ -1246,7 +1256,7 @@ void BLI_make_exist(char *dir) void BLI_make_existing_file(const char *name) { - char di[FILE_MAXDIR+FILE_MAXFILE], fi[FILE_MAXFILE]; + char di[FILE_MAX], fi[FILE_MAXFILE]; BLI_strncpy(di, name, sizeof(di)); BLI_splitdirstring(di, fi); @@ -1695,8 +1705,8 @@ static int add_win32_extension(char *name) type = BLI_exists(name); if ((type == 0) || S_ISDIR(type)) { #ifdef _WIN32 - char filename[FILE_MAXDIR+FILE_MAXFILE]; - char ext[FILE_MAXDIR+FILE_MAXFILE]; + char filename[FILE_MAX]; + char ext[FILE_MAX]; const char *extensions = getenv("PATHEXT"); if (extensions) { char *temp; @@ -1742,7 +1752,7 @@ static int add_win32_extension(char *name) */ static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name) { - char filename[FILE_MAXDIR+FILE_MAXFILE]; + char filename[FILE_MAX]; const char *path = NULL, *temp; #ifdef _WIN32 diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 0ac6e0ba4df..5c7a29c6277 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -656,12 +656,17 @@ void BLI_pbvh_free(PBVH *bvh) /* if pbvh was deformed, new memory was allocated for verts/faces -- free it */ MEM_freeN(bvh->verts); - MEM_freeN(bvh->faces); + if(bvh->faces) + MEM_freeN(bvh->faces); } } - MEM_freeN(bvh->nodes); - MEM_freeN(bvh->prim_indices); + if(bvh->nodes) + MEM_freeN(bvh->nodes); + + if(bvh->prim_indices) + MEM_freeN(bvh->prim_indices); + MEM_freeN(bvh); } @@ -1127,6 +1132,9 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3]) PBVHNode **nodes; int totnode; + if(!bvh->nodes) + return; + BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag), &nodes, &totnode); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 86095e6b909..1ef254d355f 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -442,18 +442,18 @@ int BLI_exists(const char *name) /* in Windows stat doesn't recognize dir ending on a slash To not break code where the ending slash is expected we don't mess with the argument name directly here - elubie */ - char tmp[FILE_MAXDIR+FILE_MAXFILE]; + char tmp[FILE_MAX]; int len, res; - BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(tmp, name, FILE_MAX); len = strlen(tmp); if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; res = _stat(tmp, &st); if (res == -1) return(0); #elif defined(__MINGW32__) struct _stati64 st; - char tmp[FILE_MAXDIR+FILE_MAXFILE]; + char tmp[FILE_MAX]; int len, res; - BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(tmp, name, FILE_MAX); len = strlen(tmp); if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; res = _stati64(tmp, &st); diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index f8cdc3ec873..89136f270e2 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -163,28 +163,46 @@ static const size_t utf8_skip_data[256] = { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1 }; +#define BLI_STR_UTF8_CPY(dst, src, maxncpy) \ + { \ + size_t utf8_size; \ + while(*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) { \ + maxncpy -= utf8_size; \ + switch(utf8_size) { \ + case 6: *dst ++ = *src ++; \ + case 5: *dst ++ = *src ++; \ + case 4: *dst ++ = *src ++; \ + case 3: *dst ++ = *src ++; \ + case 2: *dst ++ = *src ++; \ + case 1: *dst ++ = *src ++; \ + } \ + } \ + *dst= '\0'; \ + } + char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy) { char *dst_r= dst; - size_t utf8_size; /* note: currently we dont attempt to deal with invalid utf8 chars */ + BLI_STR_UTF8_CPY(dst, src, maxncpy) - while(*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) { - maxncpy -= utf8_size; - switch(utf8_size) { - case 6: *dst ++ = *src ++; - case 5: *dst ++ = *src ++; - case 4: *dst ++ = *src ++; - case 3: *dst ++ = *src ++; - case 2: *dst ++ = *src ++; - case 1: *dst ++ = *src ++; - } - } - *dst= '\0'; return dst_r; } +char *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy) +{ + while (*dst && maxncpy > 0) { + dst++; + maxncpy--; + } + + BLI_STR_UTF8_CPY(dst, src, maxncpy) + + return dst; +} + +#undef BLI_STR_UTF8_CPY /* --------------------------------------------------------------------------*/ /* wchar_t / utf8 functions */ diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index d3e989c28ae..1b5bb607386 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -47,13 +47,13 @@ #define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY #include "BLI_winstuff.h" - /* FILE_MAXDIR + FILE_MAXFILE */ + /* FILE_MAX */ int BLI_getInstallationDir( char * str ) { char dir[FILE_MAXDIR]; int a; - GetModuleFileName(NULL,str,FILE_MAXDIR+FILE_MAXFILE); + GetModuleFileName(NULL,str,FILE_MAX); BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */ a = strlen(dir); if(dir[a-1] == '\\') dir[a-1]=0; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c96d7f7ffa1..9246773bdc1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -501,7 +501,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepat { Main *m; Library *lib; - char name1[FILE_MAXDIR+FILE_MAXFILE]; + char name1[FILE_MAX]; BLI_strncpy(name1, filepath, sizeof(name1)); cleanup_path(relabase, name1); @@ -6668,8 +6668,8 @@ static void customdata_version_242(Mesh *me) if (layer->type == CD_MTFACE) { if (layer->name[0] == 0) { - if (mtfacen == 0) strcpy(layer->name, "UVTex"); - else sprintf(layer->name, "UVTex.%.3d", mtfacen); + if (mtfacen == 0) strcpy(layer->name, "UVMap"); + else sprintf(layer->name, "UVMap.%.3d", mtfacen); } mtfacen++; } @@ -7537,6 +7537,67 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree) } } +void do_versions_image_settings_2_60(Scene *sce) +{ + /* note: rd->subimtype is moved into indervidual settings now and no longer + * exists */ + RenderData *rd= &sce->r; + ImageFormatData *imf= &sce->r.im_format; + + imf->imtype= rd->imtype; + imf->planes= rd->planes; + imf->compress= rd->quality; + imf->quality= rd->quality; + + /* default, was stored in multiple places, may override later */ + imf->depth= R_IMF_CHAN_DEPTH_8; + + /* openexr */ + imf->exr_codec = rd->quality & 7; /* strange but true! 0-4 are valid values, OPENEXR_COMPRESS */ + + switch (imf->imtype) { + case R_IMF_IMTYPE_OPENEXR: + imf->depth= (rd->subimtype & R_OPENEXR_HALF) ? R_IMF_CHAN_DEPTH_16 : R_IMF_CHAN_DEPTH_32; + if (rd->subimtype & R_PREVIEW_JPG) { + imf->flag |= R_IMF_FLAG_PREVIEW_JPG; + } + if (rd->subimtype & R_OPENEXR_ZBUF) { + imf->flag |= R_IMF_FLAG_ZBUF; + } + break; + case R_IMF_IMTYPE_TIFF: + if (rd->subimtype & R_TIFF_16BIT) { + imf->depth= R_IMF_CHAN_DEPTH_16; + } + break; + case R_IMF_IMTYPE_JP2: + if (rd->subimtype & R_JPEG2K_16BIT) { + imf->depth= R_IMF_CHAN_DEPTH_16; + } + else if (rd->subimtype & R_JPEG2K_12BIT) { + imf->depth= R_IMF_CHAN_DEPTH_12; + } + + if (rd->subimtype & R_JPEG2K_YCC) { + imf->jp2_flag |= R_IMF_JP2_FLAG_YCC; + } + if (rd->subimtype & R_JPEG2K_CINE_PRESET) { + imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET; + } + if (rd->subimtype & R_JPEG2K_CINE_48FPS) { + imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_48; + } + break; + case R_IMF_IMTYPE_CINEON: + case R_IMF_IMTYPE_DPX: + if (rd->subimtype & R_CINEON_LOG) { + imf->cineon_flag |= R_IMF_CINEON_FLAG_LOG; + } + break; + } + +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -12733,6 +12794,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* put compatibility code here until next subversion bump */ { + Scene *sce; + for(sce = main->scene.first; sce; sce = sce->id.next) { + if (sce->r.im_format.depth == 0) { + do_versions_image_settings_2_60(sce); + } + } } /* default values in Freestyle settings */ diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 358a7659d51..c7a53555415 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -59,7 +59,7 @@ typedef struct FileData { gzFile gzfiledes; // now only in use for library appending - char relabase[FILE_MAXDIR+FILE_MAXFILE]; + char relabase[FILE_MAX]; // variables needed for reading from stream char headerdone; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 5e985e64288..74aa502d982 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1667,7 +1667,8 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, writestruct(wd, DATA, structname, datasize, layer->data); } else - printf("error: this CustomDataLayer must not be written to file\n"); + printf("%s error: layer '%s':%d - can't be written to file\n", + __func__, structname, layer->type); } } @@ -2903,7 +2904,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil /* return: success(0), failure(1) */ static int do_history(const char *name, ReportList *reports) { - char tempname1[FILE_MAXDIR+FILE_MAXFILE], tempname2[FILE_MAXDIR+FILE_MAXFILE]; + char tempname1[FILE_MAX], tempname2[FILE_MAX]; int hisnr= U.versions; if(U.versions==0) return 0; @@ -2937,8 +2938,8 @@ static int do_history(const char *name, ReportList *reports) /* return: success (1) */ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, int *thumb) { - char userfilename[FILE_MAXDIR+FILE_MAXFILE]; - char tempname[FILE_MAXDIR+FILE_MAXFILE+1]; + char userfilename[FILE_MAX]; + char tempname[FILE_MAX+1]; int file, err, write_user_block; /* open temporary file, so we preserve the original in case we crash */ @@ -2952,8 +2953,8 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL /* remapping of relative paths to new file location */ if(write_flags & G_FILE_RELATIVE_REMAP) { - char dir1[FILE_MAXDIR+FILE_MAXFILE]; - char dir2[FILE_MAXDIR+FILE_MAXFILE]; + char dir1[FILE_MAX]; + char dir2[FILE_MAX]; BLI_split_dir_part(filepath, dir1, sizeof(dir1)); BLI_split_dir_part(mainvar->name, dir2, sizeof(dir2)); @@ -3004,7 +3005,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL if(write_flags & G_FILE_COMPRESS) { /* compressed files have the same ending as regular files... only from 2.4!!! */ - char gzname[FILE_MAXDIR+FILE_MAXFILE+4]; + char gzname[FILE_MAX+4]; int ret; /* first write compressed to separate @.gz */ diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 22a3b713161..8bc9755faae 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -196,7 +196,7 @@ void GeometryExporter::createPolylist(short material_index, COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD, makeUrl(makeTexcoordSourceId(geom_id, i)), 2, // offset always 2, this is only until we have optimized UV sets - i // set number equals UV layer index + i // set number equals UV map index ); til.push_back(input3); } diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index ceb4b295f2f..40ca1bc3b0e 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -55,7 +55,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia ostr << translate_id(id_name(ma)) << a+1; COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); - // create <bind_vertex_input> for each uv layer + // create <bind_vertex_input> for each uv map Mesh *me = (Mesh*)ob->data; int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 4e7c35315fc..e57d2acd41d 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -417,7 +417,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T me->totface = mesh->getFacesCount() + new_tris; me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface); - // allocate UV layers + // allocate UV Maps unsigned int totuvset = mesh->getUVCoords().getInputInfosArray().getCount(); for (i = 0; i < totuvset; i++) { @@ -433,7 +433,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T //this->set_layername_map[i] = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i); } - // activate the first uv layer + // activate the first uv map if (totuvset) me->mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0); UVDataWrapper uvs(mesh->getUVCoords()); diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index d329874e1ba..05f9248e0a6 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -569,7 +569,7 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* draw settings for stepped interpolation modifier */ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, short UNUSED(width)) { - uiLayout *col, *subcol; + uiLayout *col, *sub; PointerRNA ptr; /* init the RNA-pointer */ @@ -584,17 +584,17 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho col= uiLayoutColumn(layout, 1); uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - subcol = uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&ptr, "use_frame_start")); - uiItemR(subcol, &ptr, "frame_start", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); + uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); /* block 3: end range settings */ col= uiLayoutColumn(layout, 1); uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - subcol = uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&ptr, "use_frame_end")); - uiItemR(subcol, &ptr, "frame_end", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); + uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); } /* --------------- */ @@ -602,7 +602,7 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm) { FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); - uiLayout *box, *row, *subrow, *col; + uiLayout *box, *row, *sub, *col; uiBlock *block; uiBut *but; short width= 314; @@ -620,30 +620,30 @@ void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifie block= uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ - subrow= uiLayoutRow(row, 1); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); + sub= uiLayoutRow(row, 1); + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); /* expand */ - uiItemR(subrow, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + uiItemR(sub, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* checkbox for 'active' status (for now) */ - uiItemR(subrow, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* name */ if (fmi) - uiItemL(subrow, fmi->name, ICON_NONE); + uiItemL(sub, fmi->name, ICON_NONE); else - uiItemL(subrow, "<Unknown Modifier>", ICON_NONE); + uiItemL(sub, "<Unknown Modifier>", ICON_NONE); /* right-align ------------------------------------------- */ - subrow= uiLayoutRow(row, 1); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); + sub= uiLayoutRow(row, 1); + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); /* 'mute' button */ - uiItemR(subrow, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + uiItemR(sub, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiBlockSetEmboss(block, UI_EMBOSSN); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index def6cd61370..d40831f9e87 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -107,7 +107,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick if (totpoints == 1) { /* draw point */ glBegin(GL_POINTS); - glVertex2f(points->x, points->y); + glVertex2iv(&points->x); glEnd(); } else if (sflag & GP_STROKE_ERASER) { @@ -132,18 +132,15 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick glBegin(GL_LINE_STRIP); /* need to roll-back one point to ensure that there are no gaps in the stroke */ - if (i != 0) { - pt--; - glVertex2f(pt->x, pt->y); - pt++; - } + if (i != 0) glVertex2iv(&(pt - 1)->x); + /* now the point we want... */ - glVertex2f(pt->x, pt->y); + glVertex2iv(&pt->x); oldpressure = pt->pressure; } else - glVertex2f(pt->x, pt->y); + glVertex2iv(&pt->x); } glEnd(); @@ -162,7 +159,7 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl /* draw point */ if (sflag & GP_STROKE_3DSPACE) { glBegin(GL_POINTS); - glVertex3f(points->x, points->y, points->z); + glVertex3fv(&points->x); glEnd(); } else { @@ -228,18 +225,16 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes glBegin(GL_LINE_STRIP); /* need to roll-back one point to ensure that there are no gaps in the stroke */ - if (i != 0) { - pt--; - glVertex3f(pt->x, pt->y, pt->z); - pt++; - } + if (i != 0) glVertex3fv(&(pt - 1)->x); + /* now the point we want... */ - glVertex3f(pt->x, pt->y, pt->z); + glVertex3fv(&pt->x); oldpressure = pt->pressure; } - else - glVertex3f(pt->x, pt->y, pt->z); + else { + glVertex3fv(&pt->x); + } } glEnd(); @@ -247,7 +242,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes if (debug) { glBegin(GL_POINTS); for (i=0, pt=points; i < totpoints && pt; i++, pt++) - glVertex3f(pt->x, pt->y, pt->z); + glVertex3fv(&pt->x); glEnd(); } } @@ -461,7 +456,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s glBegin(GL_POINTS); for (i=0, pt=points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { - glVertex2f(pt->x, pt->y); + glVertex2fv(&pt->x); } else if (sflag & GP_STROKE_2DIMAGE) { const float x= (float)((pt->x * winx) + offsx); diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 192f5c10d07..57dd1ef5572 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -95,8 +95,8 @@ static void gp_ui_dellayer_cb (bContext *C, void *gpd, void *gpl) static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, const short is_v3d) { uiLayout *box=NULL, *split=NULL; - uiLayout *col=NULL, *subcol=NULL; - uiLayout *row=NULL, *subrow=NULL; + uiLayout *col=NULL; + uiLayout *row=NULL, *sub=NULL; uiBlock *block; uiBut *but; PointerRNA ptr; @@ -120,17 +120,17 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con uiBlockSetEmboss(block, UI_EMBOSSN); /* left-align ............................... */ - subrow= uiLayoutRow(row, 0); + sub= uiLayoutRow(row, 0); /* active */ - block= uiLayoutGetBlock(subrow); + block= uiLayoutGetBlock(sub); icon= (gpl->flag & GP_LAYER_ACTIVE) ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF; but= uiDefIconBut(block, BUT, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Set active layer"); uiButSetFunc(but, gp_ui_activelayer_cb, gpd, gpl); /* locked */ icon= (gpl->flag & GP_LAYER_LOCKED) ? ICON_LOCKED : ICON_UNLOCKED; - uiItemR(subrow, &ptr, "lock", 0, "", icon); + uiItemR(sub, &ptr, "lock", 0, "", icon); /* when layer is locked or hidden, only draw header */ if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) { @@ -138,7 +138,7 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con /* visibility button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) - uiItemR(subrow, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_ON); + uiItemR(sub, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_ON); /* name */ @@ -146,14 +146,14 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con sprintf(name, "%s (Hidden)", gpl->info); else sprintf(name, "%s (Locked)", gpl->info); - uiItemL(subrow, name, ICON_NONE); + uiItemL(sub, name, ICON_NONE); /* delete button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) { /* right-align ............................... */ - subrow= uiLayoutRow(row, 1); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); - block= uiLayoutGetBlock(subrow); // XXX... err... + sub= uiLayoutRow(row, 1); + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); + block= uiLayoutGetBlock(sub); // XXX... err... but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Delete layer"); uiButSetFunc(but, gp_ui_dellayer_cb, gpd, gpl); @@ -163,24 +163,24 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con else { /* draw rest of header -------------------------------- */ /* visibility button */ - uiItemR(subrow, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_OFF); + uiItemR(sub, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_OFF); /* frame locking */ // TODO: this needs its own icons... icon= (gpl->flag & GP_LAYER_FRAMELOCK) ? ICON_RENDER_STILL : ICON_RENDER_ANIMATION; - uiItemR(subrow, &ptr, "lock_frame", 0, "", icon); + uiItemR(sub, &ptr, "lock_frame", 0, "", icon); uiBlockSetEmboss(block, UI_EMBOSS); /* name */ - uiItemR(subrow, &ptr, "info", 0, "", ICON_NONE); + uiItemR(sub, &ptr, "info", 0, "", ICON_NONE); /* delete 'button' */ uiBlockSetEmboss(block, UI_EMBOSSN); /* right-align ............................... */ - subrow= uiLayoutRow(row, 1); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); - block= uiLayoutGetBlock(subrow); // XXX... err... + sub= uiLayoutRow(row, 1); + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); + block= uiLayoutGetBlock(sub); // XXX... err... but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Delete layer"); uiButSetFunc(but, gp_ui_dellayer_cb, gpd, gpl); @@ -196,32 +196,29 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con col= uiLayoutColumn(split, 0); /* color */ - subcol= uiLayoutColumn(col, 1); - uiItemR(subcol, &ptr, "color", 0, "", ICON_NONE); - uiItemR(subcol, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + sub= uiLayoutColumn(col, 1); + uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); + uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* stroke thickness */ - subcol= uiLayoutColumn(col, 1); - uiItemR(subcol, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* debugging options */ if (G.f & G_DEBUG) { - subcol= uiLayoutColumn(col, 1); - uiItemR(subcol, &ptr, "show_points", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "show_points", 0, NULL, ICON_NONE); } /* right column ................... */ col= uiLayoutColumn(split, 0); /* onion-skinning */ - subcol= uiLayoutColumn(col, 1); - uiItemR(subcol, &ptr, "use_onion_skinning", 0, "Onion Skinning", ICON_NONE); - uiItemR(subcol, &ptr, "ghost_range_max", 0, "Frames", ICON_NONE); // XXX shorter name here? i.e. GStep + sub= uiLayoutColumn(col, 1); + uiItemR(sub, &ptr, "use_onion_skinning", 0, "Onion Skinning", ICON_NONE); + uiItemR(sub, &ptr, "ghost_range_max", 0, "Frames", ICON_NONE); // XXX shorter name here? i.e. GStep /* 3d-view specific drawing options */ if (is_v3d) { - subcol= uiLayoutColumn(col, 0); - uiItemR(subcol, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE); + uiItemR(col, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE); } } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index f09797bf6f1..6c93727bf55 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -331,8 +331,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= (tGPspoint *)(gpd->sbuffer); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* increment buffer size */ @@ -345,8 +344,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= ((tGPspoint *)(gpd->sbuffer) + 1); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* if this is just the second point we've added, increment the buffer size @@ -369,8 +367,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* increment counters */ @@ -387,8 +384,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= (tGPspoint *)(gpd->sbuffer); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* if there's stroke for this poly line session add (or replace last) point @@ -475,9 +471,8 @@ static void gp_stroke_smooth (tGPsdata *p) /* second pass: apply smoothed coordinates */ for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); - - pc->x = spc->x; - pc->y = spc->y; + + copy_v2_v2_int(&pc->x, &spc->x); } /* free temp array */ @@ -653,7 +648,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) depth_arr= MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { - mval[0]= ptc->x; mval[1]= ptc->y; + copy_v2_v2_int(mval, &ptc->x); if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) && (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0)) diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index d2ac24cd9da..2cd610e1fe4 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -205,6 +205,7 @@ void paintface_reveal(struct Object *ob); struct bDeformGroup *ED_vgroup_add(struct Object *ob); struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name); void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup); +void ED_vgroup_clear(struct Object *ob); void ED_vgroup_select_by_name(struct Object *ob, const char *name); int ED_vgroup_data_create(struct ID *id); int ED_vgroup_give_array(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 4e0f59afc15..39d6ba8bc1b 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -139,6 +139,7 @@ enum { struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type); int ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); +void ED_object_modifier_clear(struct Main *bmain, struct Scene *scene, struct Object *ob); int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index c2390d41d8c..26c3ffed91c 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -292,5 +292,6 @@ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); +void ED_view3D_background_image_clear(struct View3D *v3d); #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index a0b477413e4..d1f11d60999 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -115,12 +115,14 @@ typedef struct uiLayout uiLayout; #define UI_BLOCK_OUT_1 1024 #define UI_BLOCK_NO_FLIP 2048 #define UI_BLOCK_POPUP_MEMORY 4096 +#define UI_BLOCK_CLIP_EVENTS 8192 /* stop handling mouse events */ /* uiPopupBlockHandle->menuretval */ #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ #define UI_RETURN_OK 2 /* choice made */ #define UI_RETURN_OUT 4 /* left the menu */ #define UI_RETURN_UPDATE 8 /* update the button that opened */ +#define UI_RETURN_POPUP_OK 16 /* popup is ok to be handled */ /* block->flag bits 12-15 are identical to but->flag bits */ @@ -277,6 +279,30 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float #define UI_SCROLL_NO_OUTLINE 4 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state); +/* Callbacks + * + * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback. + * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is + * mostly for compatibility with older code. + * + * uiButSetCompleteFunc is for tab completion. + * + * uiButSearchFunc is for name buttons, showing a popup with matches + * + * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used, + * in case events, operators or RNA are not sufficient to handle the button. + * + * uiButSetNFunc will free the argument with MEM_freeN. */ + +typedef struct uiSearchItems uiSearchItems; + +typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2); +typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr); +typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2); +typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); +typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, const char *str, uiSearchItems *items); +typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); + /* Menu Callbacks */ typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1); @@ -312,7 +338,7 @@ typedef void (*uiBlockCancelFunc)(void *arg1); void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg); void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext); -void uiPupBlockEx(struct bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_func, void *arg); +void uiPupBlockEx(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg); /* void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); */ /* UNUSED */ void uiPupBlockClose(struct bContext *C, uiBlock *block); @@ -364,6 +390,7 @@ void uiTextBoundsBlock(uiBlock *block, int addval); void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my); void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my); void uiCenteredBoundsBlock(uiBlock *block, int addval); +void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy); int uiBlocksGetYMin (struct ListBase *lb); @@ -515,7 +542,7 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, i uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip); uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); -int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PropertyRNA *), const char label_align); +int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align); /* Links * @@ -527,30 +554,6 @@ void uiSetButLink(struct uiBut *but, void **poin, void ***ppoin, short *tot, void uiComposeLinks(uiBlock *block); uiBut *uiFindInlink(uiBlock *block, void *poin); -/* Callbacks - * - * uiBlockSetHandleFunc/ButmFunc are for handling events through a callback. - * HandleFunc gets the retval passed on, and ButmFunc gets a2. The latter is - * mostly for compatibility with older code. - * - * uiButSetCompleteFunc is for tab completion. - * - * uiButSearchFunc is for name buttons, showing a popup with matches - * - * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used, - * in case events, operators or RNA are not sufficient to handle the button. - * - * uiButSetNFunc will free the argument with MEM_freeN. */ - -typedef struct uiSearchItems uiSearchItems; - -typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2); -typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr); -typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2); -typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); -typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, const char *str, uiSearchItems *items); -typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); - /* use inside searchfunc to add items */ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid); /* bfunc gets search item *poin as arg2, or if NULL the old string */ @@ -688,7 +691,7 @@ uiBlock *uiLayoutGetBlock(uiLayout *layout); void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr); const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing -void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag); +void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag); struct MenuType *uiButGetMenuType(uiBut *but); void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); @@ -748,6 +751,7 @@ void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char * void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer); void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact); +void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4b7adbc1064..a10de9a8a42 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -434,6 +434,15 @@ void uiCenteredBoundsBlock(uiBlock *block, int addval) block->dobounds= UI_BLOCK_BOUNDS_POPUP_CENTER; } +void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy) +{ + block->minx = minx; + block->miny = miny; + block->maxx = maxx; + block->maxy = maxy; + block->dobounds = 0; +} + /* ************** LINK LINE DRAWING ************* */ /* link line drawing is not part of buttons or theme.. so we stick with it here */ @@ -1018,7 +1027,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block) glMatrixMode(GL_MODELVIEW); glPopMatrix(); - if(multisample_enabled) + if(multisample_enabled) glEnable(GL_MULTISAMPLE_ARB); ui_draw_links(block); @@ -1028,25 +1037,25 @@ void uiDrawBlock(const bContext *C, uiBlock *block) static void ui_is_but_sel(uiBut *but, double *value) { - short push=0, true=1; + short is_push=0, is_true=1; - if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) true= 0; + if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true= 0; if( but->bit ) { int lvalue; UI_GET_BUT_VALUE_INIT(but, *value) lvalue= (int)*value; - if( BTST(lvalue, (but->bitnr)) ) push= true; - else push= !true; + if( BTST(lvalue, (but->bitnr)) ) is_push= is_true; + else is_push= !is_true; } else { switch(but->type) { case BUT: - push= 2; + is_push= 2; break; case HOTKEYEVT: case KEYEVT: - push= 2; + is_push= 2; break; case TOGBUT: case TOG: @@ -1056,36 +1065,36 @@ static void ui_is_but_sel(uiBut *but, double *value) case ICONTOG: case OPTION: UI_GET_BUT_VALUE_INIT(but, *value) - if(*value != (double)but->hardmin) push= 1; + if(*value != (double)but->hardmin) is_push= 1; break; case ICONTOGN: case TOGN: case OPTIONN: UI_GET_BUT_VALUE_INIT(but, *value) - if(*value==0.0) push= 1; + if(*value==0.0) is_push= 1; break; case ROW: case LISTROW: UI_GET_BUT_VALUE_INIT(but, *value) /* support for rna enum buts */ if(but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { - if((int)*value & (int)but->hardmax) push= 1; + if((int)*value & (int)but->hardmax) is_push= 1; } else { - if(*value == (double)but->hardmax) push= 1; + if(*value == (double)but->hardmax) is_push= 1; } break; case COL: - push= 2; + is_push= 2; break; default: - push= 2; + is_push= 2; break; } } - if(push==2); - else if(push==1) but->flag |= UI_SELECT; + if(is_push==2); + else if(is_push==1) but->flag |= UI_SELECT; else but->flag &= ~UI_SELECT; } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 1ed05bc54f0..da94fd9237a 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -377,37 +377,6 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad) glDisable( GL_LINE_SMOOTH ); } -/* plain fake antialiased unfilled round rectangle */ -#if 0 /* UNUSED 2.5 */ -static void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float rad, float asp) -{ - float color[4], alpha; - float raddiff; - int i, passes=4; - - /* get the color and divide up the alpha */ - glGetFloatv(GL_CURRENT_COLOR, color); - alpha = 1; //color[3]; - color[3]= 0.5*alpha/(float)passes; - glColor4fv(color); - - /* set the 'jitter amount' */ - raddiff = (1/(float)passes) * asp; - - glEnable( GL_BLEND ); - - /* draw lots of lines on top of each other */ - for (i=passes; i>=(-passes); i--) { - uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad+(i*raddiff)); - } - - glDisable( GL_BLEND ); - - color[3] = alpha; - glColor4fv(color); -} -#endif - /* (old, used in outliner) plain antialiased filled box */ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 688e8f95ac7..cd3243bb9dc 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5063,6 +5063,14 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) if(ui_but_contains_pt(but, mx, my)) butover= but; } + + /* CLIP_EVENTS prevents the event from reaching other blocks */ + if (block->flag & UI_BLOCK_CLIP_EVENTS) { + /* check if mouse is inside block */ + if(block->minx <= mx && block->maxx >= mx && + block->miny <= my && block->maxy >= my) + break; + } } return butover; @@ -5853,14 +5861,14 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut * menu= data->menu; /* copy over return values from the closing menu */ - if(menu->menuretval == UI_RETURN_OK || menu->menuretval == UI_RETURN_UPDATE) { + if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) { if(but->type == COL) copy_v3_v3(data->vec, menu->retvec); else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) data->value= menu->retvalue; } - if(menu->menuretval == UI_RETURN_UPDATE) { + if(menu->menuretval & UI_RETURN_UPDATE) { if(data->interactive) ui_apply_button(C, but->block, but, data, 1); else ui_check_but(but); @@ -5868,13 +5876,13 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut * } /* now change button state or exit, which will close the submenu */ - if(ELEM(menu->menuretval, UI_RETURN_OK, UI_RETURN_CANCEL)) { + if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) { if(menu->menuretval != UI_RETURN_OK) data->cancel= 1; button_activate_exit(C, data, but, 1, 0); } - else if(menu->menuretval == UI_RETURN_OUT) { + else if(menu->menuretval & UI_RETURN_OUT) { if(event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) { button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); } @@ -6089,7 +6097,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* closing sublevels of pulldowns */ case LEFTARROWKEY: if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) - if(BLI_countlist(&block->saferct) > 0) + if(block->saferct.first) menu->menuretval= UI_RETURN_OUT; retval= WM_UI_HANDLER_BREAK; @@ -6322,7 +6330,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* enter will always close this block, we let the event * get handled by the button if it is activated, otherwise we cancel */ if(!ui_but_find_activated(ar)) - menu->menuretval= UI_RETURN_CANCEL; + menu->menuretval= UI_RETURN_CANCEL | UI_RETURN_POPUP_OK; } else { ui_mouse_motion_towards_check(block, menu, mx, my); @@ -6362,7 +6370,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle * buttons inside this region. disabled inside check .. not sure * anymore why it was there? but it meant enter didn't work * for example when mouse was not over submenu */ - if((/*inside &&*/ (!menu->menuretval || menu->menuretval == UI_RETURN_UPDATE) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { + if((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { but= ui_but_find_activated(ar); if(but) { @@ -6411,14 +6419,14 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo if(submenu->menuretval) { /* first decide if we want to close our own menu cascading, if * so pass on the sub menu return value to our own menu handle */ - if(ELEM(submenu->menuretval, UI_RETURN_OK, UI_RETURN_CANCEL)) { + if((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) { if(!(block->flag & UI_BLOCK_KEEP_OPEN)) { menu->menuretval= submenu->menuretval; menu->butretval= data->retval; } } - update= (submenu->menuretval == UI_RETURN_UPDATE); + update= (submenu->menuretval & UI_RETURN_UPDATE); /* now let activated button in this menu exit, which * will actually close the submenu too */ @@ -6591,7 +6599,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) ui_popup_block_free(C, menu); UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu); - if(temp.menuretval == UI_RETURN_OK) { + if((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) { if(temp.popup_func) temp.popup_func(C, temp.popup_arg, temp.retvalue); if(temp.optype) diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 1b7308d328e..a7d8c688f43 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -509,7 +509,7 @@ static void init_internal_icons(void) bTheme *btheme= UI_GetTheme(); ImBuf *bbuf= NULL; int x, y, icontype; - char iconfilestr[FILE_MAXDIR+FILE_MAXFILE]; + char iconfilestr[FILE_MAX]; if ((btheme!=NULL) && btheme->tui.iconfile[0]) { char *icondir= BLI_get_folder(BLENDER_DATAFILES, "icons"); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c553c1e35ad..84f0c61cd0c 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2743,7 +2743,7 @@ const char *uiLayoutIntrospect(uiLayout *layout) } /* this function does not initialize the layout, functions can be called on the layout before and after */ -void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag) +void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag) { if(!op->properties) { IDPropertyTemplate val = {0}; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 47dde3f03f0..58c3c0130b8 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -385,7 +385,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) for(i=0; i<totitem; i++) { if(item[i].identifier[0] && item[i].value == value) { - if(item[i].description[0]) { + if(item[i].description && item[i].description[0]) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "%s: %s", item[i].name, item[i].description); data->color[data->totline]= 0xDDDDDD; data->totline++; @@ -2603,7 +2603,7 @@ void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg) uiPupBlockO(C, func, arg, NULL, 0); } -void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_func, void *arg) +void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg) { wmWindow *window= CTX_wm_window(C); uiPopupBlockHandle *handle; @@ -2613,7 +2613,7 @@ void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_ handle->retvalue= 1; handle->popup_arg= arg; - // handle->popup_func= operator_cb; + handle->popup_func= popup_func; handle->cancel_func= cancel_func; // handle->opcontext= opcontext; diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 3caafe308d0..0e9dbaf3022 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -124,6 +124,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id style->buttonspacex= 8; style->buttonspacey= 2; style->panelspace= 8; + style->panelouter= 4; return style; } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 23d5e77b78d..8335668a624 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -130,7 +130,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind return but; } -int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(PropertyRNA *), const char label_align) +int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(PointerRNA *, PropertyRNA *), const char label_align) { uiLayout *split, *col; int flag; @@ -141,7 +141,7 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(Proper RNA_STRUCT_BEGIN(ptr, prop) { flag= RNA_property_flag(prop); - if(flag & PROP_HIDDEN || (check_prop && check_prop(prop)==FALSE)) + if(flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop)==FALSE)) continue; if(label_align != '\0') { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index fb2c7c154fc..4bae6afc2ef 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4390,7 +4390,7 @@ useless: } look = look->next; } - } /* end uv layer loop */ + } /* end uv map loop */ } /* end uvlay_tot */ diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 9bbfea1291f..42728eb7ea1 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -69,6 +69,7 @@ #include "ED_space_api.h" #include "ED_view3d.h" #include "ED_mesh.h" +#include "ED_numinput.h" #include "RNA_access.h" #include "RNA_define.h" @@ -95,6 +96,7 @@ typedef struct tringselOpData { Object *ob; EditMesh *em; EditEdge *eed; + NumInput num; int extend; int do_cut; @@ -345,6 +347,11 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut) lcd->em= BKE_mesh_get_editmesh((Mesh *)lcd->ob->data); lcd->extend = do_cut ? 0 : RNA_boolean_get(op->ptr, "extend"); lcd->do_cut = do_cut; + + initNumInput(&lcd->num); + lcd->num.idx_max = 0; + lcd->num.flag |= NUM_NO_NEGATIVE | NUM_NO_FRACTION; + em_setup_viewcontext(C, &lcd->vc); ED_region_tag_redraw(lcd->ar); @@ -464,6 +471,7 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(lcd->ar); break; case WHEELUPMOUSE: /* change number of cuts */ + case PADPLUSKEY: case PAGEUPKEY: if (event->val == KM_PRESS) { cuts++; @@ -474,6 +482,7 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event) } break; case WHEELDOWNMOUSE: /* change number of cuts */ + case PADMINUS: case PAGEDOWNKEY: if (event->val == KM_PRESS) { cuts=MAX2(cuts-1,1); @@ -501,6 +510,23 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event) } } + /* using the keyboard to input the number of cuts */ + if (event->val==KM_PRESS) { + float value; + + if (handleNumInput(&lcd->num, event)) + { + applyNumInput(&lcd->num, &value); + + cuts= CLAMPIS(value, 1, 32); + + RNA_int_set(op->ptr,"number_cuts",cuts); + ringsel_find_edge(lcd, cuts); + + ED_region_tag_redraw(lcd->ar); + } + } + /* keep going until the user confirms */ return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 46076d0bec4..aa94b48c1e9 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -337,8 +337,8 @@ static int uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) void MESH_OT_uv_texture_add(wmOperatorType *ot) { /* identifiers */ - ot->name= "Add UV Texture"; - ot->description= "Add UV texture layer"; + ot->name= "Add UV Map"; + ot->description= "Add UV Map"; ot->idname= "MESH_OT_uv_texture_add"; /* api callbacks */ @@ -417,8 +417,8 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) void MESH_OT_drop_named_image(wmOperatorType *ot) { /* identifiers */ - ot->name= "Assign Image to UV Texture"; - ot->description= "Assigns Image to active UV layer, or creates a UV layer"; + ot->name= "Assign Image to UV Map"; + ot->description= "Assigns Image to active UV Map, or creates a UV Map"; ot->idname= "MESH_OT_drop_named_image"; /* api callbacks */ @@ -447,8 +447,8 @@ static int uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) void MESH_OT_uv_texture_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Remove UV Texture"; - ot->description= "Remove UV texture layer"; + ot->name= "Remove UV Map"; + ot->description= "Remove UV Map"; ot->idname= "MESH_OT_uv_texture_remove"; /* api callbacks */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index a6d3365ad8a..bcd8b8903e7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1366,6 +1366,7 @@ static int convert_exec(bContext *C, wmOperator *op) makeDispListCurveTypes(scene, newob, 0); newob->type= OB_CURVE; + cu->type= OB_CURVE; if(cu->vfont) { cu->vfont->id.us--; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 63a316e7f7b..5dc1c1b0f03 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -1039,7 +1039,7 @@ static void clear_images(MTFace *mtface, int totface) if((ima->id.flag&LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); ima->id.flag|= LIB_DOIT; } } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 3c84b2df1d2..40d52e0b261 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -691,6 +691,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; + bConstraint *lastcon = NULL; bPoseChannel *pchan= NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ @@ -703,27 +704,45 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) /* nullify inverse matrix first */ unit_m4(data->invmat); - /* try to find a pose channel */ + /* try to find a pose channel - assume that this is the constraint owner */ // TODO: get from context instead? if (ob && ob->pose) pchan= get_active_posechannel(ob); - /* calculate/set inverse matrix */ + /* calculate/set inverse matrix: + * We just calculate all transform-stack eval up to but not including this constraint. + * This is because inverse should just inverse correct for just the constraint's influence + * when it gets applied; that is, at the time of application, we don't know anything about + * what follows. + */ if (pchan) { - float pmat[4][4], cinf; float imat[4][4], tmat[4][4]; + float pmat[4][4]; - /* make copy of pchan's original pose-mat (for use later) */ + /* 1. calculate posemat where inverse doesn't exist yet (inverse was cleared above), + * to use as baseline ("pmat") to derive delta from. This extra calc saves users + * from having pressing "Clear Inverse" first + */ + where_is_pose(scene, ob); copy_m4_m4(pmat, pchan->pose_mat); - /* disable constraint for pose to be solved without it */ - cinf= con->enforce; - con->enforce= 0.0f; + /* 2. knock out constraints starting from this one */ + lastcon = pchan->constraints.last; + pchan->constraints.last = con->prev; + + if (con->prev) { + /* new end must not point to this one, else this chain cutting is useless */ + con->prev->next = NULL; + } + else { + /* constraint was first */ + pchan->constraints.first = NULL; + } - /* solve pose without constraint */ + /* 3. solve pose without disabled constraints */ where_is_pose(scene, ob); - /* determine effect of constraint by removing the newly calculated + /* 4. determine effect of constraint by removing the newly calculated * pchan->pose_mat from the original pchan->pose_mat, thus determining * the effect of the constraint */ @@ -731,8 +750,19 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) mul_m4_m4m4(tmat, imat, pmat); invert_m4_m4(data->invmat, tmat); - /* recalculate pose with new inv-mat */ - con->enforce= cinf; + /* 5. restore constraints */ + pchan->constraints.last = lastcon; + + if (con->prev) { + /* hook up prev to this one again */ + con->prev->next = con; + } + else { + /* set as first again */ + pchan->constraints.first = con; + } + + /* 6. recalculate pose with new inv-mat applied */ where_is_pose(scene, ob); } else if (ob) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c39477cbf6c..722e7057ece 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2056,10 +2056,8 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) if(prop) { CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { - if (ob != ob_iter) { - if (ob->data != ob_iter->data) - set_ob_property(ob_iter, prop); - } + if (ob != ob_iter) + set_ob_property(ob_iter, prop); } CTX_DATA_END; } } @@ -2067,17 +2065,13 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) else { CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { if (ob != ob_iter) { - if (ob->data != ob_iter->data){ - if (type == COPY_PROPERTIES_REPLACE) - copy_properties( &ob_iter->prop, &ob->prop ); - - /* merge - the default when calling with no argument */ - else { - for(prop = ob->prop.first; prop; prop= prop->next ) { - set_ob_property(ob_iter, prop); - } - } - } + if (type == COPY_PROPERTIES_REPLACE) + copy_properties(&ob_iter->prop, &ob->prop); + + /* merge - the default when calling with no argument */ + else + for(prop = ob->prop.first; prop; prop= prop->next) + set_ob_property(ob_iter, prop); } } CTX_DATA_END; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7b747769e49..86477eb9dbd 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -157,10 +157,9 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return new_md; } -int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) +static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgraph) { ModifierData *obmd; - int sort_depsgraph = 0; /* It seems on rapid delete it is possible to * get called twice on same modifier, so make @@ -168,11 +167,9 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob for(obmd=ob->modifiers.first; obmd; obmd=obmd->next) if(obmd==md) break; - - if(!obmd) { - BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); + + if(!obmd) return 0; - } /* special cases */ if(md->type == eModifierType_ParticleSystem) { @@ -193,13 +190,13 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob if(ob->pd) ob->pd->deflect= 0; - sort_depsgraph = 1; + *sort_depsgraph = 1; } else if(md->type == eModifierType_Surface) { if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) ob->pd->shape = PFIELD_SHAPE_PLANE; - sort_depsgraph = 1; + *sort_depsgraph = 1; } else if(md->type == eModifierType_Smoke) { ob->dt = OB_TEXTURE; @@ -238,6 +235,21 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob BLI_remlink(&ob->modifiers, md); modifier_free(md); + return 1; +} + +int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) +{ + int sort_depsgraph = 0; + int ok; + + ok= object_modifier_remove(ob, md, &sort_depsgraph); + + if(!ok) { + BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); + return 0; + } + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sorting has to be done after the update so that dynamic systems can react properly */ @@ -247,6 +259,31 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob return 1; } +void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) +{ + ModifierData *md =ob->modifiers.first; + int sort_depsgraph = 0; + + if(!md) + return; + + while(md) { + ModifierData *next_md; + + next_md= md->next; + + object_modifier_remove(ob, md, &sort_depsgraph); + + md= next_md; + } + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + + /* sorting has to be done after the update so that dynamic systems can react properly */ + if(sort_depsgraph) + DAG_scene_sort(bmain, scene); +} + int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md) { if(md->prev) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 94e2f0aae00..3a4cd6135cf 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -61,6 +61,7 @@ #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" +#include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_fcurve.h" @@ -128,7 +129,11 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) load_editMesh(scene, obedit); make_editMesh(scene, obedit); - em = BKE_mesh_get_editmesh(me); + em= BKE_mesh_get_editmesh(me); + + /* derivedMesh might be needed for solving parenting, + so re-create it here */ + makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH); eve= em->verts.first; while(eve) { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 936da90e8b7..d6300dc1fe3 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -138,6 +138,23 @@ void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) vgroup_delete_object_mode(ob, dg); } +void ED_vgroup_clear(Object *ob) +{ + bDeformGroup *dg= (bDeformGroup *)ob->defbase.first; + int edit_mode= ED_vgroup_object_is_edit_mode(ob); + + while (dg) { + bDeformGroup *next_dg= dg->next; + + if(edit_mode) + vgroup_delete_edit_mode(ob, dg); + else + vgroup_delete_object_mode(ob, dg); + + dg= next_dg; + } +} + int ED_vgroup_data_create(ID *id) { /* create deform verts */ diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 9dd4503414a..cc60f4a52fd 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -637,7 +637,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF FluidsimSettings *domainSettings= fluidmd->fss; FILE *fileCfg; int dirExist = 0; - char newSurfdataPath[FILE_MAXDIR+FILE_MAXFILE]; // modified output settings + char newSurfdataPath[FILE_MAX]; // modified output settings const char *suffixConfig = FLUID_SUFFIX_CONFIG; int outStringsChanged = 0; @@ -667,15 +667,15 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF } if(targetDir[0] == '\0' || (!dirExist)) { - char blendDir[FILE_MAXDIR+FILE_MAXFILE]; - char blendFile[FILE_MAXDIR+FILE_MAXFILE]; + char blendDir[FILE_MAX]; + char blendFile[FILE_MAX]; // invalid dir, reset to current/previous - BLI_strncpy(blendDir, G.main->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(blendDir, G.main->name, FILE_MAX); BLI_splitdirstring(blendDir, blendFile); - BLI_replace_extension(blendFile, FILE_MAXDIR+FILE_MAXFILE, ""); /* strip .blend */ + BLI_replace_extension(blendFile, FILE_MAX, ""); /* strip .blend */ - BLI_snprintf(newSurfdataPath, FILE_MAXDIR+FILE_MAXFILE ,"//fluidsimdata/%s_%s_", blendFile, fsDomain->id.name); + BLI_snprintf(newSurfdataPath, FILE_MAX ,"//fluidsimdata/%s_%s_", blendFile, fsDomain->id.name); BLI_snprintf(debugStrBuffer, 256, "fluidsimBake::error - warning resetting output dir to '%s'\n", newSurfdataPath); elbeemDebugOut(debugStrBuffer); @@ -685,7 +685,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check if modified output dir is ok #if 0 if(outStringsChanged) { - char dispmsg[FILE_MAXDIR+FILE_MAXFILE+256]; + char dispmsg[FILE_MAX+256]; int selection=0; BLI_strncpy(dispmsg,"Output settings set to: '", sizeof(dispmsg)); strcat(dispmsg, newSurfdataPath); @@ -810,9 +810,9 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, /* copied from rna_fluidsim.c: fluidsim_find_lastframe() */ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *relbase) { - char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; - char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR]; - char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR]; + char targetDir[FILE_MAX], targetFile[FILE_MAX]; + char targetDirVel[FILE_MAX], targetFileVel[FILE_MAX]; + char previewDir[FILE_MAX], previewFile[FILE_MAX]; int curFrame = 1, exists = 0; BLI_join_dirfile(targetDir, sizeof(targetDir), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); @@ -859,8 +859,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor const char *suffixConfig = FLUID_SUFFIX_CONFIG; const char *suffixSurface = FLUID_SUFFIX_SURFACE; - char targetDir[FILE_MAXDIR+FILE_MAXFILE]; // store & modify output settings - char targetFile[FILE_MAXDIR+FILE_MAXFILE]; // temp. store filename from targetDir for access + char targetDir[FILE_MAX]; // store & modify output settings + char targetFile[FILE_MAX]; // temp. store filename from targetDir for access int outStringsChanged = 0; // modified? copy back before baking float domainMat[4][4]; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index f826d0ec41a..0cecfa05b49 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -321,7 +321,9 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) for(pid=pidlist.first; pid; pid=pid->next) { if(pid->cache == cache) { - *(pid->cache_ptr) = BKE_ptcache_add(pid->ptcaches); + PointCache *cache = BKE_ptcache_add(pid->ptcaches); + cache->step = pid->default_step; + *(pid->cache_ptr) = cache; break; } } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 6931b0b86db..dbd1e27024e 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -235,7 +235,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) /* custom scene and single layer re-render */ screen_render_scene_layer_set(op, mainp, &scene, &srl); - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return OPERATOR_CANCELLED; } @@ -516,7 +516,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 188a61181ce..3a2d9f137d7 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -220,12 +220,12 @@ static void screen_opengl_render_apply(OGLRender *oglrender) char name[FILE_MAX]; int ok; - if(scene->r.planes == 8) { + if(scene->r.im_format.planes == R_IMF_CHAN_DEPTH_8) { IMB_color_to_bw(ibuf); } - BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE); - ok= BKE_write_ibuf(ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); /* no need to stamp here */ + BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); + ok= BKE_write_ibuf(ibuf, name, &scene->r.im_format); /* no need to stamp here */ if(ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } @@ -263,7 +263,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) return 0; } - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { + if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return 0; } @@ -332,7 +332,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) Scene *scene= oglrender->scene; if(oglrender->mh) { - if(BKE_imtype_is_movie(scene->r.imtype)) + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) oglrender->mh->end_movie(); } @@ -371,8 +371,8 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) scene= oglrender->scene; oglrender->reports= op->reports; - oglrender->mh= BKE_get_movie_handle(scene->r.imtype); - if(BKE_imtype_is_movie(scene->r.imtype)) { + oglrender->mh= BKE_get_movie_handle(scene->r.im_format.imtype); + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { screen_opengl_render_end(C, oglrender); return 0; @@ -392,7 +392,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) Scene *scene= oglrender->scene; ImBuf *ibuf; void *lock; - char name[FILE_MAXDIR+FILE_MAXFILE]; + char name[FILE_MAX]; int ok= 0; const short view_context= (oglrender->v3d != NULL); Object *camera= NULL; @@ -440,7 +440,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if(ibuf) { /* color -> greyscale */ /* editing directly would alter the render view */ - if(scene->r.planes == 8) { + if(scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); // IMB_freeImBuf(ibuf); /* owned by the image */ @@ -449,14 +449,14 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) else { /* this is lightweight & doesnt re-alloc the buffers, only do this * to save the correct bit depth since the image is always RGBA */ - ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.planes, 0); + ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.im_format.planes, 0); ibuf_cpy->rect= ibuf->rect; ibuf_cpy->rect_float= ibuf->rect_float; ibuf_cpy->zbuf_float= ibuf->zbuf_float; ibuf= ibuf_cpy; } - if(BKE_imtype_is_movie(scene->r.imtype)) { + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { ok= oglrender->mh->append_movie(&scene->r, CFRA, (int*)ibuf->rect, oglrender->sizex, oglrender->sizey, oglrender->reports); if(ok) { printf("Append frame %d", scene->r.cfra); @@ -464,8 +464,8 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); - ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); + ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); if(ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index b516954cd4c..96018de130b 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -1222,7 +1222,7 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot) /********************** environment map operators *********************/ -static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, int imtype) +static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype) { float layout[12]; if ( RNA_struct_find_property(op->ptr, "layout") ) @@ -1244,7 +1244,7 @@ static int envmap_save_exec(bContext *C, wmOperator *op) Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; Scene *scene = CTX_data_scene(C); //int imtype = RNA_enum_get(op->ptr, "file_type"); - int imtype = scene->r.imtype; + char imtype = scene->r.im_format.imtype; char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); @@ -1271,7 +1271,7 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event if(RNA_property_is_set(op->ptr, "filepath")) return envmap_save_exec(C, op); - //RNA_enum_set(op->ptr, "file_type", scene->r.imtype); + //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype); RNA_string_set(op->ptr, "filepath", G.main->name); WM_event_add_fileselect(C, op); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 72ea79fae7e..f353a090305 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -188,6 +188,10 @@ static int nodes_use_tex(bNodeTree *ntree, Tex *tex) if(node->id == (ID*)tex) { return 1; } + else if(GS(node->id->name) == ID_MA) { + if(mtex_use_tex(((Material*)node->id)->mtex, MAX_MTEX, tex)) + return 1; + } else if(node->type==NODE_GROUP) { if(nodes_use_tex((bNodeTree *)node->id, tex)) return 1; @@ -198,14 +202,46 @@ static int nodes_use_tex(bNodeTree *ntree, Tex *tex) return 0; } -static void material_changed(Main *UNUSED(bmain), Material *ma) +static int nodes_use_material(bNodeTree *ntree, Material *ma) +{ + bNode *node; + + for(node=ntree->nodes.first; node; node= node->next) { + if(node->id) { + if(node->id == (ID*)ma) { + return 1; + } + else if(node->type==NODE_GROUP) { + if(nodes_use_material((bNodeTree *)node->id, ma)) + return 1; + } + } + } + + return 0; +} + +static void material_changed(Main *bmain, Material *ma) { + Material *parent; + /* icons */ BKE_icon_changed(BKE_icon_getid(&ma->id)); /* glsl */ if(ma->gpumaterial.first) GPU_material_free(ma); + + /* find node materials using this */ + for(parent=bmain->mat.first; parent; parent=parent->id.next) { + if(parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)); + else continue; + + BKE_icon_changed(BKE_icon_getid(&parent->id)); + + if(parent->gpumaterial.first) + GPU_material_free(parent); + } } static void texture_changed(Main *bmain, Tex *tex) diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 8a90aadbee2..7d0ec866456 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -160,13 +160,13 @@ static int screenshot_exec(bContext *C, wmOperator *op) /* BKE_add_image_extension() checks for if extension was already set */ if(scene->r.scemode & R_EXTENSION) - if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5) - BKE_add_image_extension(path, scene->r.imtype); + if(strlen(path)<FILE_MAX-5) + BKE_add_image_extension(path, scene->r.im_format.imtype); ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); ibuf->rect= scd->dumprect; - BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); + BKE_write_ibuf(ibuf, path, &scene->r.im_format); IMB_freeImBuf(ibuf); } @@ -261,14 +261,14 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float { ScreenshotJob *sj= sjv; RenderData rd= sj->scene->r; - bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.imtype); + bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype); int cfra= 1; /* we need this as local variables for renderdata */ rd.frs_sec= U.scrcastfps; rd.frs_sec_base= 1.0f; - if(BKE_imtype_is_movie(rd.imtype)) { + if(BKE_imtype_is_movie(rd.im_format.imtype)) { if(!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) { printf("screencast job stopped\n"); return; @@ -294,14 +294,14 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float break; } else { - ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.planes, 0); - char name[FILE_MAXDIR+FILE_MAXFILE]; + ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); + char name[FILE_MAX]; int ok; - BKE_makepicstring(name, rd.pic, sj->bmain->name, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE); + BKE_makepicstring(name, rd.pic, sj->bmain->name, cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE); ibuf->rect= sj->dumprect; - ok= BKE_write_ibuf(ibuf, name, rd.imtype, rd.subimtype, rd.quality); + ok= BKE_write_ibuf(ibuf, name, &rd.im_format); if(ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 9b256acbca9..d557a3bd144 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -263,7 +263,7 @@ typedef struct ProjPaintState { MVert *dm_mvert; MFace *dm_mface; MTFace *dm_mtface; - MTFace *dm_mtface_clone; /* other UV layer, use for cloning between layers */ + MTFace *dm_mtface_clone; /* other UV map, use for cloning between layers */ MTFace *dm_mtface_stencil; /* projection painting only */ @@ -300,6 +300,7 @@ typedef struct ProjPaintState { short do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/ short do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */ short do_mask_normal; /* mask out pixels based on their normals */ + short do_new_shading_nodes; /* cache scene_use_new_shading_nodes value */ float normal_angle; /* what angle to mask at*/ float normal_angle_inner; float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */ @@ -518,17 +519,16 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) return ima; } -static Image *project_paint_face_image(const ProjPaintState *ps, int face_index) +static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtface, int face_index) { Image *ima; - if(scene_use_new_shading_nodes(ps->scene)) { + if(ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface+face_index; ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL); } else { - MTFace *tf = ps->dm_mtface+face_index; - ima = tf->tpage; + ima = dm_mtface[face_index].tpage; } return ima; @@ -725,7 +725,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[2], tf->uv[3], w); } - ima = project_paint_face_image(ps, face_index); + ima = project_paint_face_image(ps, ps->dm_mtface, face_index); ibuf = ima->ibufs.first; /* we must have got the imbuf before getting here */ if (!ibuf) return 0; @@ -1091,8 +1091,8 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o /* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */ if (i2_fidx != -1) { - Image *tpage = project_paint_face_image(ps, face_index); - Image *orig_tpage = project_paint_face_image(ps, orig_face); + Image *tpage = project_paint_face_image(ps, ps->dm_mtface, face_index); + Image *orig_tpage = project_paint_face_image(ps, ps->dm_mtface, orig_face); /* This IS an adjacent face!, now lets check if the UVs are ok */ tf = ps->dm_mtface + face_index; @@ -1347,9 +1347,9 @@ static float project_paint_uvpixel_mask( /* Image Mask */ if (ps->do_layer_stencil) { - /* another UV layers image is masking this one's */ + /* another UV maps image is masking this one's */ ImBuf *ibuf_other; - Image *other_tpage = project_paint_face_image(ps, face_index); + Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_stencil, face_index); const MTFace *tf_other = ps->dm_mtface_stencil + face_index; if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) { @@ -1506,7 +1506,7 @@ static ProjPixel *project_paint_uvpixel_init( if (ps->tool==PAINT_TOOL_CLONE) { if (ps->dm_mtface_clone) { ImBuf *ibuf_other; - Image *other_tpage = project_paint_face_image(ps, face_index); + Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_clone, face_index); const MTFace *tf_other = ps->dm_mtface_clone + face_index; if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) { @@ -2746,7 +2746,7 @@ static void project_bucket_init(const ProjPaintState *ps, const int thread_index face_index = GET_INT_FROM_POINTER(node->link); /* Image context switching */ - tpage = project_paint_face_image(ps, face_index); + tpage = project_paint_face_image(ps, ps->dm_mtface, face_index); if (tpage_last != tpage) { tpage_last = tpage; @@ -3249,7 +3249,7 @@ static void project_paint_begin(ProjPaintState *ps) } #endif - tpage = project_paint_face_image(ps, face_index); + tpage = project_paint_face_image(ps, ps->dm_mtface, face_index); if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) { @@ -4333,7 +4333,7 @@ static ImBuf *imapaint_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) /* note: allocImbuf returns zero'd memory, so regions outside image will have zero alpha, and hence not be blended onto the image */ int w=ibufb->x, h=ibufb->y, destx=0, desty=0, srcx=pos[0], srcy=pos[1]; - ImBuf *clonebuf= IMB_allocImBuf(w, h, ibufb->depth, ibufb->flags); + ImBuf *clonebuf= IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags); IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &w, &h); IMB_rectblend(clonebuf, ibuf, destx, desty, srcx, srcy, w, h, @@ -4714,6 +4714,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1; ps->do_occlude = (settings->imapaint.flag & IMAGEPAINT_PROJECT_XRAY) ? 0 : 1; ps->do_mask_normal = (settings->imapaint.flag & IMAGEPAINT_PROJECT_FLAT) ? 0 : 1; + ps->do_new_shading_nodes = scene_use_new_shading_nodes(scene); /* only cache the value */ if (ps->tool == PAINT_TOOL_CLONE) ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 623cfc48827..dd7ea81d520 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -265,7 +265,7 @@ static int sound_mixdown_invoke(bContext *C, wmOperator *op, wmEvent *event) return WM_operator_filesel(C, op, event); } -static int sound_mixdown_draw_check_prop(PropertyRNA *prop) +static int sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { const char *prop_id= RNA_property_identifier(prop); return !( strcmp(prop_id, "filepath") == 0 || diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 4446a2e848a..c0ccaeaea90 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -257,8 +257,8 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) if(!scene_use_new_shading_nodes(scene)) { if(ct) { - MEM_freeN(ct); BLI_freelistN(&ct->users); + MEM_freeN(ct); sbuts->texuser= NULL; } diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 43eb45b17a7..ddfd403806c 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -90,12 +90,14 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c prop= RNA_struct_find_property(ptr, propname); if(!prop) { - printf("uiTemplateMovieClip: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: property not found: %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } if(RNA_property_type(prop) != PROP_POINTER) { - printf("uiTemplateMovieClip: expected pointer property for %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: expected pointer property for %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } @@ -136,12 +138,14 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) prop= RNA_struct_find_property(ptr, propname); if(!prop) { - printf("uiTemplateTrack: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: property not found: %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } if(RNA_property_type(prop) != PROP_POINTER) { - printf("uiTemplateTrack: expected pointer property for %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: expected pointer property for %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } @@ -327,12 +331,14 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P prop= RNA_struct_find_property(ptr, propname); if(!prop) { - printf("uiTemplateMarker: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: property not found: %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } if(RNA_property_type(prop) != PROP_POINTER) { - printf("uiTemplateMarker: expected pointer property for %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: expected pointer property for %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 43df8b0ea47..e5a5109d796 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -2251,7 +2251,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) MovieTrackingTrack *track= clip->tracking.tracks.first; int placement= RNA_enum_get(op->ptr, "placement"); int margin= RNA_int_get(op->ptr, "margin"); - int min_trackness= RNA_int_get(op->ptr, "min_trackness"); + int min_trackability= RNA_int_get(op->ptr, "min_trackability"); int min_distance= RNA_int_get(op->ptr, "min_distance"); int place_outside_layer= 0; bGPDlayer *layer= NULL; @@ -2270,7 +2270,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) track= track->next; } - BKE_tracking_detect_fast(&clip->tracking, ibuf, sc->user.framenr, margin, min_trackness, min_distance, layer, place_outside_layer); + BKE_tracking_detect_fast(&clip->tracking, ibuf, sc->user.framenr, margin, min_trackability, min_distance, layer, place_outside_layer); IMB_freeImBuf(ibuf); @@ -2303,7 +2303,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot) /* properties */ RNA_def_enum(ot->srna, "placement", placement_items, 0, "Placement", "Placement for detected features"); RNA_def_int(ot->srna, "margin", 16, 0, INT_MAX, "Margin", "Only corners further than margin pixels from the image edges are considered", 0, 300); - RNA_def_int(ot->srna, "min_trackness", 16, 0, INT_MAX, "Trackness", "Minimum score to add a corner", 0, 300); + RNA_def_int(ot->srna, "min_trackability", 16, 0, INT_MAX, "Trackability", "Minimum trackability score to add a corner", 0, 300); RNA_def_int(ot->srna, "min_distance", 120, 0, INT_MAX, "Distance", "Minimal distance accepted between two corners", 0, 300); } diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 4867552cc52..c713317aa7e 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -192,7 +192,7 @@ static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void path_drop_copy(wmDrag *drag, wmDropBox *drop) { - char pathname[FILE_MAXDIR+FILE_MAXFILE+2]; + char pathname[FILE_MAX+2]; BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); RNA_string_set(drop->ptr, "text", pathname); } diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 7bcaf722827..26083cbe625 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -177,7 +177,7 @@ static void file_panel_operator_header(const bContext *C, Panel *pa) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); } -static int file_panel_check_prop(PropertyRNA *prop) +static int file_panel_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { const char *prop_id= RNA_property_identifier(prop); return !( strcmp(prop_id, "filepath") == 0 || diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 80537a4526e..4682ea3fb60 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -852,7 +852,7 @@ static void filelist_read_library(struct FileList* filelist) file = filelist->filelist; for(num=0; num<filelist->numfiles; num++, file++) { if(BLO_has_bfile_extension(file->relname)) { - char name[FILE_MAXDIR+FILE_MAXFILE]; + char name[FILE_MAX]; BLI_strncpy(name, filelist->dir, sizeof(name)); strcat(name, file->relname); @@ -988,7 +988,7 @@ void filelist_from_library(struct FileList* filelist) LinkNode *l, *names, *previews; struct ImBuf* ima; int ok, i, nprevs, nnames, idcode; - char filename[FILE_MAXDIR+FILE_MAXFILE]; + char filename[FILE_MAX]; char dir[FILE_MAX], group[GROUP_MAX]; /* name test */ @@ -1180,7 +1180,7 @@ void filelist_from_main(struct FileList *filelist) if(id->lib==NULL) files->relname= BLI_strdup(id->name+2); else { - files->relname= MEM_mallocN(FILE_MAXDIR+FILE_MAXFILE+32, "filename for lib"); + files->relname= MEM_mallocN(FILE_MAX+32, "filename for lib"); sprintf(files->relname, "%s | %s", id->lib->name, id->name+2); } files->type |= S_IFREG; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 6b3477d1fe5..9a952d22274 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -326,13 +326,13 @@ void fsmenu_read_system(struct FSMenu* fsmenu) for (i=1; err!=nsvErr; i++) { FSRef dir; - unsigned char path[FILE_MAXDIR+FILE_MAXFILE]; + unsigned char path[FILE_MAX]; err = FSGetVolumeInfo(kFSInvalidVolumeRefNum, i, NULL, kFSVolInfoNone, NULL, NULL, &dir); if (err != noErr) continue; - FSRefMakePath(&dir, path, FILE_MAXDIR+FILE_MAXFILE); + FSRefMakePath(&dir, path, FILE_MAX); if (strcmp((char*)path, "/home") && strcmp((char*)path, "/net")) { /* /net and /home are meaningless on OSX, home folders are stored in /Users */ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0); @@ -414,7 +414,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) FSRef dir; FSVolumeRefNum volRefNum; struct GetVolParmsInfoBuffer volParmsBuffer; - unsigned char path[FILE_MAXDIR+FILE_MAXFILE]; + unsigned char path[FILE_MAX]; err = FSGetVolumeInfo(kFSInvalidVolumeRefNum, i, &volRefNum, kFSVolInfoNone, NULL, NULL, &dir); if (err != noErr) @@ -425,7 +425,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) continue; - FSRefMakePath(&dir, path, FILE_MAXDIR+FILE_MAXFILE); + FSRefMakePath(&dir, path, FILE_MAX); fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0); } diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 51a24044deb..c1dfa97a508 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -136,7 +136,7 @@ static void graph_panel_view(const bContext *C, Panel *pa) SpaceIpo *sipo= CTX_wm_space_graph(C); Scene *scene= CTX_data_scene(C); PointerRNA spaceptr, sceneptr; - uiLayout *col, *subcol, *row; + uiLayout *col, *sub, *row; /* get RNA pointers for use when creating the UI elements */ RNA_id_pointer_create(&scene->id, &sceneptr); @@ -146,16 +146,16 @@ static void graph_panel_view(const bContext *C, Panel *pa) col= uiLayoutColumn(pa->layout, 0); uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - subcol= uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor")); - uiItemO(subcol, "Cursor from Selection", ICON_NONE, "GRAPH_OT_frame_jump"); + sub= uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); + uiItemO(sub, "Cursor from Selection", ICON_NONE, "GRAPH_OT_frame_jump"); - subcol= uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor")); - row= uiLayoutSplit(subcol, 0.7, 1); + sub= uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); + row= uiLayoutSplit(sub, 0.7, 1); uiItemR(row, &sceneptr, "frame_current", 0, "Cursor X", ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", "To Keys", 0, "type", GRAPHKEYS_SNAP_CFRA); - row= uiLayoutSplit(subcol, 0.7, 1); + row= uiLayoutSplit(sub, 0.7, 1); uiItemR(row, &spaceptr, "cursor_position_y", 0, "Cursor Y", ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", "To Keys", 0, "type", GRAPHKEYS_SNAP_VALUE); } @@ -168,7 +168,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) FCurve *fcu; PointerRNA fcu_ptr; uiLayout *layout = pa->layout; - uiLayout *col, *row, *subrow; + uiLayout *col, *row, *sub; uiBlock *block; char name[256]; int icon = 0; @@ -201,9 +201,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa) row= uiLayoutRow(col, 1); uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - subrow= uiLayoutRow(row, 1); - uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM)); - uiItemR(subrow, &fcu_ptr, "color", 0, "", ICON_NONE); + sub= uiLayoutRow(row, 1); + uiLayoutSetEnabled(sub, (fcu->color_mode==FCURVE_COLOR_CUSTOM)); + uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); MEM_freeN(ale); } @@ -562,7 +562,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar DriverTarget *dtar= &dvar->targets[0]; Object *ob = (Object *)dtar->id; PointerRNA dtar_ptr; - uiLayout *col, *subcol; + uiLayout *col, *sub; /* initialise RNA pointer to the target */ RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); @@ -578,9 +578,9 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - subcol= uiLayoutColumn(layout, 1); - uiItemR(subcol, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); - uiItemR(subcol, &dtar_ptr, "transform_space", 0, "Space", ICON_NONE); + sub= uiLayoutColumn(layout, 1); + uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); + uiItemR(sub, &dtar_ptr, "transform_space", 0, "Space", ICON_NONE); } /* driver settings for active F-Curve (only for 'Drivers' mode) */ diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 5445f2e8c44..6c68ba0ea71 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -122,13 +122,13 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, if(ibuf->channels!=4) { ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels); } - else if(ibuf->depth==32) + else if(ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA float"); else ofs+= sprintf(str+ofs, " RGB float"); } else { - if(ibuf->depth==32) + if(ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA byte"); else ofs+= sprintf(str+ofs, " RGB byte"); @@ -488,38 +488,6 @@ static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v) } #if 0 -static void image_pack_cb(bContext *C, void *ima_v, void *iuser_v) -{ - if(ima_v) { - Image *ima= ima_v; - if(ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE) { - if (ima->packedfile) { - if (G.fileflags & G_AUTOPACK) { - if (okee("Disable AutoPack ?")) { - G.fileflags &= ~G_AUTOPACK; - } - } - - if ((G.fileflags & G_AUTOPACK) == 0) { - unpackImage(NULL, ima, PF_ASK); /* XXX report errors */ - ED_undo_push(C, "Unpack image"); - } - } - else { - ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser_v); - if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) { - // XXX error("Can't pack painted image. Save image or use Repack as PNG"); - } else { - ima->packedfile = newPackedFile(NULL, ima->name); /* XXX report errors */ - ED_undo_push(C, "Pack image"); - } - } - } - } -} -#endif - -#if 0 static void image_freecache_cb(bContext *C, void *ima_v, void *unused) { Scene *scene= CTX_data_scene(C); @@ -649,12 +617,14 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char prop= RNA_struct_find_property(ptr, propname); if(!prop) { - printf("uiTemplateImage: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: property not found: %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } if(RNA_property_type(prop) != PROP_POINTER) { - printf("uiTemplateImage: expected pointer property for %s.%s\n", RNA_struct_identifier(ptr->type), propname); + printf("%s: expected pointer property for %s.%s\n", + __func__, RNA_struct_identifier(ptr->type), propname); return; } @@ -674,8 +644,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if(!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); - // XXX missing: reload, pack - if(ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -815,6 +783,78 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char MEM_freeN(cb); } +void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) +{ + ImageFormatData *imf= imfptr->data; + ID *id= imfptr->id.data; + const int depth_ok= BKE_imtype_valid_depths(imf->imtype); + /* some settings depend on this being a scene thats rendered */ + const short is_render_out= (id && GS(id->name) == ID_SCE); + + uiLayout *col, *row, *split, *sub; + + col= uiLayoutColumn(layout, 0); + + split= uiLayoutSplit(col, 0.5f, 0); + + uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE); + sub= uiLayoutRow(split, 0); + uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, "Color", ICON_NONE); + + /* only display depth setting if multiple depths can be used */ + if((ELEM6(depth_ok, + R_IMF_CHAN_DEPTH_1, + R_IMF_CHAN_DEPTH_8, + R_IMF_CHAN_DEPTH_12, + R_IMF_CHAN_DEPTH_16, + R_IMF_CHAN_DEPTH_24, + R_IMF_CHAN_DEPTH_32)) == 0) + { + row= uiLayoutRow(col, 0); + uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + } + + if (BKE_imtype_supports_quality(imf->imtype)) { + uiItemR(col, imfptr, "quality", 0, NULL, ICON_NONE); + } + + if (BKE_imtype_supports_compress(imf->imtype)) { + uiItemR(col, imfptr, "compression", 0, NULL, ICON_NONE); + } + + if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { + uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); + } + + row= uiLayoutRow(col, 0); + if (BKE_imtype_supports_zbuf(imf->imtype)) { + uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); + } + + if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) { + uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE); + } + + if (imf->imtype == R_IMF_IMTYPE_JP2) { + row= uiLayoutRow(col, 0); + uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); + uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); + + uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE); + } + + if (imf->imtype == R_IMF_IMTYPE_CINEON) { +#if 1 + uiItemL(col, "Hard coded Non-Linear, Gamma:1.0", ICON_NONE); +#else + uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "cineon_white", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE); +#endif + } +} + void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser) { Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 77c92b2d9c3..0efc89e802a 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -707,40 +707,6 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot) } /**************** load/replace/save callbacks ******************/ - -/* XXX make dynamic */ -static const EnumPropertyItem image_file_type_items[] = { - {R_TARGA, "TARGA", 0, "Targa", ""}, - {R_RAWTGA, "TARGA RAW", 0, "Targa Raw", ""}, - {R_PNG, "PNG", 0, "PNG", ""}, -#ifdef WITH_DDS - {R_DDS, "DDS", 0, "DirectDraw Surface", ""}, -#endif - {R_BMP, "BMP", 0, "BMP", ""}, - {R_JPEG90, "JPEG", 0, "Jpeg", ""}, -#ifdef WITH_OPENJPEG - {R_JP2, "JPEG_2000", 0, "Jpeg 2000", ""}, -#endif - {R_IRIS, "IRIS", 0, "Iris", ""}, -#ifdef WITH_TIFF - {R_TIFF, "TIFF", 0, "Tiff", ""}, -#endif -#ifdef WITH_DDS - {R_RADHDR, "RADIANCE_HDR", 0, "Radiance HDR", ""}, -#endif -#ifdef WITH_CINEON - {R_CINEON, "CINEON", 0, "Cineon", ""}, - {R_DPX, "DPX", 0, "DPX", ""}, -#endif -#ifdef WITH_OPENEXR - {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""}, - /* saving sequences of multilayer won't work, they copy buffers */ - /*if(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER); - else*/ - {R_MULTILAYER, "MULTILAYER", 0, "MultiLayer", ""}, -#endif - {0, NULL, 0, NULL, NULL}}; - static void image_filesel(bContext *C, wmOperator *op, const char *path) { RNA_string_set(op->ptr, "filepath", path); @@ -943,19 +909,42 @@ void IMAGE_OT_replace(wmOperatorType *ot) typedef struct { /* matching scene->r settings */ - short planes, imtype, subimtype, quality; + //short planes, imtype, subimtype, quality; + ImageFormatData im_format; char filepath[FILE_MAX]; /* keep absolute */ } SaveImageOptions; static void save_image_options_defaults(SaveImageOptions *simopts) { - simopts->planes= R_PLANES24; - simopts->imtype= R_PNG; - simopts->subimtype= 0; - simopts->quality= 90; + memset(&simopts->im_format, 0, sizeof(simopts->im_format)); + simopts->im_format.planes= R_IMF_PLANES_RGB; + simopts->im_format.imtype= R_IMF_IMTYPE_PNG; + simopts->im_format.quality= 90; + simopts->im_format.compress= 90; simopts->filepath[0]= '\0'; } +static char imtype_best_depth(ImBuf *ibuf, const char imtype) +{ + const char depth_ok= BKE_imtype_valid_depths(imtype); + + if (ibuf->rect_float) { + if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32; + if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24; + if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16; + if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12; + return R_IMF_CHAN_DEPTH_8; + } + else { + if (depth_ok & R_IMF_CHAN_DEPTH_8) return R_IMF_CHAN_DEPTH_8; + if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12; + if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16; + if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24; + if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32; + return R_IMF_CHAN_DEPTH_8; /* fallback, should not get here */ + } +} + static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path) { void *lock; @@ -963,34 +952,41 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, if(ibuf) { Image *ima= sima->image; + short is_depth_set= FALSE; - simopts->planes= ibuf->depth; + simopts->im_format.planes= ibuf->planes; if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { - simopts->imtype= scene->r.imtype; - simopts->planes= scene->r.planes; + /* imtype */ + simopts->im_format= scene->r.im_format; + is_depth_set= TRUE; } else if (ima->source == IMA_SRC_GENERATED) { - simopts->imtype= R_PNG; + simopts->im_format.imtype= R_IMF_IMTYPE_PNG; } else { - simopts->imtype= BKE_ftype_to_imtype(ibuf->ftype); + simopts->im_format.imtype= BKE_ftype_to_imtype(ibuf->ftype); } - simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ - simopts->quality= ibuf->ftype & 0xff; + //simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ + simopts->im_format.quality= ibuf->ftype & 0xff; BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath)); /* sanitize all settings */ /* unlikely but just incase */ - if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) { - simopts->planes= R_PLANES32; + if (ELEM3(simopts->im_format.planes, R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA) == 0) { + simopts->im_format.planes= R_IMF_PLANES_RGBA; + } + + /* depth, account for float buffer and format support */ + if (is_depth_set == FALSE) { + simopts->im_format.depth= imtype_best_depth(ibuf, simopts->im_format.imtype); } /* some formats dont use quality so fallback to scenes quality */ - if (simopts->quality == 0) { - simopts->quality= scene->r.quality; + if (simopts->im_format.quality == 0) { + simopts->im_format.quality= scene->r.im_format.quality; } /* check for empty path */ @@ -1009,18 +1005,11 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, return (ibuf != NULL); } -static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op, Scene *evil_scene) +static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op) { - if (RNA_property_is_set(op->ptr, "color_mode")) simopts->planes= RNA_enum_get(op->ptr, "color_mode"); - if (RNA_property_is_set(op->ptr, "file_format")) simopts->imtype= RNA_enum_get(op->ptr, "file_format"); - -#if 0 - if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX -#else - simopts->subimtype= evil_scene->r.subimtype; -#endif - - if (RNA_property_is_set(op->ptr, "file_quality")) simopts->quality= RNA_int_get(op->ptr, "file_quality"); + if (op->customdata) { + simopts->im_format= *(ImageFormatData *)op->customdata; + } if (RNA_property_is_set(op->ptr, "filepath")) { RNA_string_get(op->ptr, "filepath", simopts->filepath); @@ -1030,10 +1019,9 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) { - RNA_enum_set(op->ptr, "color_mode", simopts->planes); - RNA_enum_set(op->ptr, "file_format", simopts->imtype); - // RNA_enum_set(op->ptr, "subimtype", simopts->subimtype); - RNA_int_set(op->ptr, "file_quality", simopts->quality); + if (op->customdata) { + *(ImageFormatData *)op->customdata= simopts->im_format; + } RNA_string_set(op->ptr, "filepath", simopts->filepath); } @@ -1059,26 +1047,26 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI if(ima->type == IMA_TYPE_R_RESULT) { /* enforce user setting for RGB or RGBA, but skip BW */ - if(simopts->planes==R_PLANES32) { - ibuf->depth= 32; + if(simopts->im_format.planes==R_IMF_PLANES_RGBA) { + ibuf->planes= R_IMF_PLANES_RGBA; } - else if(simopts->planes==R_PLANES24) { - ibuf->depth= 24; + else if(simopts->im_format.planes==R_IMF_PLANES_RGB) { + ibuf->planes= R_IMF_PLANES_RGB; } } else { /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ if(ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ - ibuf->depth= BKE_alphatest_ibuf(ibuf) ? 32 : 24; + ibuf->planes= BKE_alphatest_ibuf(ibuf) ? 32 : 24; } } - if(simopts->imtype==R_MULTILAYER) { + if(simopts->im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { Scene *scene= CTX_data_scene(C); RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); if(rr) { - RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->quality); + RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.quality); ok= TRUE; } else { @@ -1086,8 +1074,10 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI } BKE_image_release_renderresult(scene, ima); } - else if (BKE_write_ibuf(ibuf, simopts->filepath, simopts->imtype, simopts->subimtype, simopts->quality)) { - ok= TRUE; + else { + if (BKE_write_ibuf_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { + ok= TRUE; + } } if (ok) { @@ -1139,27 +1129,40 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ED_space_image_release_buffer(sima, lock); } +static void image_save_as_free(wmOperator *op) +{ + if (op->customdata) { + MEM_freeN(op->customdata); + op->customdata= NULL; + } +} + static int image_save_as_exec(bContext *C, wmOperator *op) { SpaceImage *sima= CTX_wm_space_image(C); SaveImageOptions simopts; + save_image_options_defaults(&simopts); + /* just incase to initialize values, * these should be set on invoke or by the caller. */ - save_image_options_defaults(&simopts); - save_image_options_from_op(&simopts, op, CTX_data_scene(C)); + save_image_options_init(&simopts, sima, CTX_data_scene(C), 0); + + save_image_options_from_op(&simopts, op); save_image_doit(C, sima, op, &simopts, TRUE); + image_save_as_free(op); return OPERATOR_FINISHED; } static int image_save_as_check(bContext *UNUSED(C), wmOperator *op) { + ImageFormatData *imf= op->customdata; char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_format"))) { + if(BKE_add_image_extension(filepath, imf->imtype)) { RNA_string_set(op->ptr, "filepath", filepath); return TRUE; } @@ -1185,15 +1188,51 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve RNA_boolean_set(op->ptr, "copy", TRUE); } - // XXX note: we can give default menu enums to operator for this + op->customdata= MEM_mallocN(sizeof(simopts.im_format), __func__); + memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format)); + image_filesel(C, op, simopts.filepath); return OPERATOR_RUNNING_MODAL; } +static int image_save_as_cancel(bContext *UNUSED(C), wmOperator *op) +{ + image_save_as_free(op); + + return OPERATOR_CANCELLED; +} + +static int image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +{ + const char *prop_id= RNA_property_identifier(prop); + + return !(strcmp(prop_id, "filepath") == 0 || + strcmp(prop_id, "directory") == 0 || + strcmp(prop_id, "filename") == 0 || + /* when saving a copy, relative path has no effect */ + ((strcmp(prop_id, "relative_path") == 0) && RNA_boolean_get(ptr, "copy")) + ); +} + +static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op) +{ + uiLayout *layout= op->layout; + ImageFormatData *imf= op->customdata; + PointerRNA ptr; + + /* image template */ + RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &ptr); + uiTemplateImageSettings(layout, &ptr); + + /* main draw call */ + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, '\0'); +} + void IMAGE_OT_save_as(wmOperatorType *ot) { - PropertyRNA *prop; +// PropertyRNA *prop; /* identifiers */ ot->name= "Save As Image"; @@ -1203,22 +1242,17 @@ void IMAGE_OT_save_as(wmOperatorType *ot) ot->exec= image_save_as_exec; ot->check= image_save_as_check; ot->invoke= image_save_as_invoke; + ot->cancel= image_save_as_cancel; + ot->ui= image_save_as_draw; ot->poll= space_image_buffer_exists_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - - /* format options */ - RNA_def_enum(ot->srna, "file_format", image_file_type_items, R_PNG, "File Type", "File type to save image as"); - RNA_def_enum(ot->srna, "color_mode", image_color_mode_items, R_PLANES24, "Channels", "Image channels to save"); - prop= RNA_def_int(ot->srna, "file_quality", 90, 0, 100, "Quality", "", 0, 100); - RNA_def_property_subtype(prop, PROP_PERCENTAGE); + RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender"); WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); - - RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender"); } /******************** save image operator ********************/ @@ -1231,7 +1265,7 @@ static int image_save_exec(bContext *C, wmOperator *op) if (save_image_options_init(&simopts, sima, scene, FALSE) == 0) return OPERATOR_CANCELLED; - save_image_options_from_op(&simopts, op, scene); + save_image_options_from_op(&simopts, op); if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) { save_image_doit(C, sima, op, &simopts, FALSE); diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 2f69fc5f99f..e5255448ae9 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3222,7 +3222,7 @@ static int is_sensor_linked(uiBlock *block, bSensor *sens) static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr) { - uiLayout *box, *row, *subrow; + uiLayout *box, *row, *sub; bSensor *sens= (bSensor *)ptr->data; box= uiLayoutBox(layout); @@ -3237,15 +3237,15 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiItemL(row, sens->name, ICON_NONE); } - subrow= uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") + sub= uiLayoutRow(row, 0); + uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); - uiItemR(subrow, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); + uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if(RNA_boolean_get(ptr, "show_expanded")==0) { - subrow= uiLayoutRow(row, 1); - uiItemEnumO(subrow, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up - uiItemEnumO(subrow, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down + sub= uiLayoutRow(row, 1); + uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up + uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down } uiItemO(row, "", ICON_X, "LOGIC_OT_sensor_remove"); @@ -3253,7 +3253,7 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) { - uiLayout *box, *split, *subrow, *row; + uiLayout *box, *split, *sub, *row; box= uiLayoutBox(layout); split = uiLayoutSplit(box, 0.45, 0); @@ -3262,17 +3262,16 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP); uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN); - subrow=uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, (RNA_boolean_get(ptr, "use_pulse_true_level") + sub=uiLayoutRow(row, 0); + uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") || RNA_boolean_get(ptr, "use_pulse_false_level"))); - uiItemR(subrow, ptr, "frequency", 0, "Freq", ICON_NONE); + uiItemR(sub, ptr, "frequency", 0, "Freq", ICON_NONE); row= uiLayoutRow(split, 1); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row= uiLayoutRow(split, 1); - uiItemR(row, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", ICON_NONE); + uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", ICON_NONE); } /* sensors in alphabetical order */ @@ -3577,7 +3576,7 @@ static void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C) /* Controller code */ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, int width, int yco) { - uiLayout *box, *row, *subrow; + uiLayout *box, *row, *sub; bController *cont= (bController *)ptr->data; char state[3]; @@ -3601,9 +3600,9 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE); if(RNA_boolean_get(ptr, "show_expanded")==0) { - subrow= uiLayoutRow(row, 1); - uiItemEnumO(subrow, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up - uiItemEnumO(subrow, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down + sub= uiLayoutRow(row, 1); + uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up + uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down } uiItemO(row, "", ICON_X, "LOGIC_OT_controller_remove"); } @@ -3615,7 +3614,7 @@ static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr) static void draw_controller_python(uiLayout *layout, PointerRNA *ptr) { - uiLayout *split, *subsplit; + uiLayout *split, *sub; split = uiLayoutSplit(layout, 0.3, 1); uiItemR(split, ptr, "mode", 0, "", ICON_NONE); @@ -3623,9 +3622,9 @@ static void draw_controller_python(uiLayout *layout, PointerRNA *ptr) uiItemR(split, ptr, "text", 0, "", ICON_NONE); } else { - subsplit = uiLayoutSplit(split, 0.8, 0); - uiItemR(subsplit, ptr, "module", 0, "", ICON_NONE); - uiItemR(subsplit, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + sub = uiLayoutSplit(split, 0.8, 0); + uiItemR(sub, ptr, "module", 0, "", ICON_NONE); + uiItemR(sub, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } } @@ -3670,7 +3669,7 @@ static void draw_brick_controller(uiLayout *layout, PointerRNA *ptr) /* Actuator code */ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr) { - uiLayout *box, *row, *subrow; + uiLayout *box, *row, *sub; bActuator *act= (bActuator *)ptr->data; box= uiLayoutBox(layout); @@ -3685,15 +3684,15 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiItemL(row, act->name, ICON_NONE); } - subrow= uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") + sub= uiLayoutRow(row, 0); + uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); - uiItemR(subrow, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); + uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if(RNA_boolean_get(ptr, "show_expanded")==0) { - subrow= uiLayoutRow(row, 1); - uiItemEnumO(subrow, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up - uiItemEnumO(subrow, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down + sub= uiLayoutRow(row, 1); + uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up + uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down } uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove"); } @@ -3702,20 +3701,20 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointerRNA settings_ptr; - uiLayout *row, *subrow, *col; + uiLayout *row, *sub; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE); - subrow= uiLayoutRow(row, 1); - uiItemR(subrow, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - uiItemR(subrow, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + sub= uiLayoutRow(row, 1); + uiItemR(sub, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + uiItemR(sub, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(subrow, 0); - uiLayoutSetActive(col, (RNA_boolean_get(ptr, "use_additive") || RNA_boolean_get(ptr, "use_force"))); - uiItemR(col, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + row = uiLayoutColumn(sub, 0); + uiLayoutSetActive(row, (RNA_boolean_get(ptr, "use_additive") || RNA_boolean_get(ptr, "use_force"))); + uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "action", 0, "", ICON_NONE); @@ -3740,11 +3739,10 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE); uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR - uiItemR(row, "stride_length", 0, NULL, ICON_NONE); + uiItemR(layout, "stride_length", 0, NULL, ICON_NONE); #endif } @@ -3829,7 +3827,7 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext *C) { - uiLayout *row, *col, *subcol, *split; + uiLayout *row, *col, *sub, *split; PointerRNA main_ptr; RNA_main_pointer_create(CTX_data_main(C), &main_ptr); @@ -3855,15 +3853,15 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, 1); uiItemL(col, "Range:", ICON_NONE); uiItemR(col, ptr, "range", 0, "", ICON_NONE); col = uiLayoutColumn(row, 1); uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - subcol = uiLayoutColumn(col, 0); - uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_force_distance")==1); - uiItemR(subcol, ptr, "distance", 0, "", ICON_NONE); + sub = uiLayoutColumn(col, 0); + uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_force_distance")==1); + uiItemR(sub, ptr, "distance", 0, "", ICON_NONE); uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, ICON_NONE); @@ -3931,7 +3929,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; - uiLayout *row, *split, *subsplit; + uiLayout *row, *split, *sub; uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); switch (RNA_enum_get(ptr, "mode")) @@ -3967,9 +3965,9 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) case ACT_EDOB_TRACK_TO: split = uiLayoutSplit(layout, 0.5, 0); uiItemR(split, ptr, "track_object", 0, NULL, ICON_NONE); - subsplit = uiLayoutSplit(split, 0.7, 0); - uiItemR(subsplit, ptr, "time", 0, NULL, ICON_NONE); - uiItemR(subsplit, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + sub = uiLayoutSplit(split, 0.7, 0); + uiItemR(sub, ptr, "time", 0, NULL, ICON_NONE); + uiItemR(sub, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; case ACT_EDOB_DYNAMICS: if(ob->type != OB_MESH) { @@ -4041,7 +4039,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) { Object *ob; PointerRNA settings_ptr; - uiLayout *split, *row, *col, *subcol; + uiLayout *split, *row, *col, *sub; int physics_type; ob = (Object *)ptr->id.data; @@ -4100,24 +4098,24 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(layout, 0); col = uiLayoutColumn(row, 0); uiItemR(col, ptr, "use_servo_limit_x", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - subcol = uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_servo_limit_x")==1); - uiItemR(subcol, ptr, "force_max_x", 0, NULL, ICON_NONE); - uiItemR(subcol, ptr, "force_min_x", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_x")==1); + uiItemR(sub, ptr, "force_max_x", 0, NULL, ICON_NONE); + uiItemR(sub, ptr, "force_min_x", 0, NULL, ICON_NONE); col = uiLayoutColumn(row, 0); uiItemR(col, ptr, "use_servo_limit_y", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - subcol = uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_servo_limit_y")==1); - uiItemR(subcol, ptr, "force_max_y", 0, NULL, ICON_NONE); - uiItemR(subcol, ptr, "force_min_y", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_y")==1); + uiItemR(sub, ptr, "force_max_y", 0, NULL, ICON_NONE); + uiItemR(sub, ptr, "force_min_y", 0, NULL, ICON_NONE); col = uiLayoutColumn(row, 0); uiItemR(col, ptr, "use_servo_limit_z", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - subcol = uiLayoutColumn(col, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_servo_limit_z")==1); - uiItemR(subcol, ptr, "force_max_z", 0, NULL, ICON_NONE); - uiItemR(subcol, ptr, "force_min_z", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_z")==1); + uiItemR(sub, ptr, "force_max_z", 0, NULL, ICON_NONE); + uiItemR(sub, ptr, "force_min_z", 0, NULL, ICON_NONE); //XXXACTUATOR missing labels from original 2.49 ui (e.g. Servo, Min, Max, Fast) //Layout designers willing to help on that, please compare with 2.49 ui @@ -4133,7 +4131,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr) { - uiLayout *row, *subrow; + uiLayout *row, *sub; uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); @@ -4142,9 +4140,9 @@ static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(layout, 0); uiItemR(row, ptr, "use_compound", 0, NULL, ICON_NONE); - subrow= uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "use_compound")==1); - uiItemR(subrow, ptr, "use_ghost", 0, NULL, ICON_NONE); + sub= uiLayoutRow(row, 0); + uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_compound")==1); + uiItemR(sub, ptr, "use_ghost", 0, NULL, ICON_NONE); } } @@ -4156,7 +4154,7 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) Object *ob_from= pa->ob; PointerRNA settings_ptr, obj_settings_ptr; - uiLayout *row, *subrow; + uiLayout *row, *sub; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); @@ -4181,9 +4179,9 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) uiItemPointerR(row, ptr, "object_property", &obj_settings_ptr, "properties", NULL, ICON_NONE); }else { - subrow= uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, 0); - uiItemR(subrow, ptr, "object_property", 0, NULL, ICON_NONE); + sub= uiLayoutRow(row, 0); + uiLayoutSetActive(sub, 0); + uiItemR(sub, ptr, "object_property", 0, NULL, ICON_NONE); } break; } diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 1d2d6b4f8a7..9bacdf8327b 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -295,7 +295,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) { PointerRNA strip_ptr; uiLayout *layout= pa->layout; - uiLayout *column, *row, *subcol; + uiLayout *column, *row, *sub; uiBlock *block; short showEvalProps = 1; @@ -340,10 +340,10 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - subcol= uiLayoutColumn(column, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); - uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); - uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + sub= uiLayoutColumn(column, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); + uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); + uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); /* settings */ column= uiLayoutColumn(layout, 1); @@ -396,7 +396,7 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) { PointerRNA strip_ptr; uiLayout *layout= pa->layout; - uiLayout *column, *subcolumn, *subrow; + uiLayout *col, *sub; uiBlock *block; /* check context and also validity of pointer */ @@ -406,23 +406,21 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) block= uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); - column= uiLayoutColumn(layout, 1); - uiItemR(column, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - - subcolumn= uiLayoutColumn(column, 1); - uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "use_animated_influence")); - uiItemR(subcolumn, &strip_ptr, "influence", 0, NULL, ICON_NONE); - + col= uiLayoutColumn(layout, 1); + uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - column= uiLayoutColumn(layout, 1); - subrow= uiLayoutRow(column, 0); - uiItemR(subrow, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); - uiItemR(subrow, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); - - subcolumn= uiLayoutColumn(column, 1); - subrow= uiLayoutRow(subcolumn, 0); - uiLayoutSetEnabled(subrow, RNA_boolean_get(&strip_ptr, "use_animated_time")); - uiItemR(subcolumn, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); + sub= uiLayoutColumn(col, 1); + uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); + uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); + + col= uiLayoutColumn(layout, 1); + sub= uiLayoutRow(col, 0); + uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); + uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); + + sub= uiLayoutRow(col, 0); + uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time")); + uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } /* F-Modifiers for active NLA-Strip */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 92592a7c071..4e9ac08d8c8 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -471,6 +471,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) float locx, locy; rctf *rect= &gnode->totr; float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; + float group_header= 26*U.dpi/72; int counter; int dy; @@ -594,6 +595,15 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) gsock = gsock->next; } } + + /* Set the block bounds to clip mouse events from underlying nodes. + * Add margin for header and input/output columns. + */ + uiExplicitBoundsBlock(gnode->block, + rect->xmin - node_group_frame, + rect->ymin, + rect->xmax + node_group_frame, + rect->ymax + group_header); } } @@ -1001,7 +1011,6 @@ static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), Po static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr) { - //uiItemR(layout, ptr, "image", 0, "", ICON_NONE); uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); } @@ -1633,24 +1642,17 @@ static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), Po static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiLayout *col, *row; + bNode *node= ptr->data; + NodeImageFile *nif= node->storage; + PointerRNA imfptr; + + uiLayout *row; + + uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE); + + RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &nif->im_format, &imfptr); + uiTemplateImageSettings(layout, &imfptr); - col= uiLayoutColumn(layout, 0); - uiItemR(col, ptr, "filepath", 0, "", ICON_NONE); - uiItemR(col, ptr, "image_type", 0, "", ICON_NONE); - - row= uiLayoutRow(layout, 0); - if (RNA_enum_get(ptr, "image_type")== R_OPENEXR) { - uiItemR(row, ptr, "use_exr_half", 0, NULL, ICON_NONE); - uiItemR(row, ptr, "exr_codec", 0, "", ICON_NONE); - } - else if (RNA_enum_get(ptr, "image_type")== R_JPEG90) { - uiItemR(row, ptr, "quality", UI_ITEM_R_SLIDER, "Quality", ICON_NONE); - } - else if (RNA_enum_get(ptr, "image_type")== R_PNG) { - uiItemR(row, ptr, "quality", UI_ITEM_R_SLIDER, "Compression", ICON_NONE); - } - row= uiLayoutRow(layout, 1); uiItemR(row, ptr, "frame_start", 0, "Start", ICON_NONE); uiItemR(row, ptr, "frame_end", 0, "End", ICON_NONE); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c4a7f2cb473..02a8b5cc9fb 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -197,28 +197,16 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) bNode *node; char str[32]; - /* add node uiBlocks in reverse order - prevents events going to overlapping nodes */ + /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - /* process selected nodes first so they're at the start of the uiblocks list */ - for(node= ntree->nodes.last; node; node= node->prev) { - - if (node->flag & NODE_SELECT) { - /* ui block */ - sprintf(str, "node buttons %p", (void *)node); - node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); - uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); - } - } - - /* then the rest */ - for(node= ntree->nodes.last; node; node= node->prev) { - - if (!(node->flag & (NODE_GROUP_EDIT|NODE_SELECT))) { + for(node= ntree->nodes.first; node; node=node->next) { /* ui block */ sprintf(str, "node buttons %p", (void *)node); node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); - } + + /* this cancels events for background nodes */ + uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS); } } @@ -339,6 +327,15 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->totr.xmax= locx + node->width; node->totr.ymax= locy; node->totr.ymin= MIN2(dy, locy-2*NODE_DY); + + /* Set the block bounds to clip mouse events from underlying nodes. + * Add a margin for sockets on each side. + */ + uiExplicitBoundsBlock(node->block, + node->totr.xmin - NODE_SOCKSIZE, + node->totr.ymin, + node->totr.xmax + NODE_SOCKSIZE, + node->totr.ymax); } /* based on settings in node, sets drawing rect info. each redraw! */ @@ -391,6 +388,15 @@ static void node_update_hidden(bNode *node) rad+= drad; } } + + /* Set the block bounds to clip mouse events from underlying nodes. + * Add a margin for sockets on each side. + */ + uiExplicitBoundsBlock(node->block, + node->totr.xmin - NODE_SOCKSIZE, + node->totr.ymin, + node->totr.xmax + NODE_SOCKSIZE, + node->totr.ymax); } void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) @@ -927,15 +933,16 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) if(snode->nodetree) { bNode *node; - /* init ui blocks for opened node group trees first - * so they're in the correct depth stack order */ + node_uiblocks_init(C, snode->nodetree); + + /* uiBlocks must be initialized in drawing order for correct event clipping. + * Node group internal blocks added after the main group block. + */ for(node= snode->nodetree->nodes.first; node; node= node->next) { if(node->flag & NODE_GROUP_EDIT) node_uiblocks_init(C, (bNodeTree *)node->id); } - node_uiblocks_init(C, snode->nodetree); - node_update_nodetree(C, snode->nodetree, 0.0f, 0.0f); node_draw_nodetree(C, ar, snode, snode->nodetree); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 27ad2c4fd6d..f4e46d0255d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -297,8 +297,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); if(base) { - SpaceOops *soops= CTX_wm_space_outliner(C); - // check also library later if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); @@ -306,15 +304,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); te->directdata= NULL; tselem->id= NULL; - - /* XXX: tree management normally happens from draw_outliner(), but when - you're clicking to fast on Delete object from context menu in - outliner several mouse events can be handled in one cycle without - handling notifiers/redraw which leads to deleting the same object twice. - cleanup tree here to prevent such cases. */ - outliner_cleanup_tree(soops); } - } static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) @@ -579,6 +569,14 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } else if(event==4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); + + /* XXX: tree management normally happens from draw_outliner(), but when + you're clicking to fast on Delete object from context menu in + outliner several mouse events can be handled in one cycle without + handling notifiers/redraw which leads to deleting the same object twice. + cleanup tree here to prevent such cases. */ + outliner_cleanup_tree(soops); + DAG_scene_sort(bmain, scene); str= "Delete Objects"; WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index ddfa2fd915f..2b59a02deae 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -512,7 +512,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, const unsigned char background_col[3]) { rctf rect; - char str[32 + FILE_MAXDIR+FILE_MAXFILE]; + char str[32 + FILE_MAX]; const char *name= seq->name+2; char col[4]; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index e36cdd32ab8..16ee32d10a2 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -449,9 +449,9 @@ static void txt_write_file(Text *text, ReportList *reports) FILE *fp; TextLine *tmp; struct stat st; - char filepath[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAX]; - BLI_strncpy(filepath, text->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(filepath, text->name, FILE_MAX); BLI_path_abs(filepath, G.main->name); fp= fopen(filepath, "w"); @@ -3053,12 +3053,12 @@ int text_file_modified(Text *text) { struct stat st; int result; - char file[FILE_MAXDIR+FILE_MAXFILE]; + char file[FILE_MAX]; if(!text || !text->name) return 0; - BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(file, text->name, FILE_MAX); BLI_path_abs(file, G.main->name); if(!BLI_exists(file)) @@ -3082,11 +3082,11 @@ static void text_ignore_modified(Text *text) { struct stat st; int result; - char file[FILE_MAXDIR+FILE_MAXFILE]; + char file[FILE_MAX]; if(!text || !text->name) return; - BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_strncpy(file, text->name, FILE_MAX); BLI_path_abs(file, G.main->name); if(!BLI_exists(file)) return; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 0ce2e891b6e..be3a599330b 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -112,6 +112,12 @@ ((ELEM(vd->drawtype, OB_TEXTURE, OB_MATERIAL) && dt>OB_SOLID) || \ (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) +typedef enum eWireDrawMode { + OBDRAW_WIRE_OFF= 0, + OBDRAW_WIRE_ON= 1, + OBDRAW_WIRE_ON_DEPTH= 2 +} eWireDrawMode; + static void draw_bounding_volume(Scene *scene, Object *ob, char type); static void drawcube_size(float size); @@ -1093,7 +1099,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* cone can't be drawn for duplicated lamps, because duplilist would be freed to */ /* the moment of view3d_draw_transp() call */ const short is_view= (rv3d->persp==RV3D_CAMOB && v3d->camera == base->object); - const short drawcone= (dt>OB_WIRE && !(G.f & G_PICKSEL) && (la->type == LA_SPOT) && (la->mode & LA_SHOW_CONE) && !(base->flag & OB_FROMDUPLI) && !is_view); + const short drawcone= ((dt > OB_WIRE) && + !(G.f & G_PICKSEL) && + (la->type == LA_SPOT) && + (la->mode & LA_SHOW_CONE) && + !(base->flag & OB_FROMDUPLI) && + !is_view); if(drawcone && !v3d->transp) { /* in this case we need to draw delayed */ @@ -1568,7 +1579,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, glBegin(GL_LINE_STRIP); for(a= 0; a<reconstruction->camnr; a++, camera++) { - glVertex3f(camera->mat[3][0], camera->mat[3][1], camera->mat[3][2]); + glVertex3fv(camera->mat[3]); } glEnd(); @@ -1806,7 +1817,7 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i float col[3]; MDeformWeight *mdw= defvert_find_index (lt->dvert+index, use_wcol-1); - weight_to_rgb(mdw?mdw->weight:0.0f, col, col+1, col+2); + weight_to_rgb(col, mdw?mdw->weight:0.0f); glColor3fv(col); } @@ -2747,35 +2758,29 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object if(dt>OB_WIRE) { if(CHECK_OB_DRAWTEXTURE(v3d, dt)) { if(draw_glsl_material(scene, ob, v3d, dt)) { - /* if em has no faces the drawMappedFaces callback will fail */ - if(em->faces.first) { - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - - finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, - draw_em_fancy__setGLSLFaceOpts, NULL); - GPU_disable_material(); - - glFrontFace(GL_CCW); - } + glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + + finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, + draw_em_fancy__setGLSLFaceOpts, NULL); + GPU_disable_material(); + + glFrontFace(GL_CCW); } else { draw_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0); } } else { - /* if em has no faces the drawMappedFaces callback will fail */ - if(em->faces.first) { - /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */ - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED); - - glEnable(GL_LIGHTING); - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - - finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL); - - glFrontFace(GL_CCW); - glDisable(GL_LIGHTING); - } + /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */ + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED); + + glEnable(GL_LIGHTING); + glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + + finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL); + + glFrontFace(GL_CCW); + glDisable(GL_LIGHTING); } // Setup for drawing wire over, disable zbuffer @@ -2944,7 +2949,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D Mesh *me = ob->data; Material *ma= give_current_material(ob, 1); const short hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO)); - int draw_wire = 0; + eWireDrawMode draw_wire= OBDRAW_WIRE_OFF; int /* totvert,*/ totedge, totface; DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); ModifierData *md = NULL; @@ -2967,9 +2972,13 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } } - - if (ob->dtx&OB_DRAWWIRE) { - draw_wire = 2; /* draw wire after solid using zoffset and depth buffer adjusment */ + + /* Unwanted combination */ + if (draw_flags & DRAW_FACE_SELECT) { + draw_wire= OBDRAW_WIRE_OFF; + } + else if (ob->dtx & OB_DRAWWIRE) { + draw_wire= OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */ } /* totvert = dm->getNumVerts(dm); */ /*UNUSED*/ @@ -2979,9 +2988,6 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */ glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - // Unwanted combination. - if (draw_flags & DRAW_FACE_SELECT) draw_wire = 0; - if(dt==OB_BOUNDBOX) { if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0) draw_bounding_volume(scene, ob, ob->boundtype); @@ -2992,12 +2998,17 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glPointSize(1.0); } else if(dt==OB_WIRE || totface==0) { - draw_wire = 1; /* draw wire only, no depth buffer stuff */ + draw_wire= OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */ } - else if( (draw_flags & DRAW_FACE_SELECT || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) || - CHECK_OB_DRAWTEXTURE(v3d, dt)) + else if ( (draw_flags & DRAW_FACE_SELECT || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) || + CHECK_OB_DRAWTEXTURE(v3d, dt)) { - if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && !draw_wire) { + if ( (v3d->flag & V3D_SELECT_OUTLINE) && + ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && + (base->flag & SELECT) && + !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && + (draw_wire == OBDRAW_WIRE_OFF)) + { draw_mesh_object_outline(v3d, ob, dm); } @@ -3049,7 +3060,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D GPU_disable_material(); /* since we already draw wire as wp guide, dont draw over the top */ - draw_wire= 0; + draw_wire= OBDRAW_WIRE_OFF; } else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) { /* for object selection draws no shade */ @@ -3058,8 +3069,14 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } else { /* draw outline */ - if((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire && !ob->sculpt) + if ( (v3d->flag & V3D_SELECT_OUTLINE) && + ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && + (base->flag & SELECT) && + (draw_wire == OBDRAW_WIRE_OFF) && + (ob->sculpt == NULL)) + { draw_mesh_object_outline(v3d, ob, dm); + } /* materials arent compatible with vertex colors */ GPU_end_object_materials(); @@ -3086,8 +3103,14 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else { Paint *p; - if((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire && !ob->sculpt) + if ( (v3d->flag & V3D_SELECT_OUTLINE) && + ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && + (base->flag & SELECT) && + (draw_wire == OBDRAW_WIRE_OFF) && + (ob->sculpt == NULL)) + { draw_mesh_object_outline(v3d, ob, dm); + } glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED ); @@ -3181,7 +3204,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } } - if (draw_wire) { + if (draw_wire != OBDRAW_WIRE_OFF) { /* When using wireframe object traw in particle edit mode * the mesh gets in the way of seeing the particles, fade the wire color @@ -3204,7 +3227,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D * if draw wire is 1 then just drawing wire, no need for depth buffer stuff, * otherwise this wire is to overlay solid mode faces so do some depth buffer tricks. */ - if (dt!=OB_WIRE && draw_wire==2) { + if (dt!=OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { bglPolygonOffset(rv3d->dist, 1.0); glDepthMask(0); // disable write in zbuffer, selected edge wires show better } @@ -3212,7 +3235,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_SOLID)==0) dm->drawEdges(dm, (dt==OB_WIRE || totface==0), me->drawflag & ME_ALLEDGES); - if (dt!=OB_WIRE && draw_wire==2) { + if (dt!=OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { glDepthMask(1); bglPolygonOffset(rv3d->dist, 0.0); } @@ -3267,15 +3290,11 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D if(dt>OB_WIRE) { glsl = draw_glsl_material(scene, ob, v3d, dt); - check_alpha = check_material_alpha(base, glsl); - GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, - (check_alpha)? &do_alpha_pass: NULL); + GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); } - // transp in editmode makes the fancy draw over go bad - if (!do_alpha_pass) - draw_em_fancy(scene, v3d, rv3d, ob, em, cageDM, finalDM, dt); + draw_em_fancy(scene, v3d, rv3d, ob, em, cageDM, finalDM, dt); GPU_end_object_materials(); @@ -3728,19 +3747,15 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix float vec[3], vec2[3]; float *vd = NULL; float *cd = NULL; - float ma_r=0.0f; - float ma_g=0.0f; - float ma_b=0.0f; + float ma_col[3]= {0.0f, 0.0f, 0.0f}; /* null only for PART_DRAW_CIRC */ if(pdd) { vd = pdd->vd; cd = pdd->cd; - if(pdd->ma_r) { - ma_r = *pdd->ma_r; - ma_g = *pdd->ma_g; - ma_b = *pdd->ma_b; + if(pdd->ma_col) { + copy_v3_v3(ma_col, pdd->ma_col); } } @@ -3751,9 +3766,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix copy_v3_v3(vd,state->co); pdd->vd+=3; } if(cd) { - cd[0]=ma_r; - cd[1]=ma_g; - cd[2]=ma_b; + copy_v3_v3(cd, pdd->ma_col); pdd->cd+=3; } break; @@ -3779,9 +3792,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix } else { if(cd) { - cd[0]=cd[3]=cd[6]=cd[9]=cd[12]=cd[15]=ma_r; - cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]=ma_g; - cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma_b; + cd[0]=cd[3]=cd[6]=cd[ 9]=cd[12]=cd[15]= ma_col[0]; + cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]= ma_col[1]; + cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]= ma_col[2]; pdd->cd+=18; } sub_v3_v3v3(vec2, state->co, vec); @@ -3826,9 +3839,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd+=3; madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd+=3; if(cd) { - cd[0]=cd[3]=ma_r; - cd[1]=cd[4]=ma_g; - cd[2]=cd[5]=ma_b; + cd[0]=cd[3]= ma_col[0]; + cd[1]=cd[4]= ma_col[1]; + cd[2]=cd[5]= ma_col[2]; pdd->cd+=6; } break; @@ -3842,9 +3855,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix { float xvec[3], yvec[3], zvec[3], bb_center[3]; if(cd) { - cd[0]=cd[3]=cd[6]=cd[9]=ma_r; - cd[1]=cd[4]=cd[7]=cd[10]=ma_g; - cd[2]=cd[5]=cd[8]=cd[11]=ma_b; + cd[0]=cd[3]=cd[6]=cd[ 9]= ma_col[0]; + cd[1]=cd[4]=cd[7]=cd[10]= ma_col[1]; + cd[2]=cd[5]=cd[8]=cd[11]= ma_col[2]; pdd->cd+=12; } @@ -3899,7 +3912,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv float timestep, pixsize=1.0, pa_size, r_tilt, r_length; float pa_time, pa_birthtime, pa_dietime, pa_health, intensity; float cfra; - float ma_r=0.0f, ma_g=0.0f, ma_b=0.0f; + float ma_col[3]= {0.0f, 0.0f, 0.0f}; int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0; int select=ob->flag&SELECT, create_cdata=0, need_v=0; GLint polygonmode[2]; @@ -3963,10 +3976,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if((ma) && (part->draw_col == PART_DRAW_COL_MAT)) { rgb_float_to_byte(&(ma->r), tcol); - - ma_r = ma->r; - ma_g = ma->g; - ma_b = ma->b; + copy_v3_v3(ma_col, &ma->r); } glColor3ubv(tcol); @@ -4132,9 +4142,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } if(pdd) { - pdd->ma_r = &ma_r; - pdd->ma_g = &ma_g; - pdd->ma_b = &ma_b; + pdd->ma_col= ma_col; } psys->lattice= psys_get_lattice(&sim); @@ -4176,7 +4184,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv intensity= 1.0f; /* should never happen */ } CLAMP(intensity, 0.f, 1.f); - weight_to_rgb(intensity, &ma_r, &ma_g, &ma_b); + weight_to_rgb(ma_col, intensity); } } else{ @@ -4437,7 +4445,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } /* restore from select */ - glColor3f(ma_r,ma_g,ma_b); + glColor3fv(ma_col); glPointSize(part->draw_size ? part->draw_size : 2.0); glLineWidth(1.0); @@ -4502,7 +4510,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if(pdd) { /* drop references to stack memory */ - pdd->ma_r= pdd->ma_g= pdd->ma_b= NULL; + pdd->ma_col= NULL; } if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) { diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 70cf113384b..15494d73ea1 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1365,142 +1365,6 @@ static void view3d_panel_preview(bContext *C, ARegion *ar, short cntrl) // VIEW3 } #endif -#if 0 // XXX not used -static void delete_sketch_armature(bContext *C, void *arg1, void *arg2) -{ - BIF_deleteSketch(C); -} - -static void convert_sketch_armature(bContext *C, void *arg1, void *arg2) -{ - BIF_convertSketch(C); -} - -static void assign_template_sketch_armature(bContext *C, void *arg1, void *arg2) -{ - int index = *(int*)arg1; - BIF_setTemplate(C, index); -} - - -static int view3d_panel_bonesketch_spaces_poll(const bContext *C, PanelType *pt) -{ - Object *obedit = CTX_data_edit_object(C); - - /* replace with check call to sketching lib */ - return (obedit && obedit->type == OB_ARMATURE); -} -static void view3d_panel_bonesketch_spaces(const bContext *C, Panel *pa) -{ - Scene *scene = CTX_data_scene(C); - static int template_index; - static char joint_label[128]; - uiBlock *block; - uiBut *but; - char *bone_name; - int yco = 130; - int nb_joints; - static char subdiv_tooltip[4][64] = { - "Subdivide arcs based on a fixed number of bones", - "Subdivide arcs in bones of equal length", - "Subdivide arcs based on correlation", - "Retarget template to stroke" - }; - - - block= uiLayoutAbsoluteBlock(pa->layout); - uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); - - uiBlockBeginAlign(block); - - /* use real flag instead of 1 */ - uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones, (Ctrl snaps to mesh volume)"); - uiDefButBitC(block, TOG, BONE_SKETCHING_ADJUST, B_REDR, "A", 170, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Adjust strokes by drawing near them"); - uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 190, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end"); - yco -= 20; - - but = uiDefBut(block, BUT, B_REDR, "Convert", 10,yco,100,20, 0, 0, 0, 0, 0, "Convert sketch to armature"); - uiButSetFunc(but, convert_sketch_armature, NULL, NULL); - - but = uiDefBut(block, BUT, B_REDR, "Delete", 110,yco,100,20, 0, 0, 0, 0, 0, "Delete sketch"); - uiButSetFunc(but, delete_sketch_armature, NULL, NULL); - yco -= 20; - - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - - uiDefButC(block, MENU, B_REDR, "Subdivision Method%t|Length%x1|Adaptative%x2|Fixed%x0|Template%x3", 10,yco,60,19, &scene->toolsettings->bone_sketching_convert, 0, 0, 0, 0, subdiv_tooltip[(unsigned char)scene->toolsettings->bone_sketching_convert]); - - switch(scene->toolsettings->bone_sketching_convert) - { - case SK_CONVERT_CUT_LENGTH: - uiDefButF(block, NUM, B_REDR, "Lim:", 70, yco, 140, 19, &scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0, "Maximum length of the subdivided bones"); - yco -= 20; - break; - case SK_CONVERT_CUT_ADAPTATIVE: - uiDefButF(block, NUM, B_REDR, "Thres:", 70, yco, 140, 19, &scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0, "Correlation threshold for subdivision"); - yco -= 20; - break; - default: - case SK_CONVERT_CUT_FIXED: - uiDefButC(block, NUM, B_REDR, "Num:", 70, yco, 140, 19, &scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Number of subdivided bones"); - yco -= 20; - break; - case SK_CONVERT_RETARGET: - uiDefButC(block, ROW, B_NOP, "No", 70, yco, 40,19, &scene->toolsettings->skgen_retarget_roll, 0, 0, 0, 0, "No special roll treatment"); - uiDefButC(block, ROW, B_NOP, "View", 110, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_VIEW, 0, 0, "Roll bones perpendicular to view"); - uiDefButC(block, ROW, B_NOP, "Joint", 160, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_JOINT, 0, 0, "Roll bones relative to joint bend"); - yco -= 30; - - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - /* button here to select what to do (copy or not), template, ...*/ - - BIF_makeListTemplates(C); - template_index = BIF_currentTemplate(C); - - but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(C), 10,yco,200,19, &template_index, 0, 0, 0, 0, "Template"); - uiButSetFunc(but, assign_template_sketch_armature, &template_index, NULL); - - yco -= 20; - - uiDefButF(block, NUM, B_NOP, "A:", 10, yco, 66,19, &scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0, "Angle Weight"); - uiDefButF(block, NUM, B_NOP, "L:", 76, yco, 67,19, &scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0, "Length Weight"); - uiDefButF(block, NUM, B_NOP, "D:", 143,yco, 67,19, &scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0, "Distance Weight"); - yco -= 20; - - uiDefBut(block, TEX,B_REDR,"S:", 10, yco, 90, 20, scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace &S with"); - uiDefBut(block, TEX,B_REDR,"N:", 100, yco, 90, 20, scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace &N with"); - uiDefIconButBitC(block, TOG, SK_RETARGET_AUTONAME, B_NOP, ICON_AUTO,190,yco,20,20, &scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Use Auto Naming"); - yco -= 20; - - /* auto renaming magic */ - uiBlockEndAlign(block); - - nb_joints = BIF_nbJointsTemplate(C); - - if (nb_joints == -1) - { - //XXX - //nb_joints = G.totvertsel; - } - - bone_name = BIF_nameBoneTemplate(C); - - BLI_snprintf(joint_label, 32, "%i joints: %s", nb_joints, bone_name); - - uiDefBut(block, LABEL, 1, joint_label, 10, yco, 200, 20, NULL, 0.0, 0.0, 0, 0, ""); - yco -= 20; - break; - } - - uiBlockEndAlign(block); -} - -#endif // XXX not used - void view3d_buttons_register(ARegionType *art) { PanelType *pt; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7dae02aba39..5dfb9cfb5b6 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1329,7 +1329,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) v3d->zbuf= FALSE; glDisable(GL_DEPTH_TEST); glEnable(GL_DITHER); - if(multisample_enabled) + if(multisample_enabled) glEnable(GL_MULTISAMPLE_ARB); if(rv3d->rflag & RV3D_CLIPPING) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 32e162fd09c..6d2a745fd67 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3547,7 +3547,7 @@ BGpic *ED_view3D_background_image_new(View3D *v3d) return bgpic; } -void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) +void ED_view3D_background_image_remove(View3D *v3d, BGpic *bgpic) { BLI_remlink(&v3d->bgpicbase, bgpic); @@ -3559,3 +3559,16 @@ void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) MEM_freeN(bgpic); } + +void ED_view3D_background_image_clear(View3D *v3d) +{ + BGpic *bgpic= v3d->bgpicbase.first; + + while(bgpic) { + BGpic *next_bgpic= bgpic->next; + + ED_view3D_background_image_remove(v3d, bgpic); + + bgpic= next_bgpic; + } +} diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 35d9aed3691..a8d88f08b48 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4740,7 +4740,7 @@ static int createSlideVerts(TransInfo *t) } look = look->next; } - } /* end uv layer loop */ + } /* end uv map loop */ } /* end uvlay_tot */ sld->uvhash = uvarray; diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index fef42866e29..1a1022a5c7f 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -164,7 +164,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha PointerRNA props_ptr; uiPopupMenu *pup; uiLayout *layout; - char line[FILE_MAXDIR + FILE_MAXFILE + 100]; + char line[FILE_MAX + 100]; pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE); layout= uiPupMenuLayout(pup); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 0f21aa3759c..0da3f66fc6f 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -219,7 +219,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac else areadiff = 1.0f-(area/uvarea); - weight_to_rgb(areadiff, col, col+1, col+2); + weight_to_rgb(col, areadiff); glColor3fv(col); glBegin(efa->v4?GL_QUADS:GL_TRIANGLES); @@ -298,19 +298,19 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac * 1.0-powf((1.0-a), 2) */ a = fabsf(uvang1-ang1)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[0]); a = fabsf(uvang2-ang2)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[1]); a = fabsf(uvang3-ang3)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[2]); a = fabsf(uvang4-ang4)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[3]); @@ -353,15 +353,15 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac glBegin(GL_TRIANGLES); a = fabsf(uvang1-ang1)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[0]); a = fabsf(uvang2-ang2)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[1]); a = fabsf(uvang3-ang3)/(float)M_PI; - weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); + weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f)); glColor3fv(col); glVertex2fv(tf->uv[2]); } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 7fc878de3f9..92bd74db68a 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -165,7 +165,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im else { /* old shading system, assign image to selected faces */ - /* ensure we have a uv layer */ + /* ensure we have a uv map */ if(!CustomData_has_layer(&em->fdata, CD_MTFACE)) { EM_add_data_layer(em, &em->fdata, CD_MTFACE, NULL); update= 1; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 11cd50a7d4e..c565e2fc305 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -896,7 +896,7 @@ static void uv_map_clip_correct(EditMesh *em, wmOperator *op) /* ******************** Unwrap operator **************** */ -/* assumes UV layer is checked, doesn't run update funcs */ +/* assumes UV Map is checked, doesn't run update funcs */ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel) { EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 01d416e46be..103255d28d1 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -78,8 +78,8 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re, int render_count) freestyle_scene->r.gauss= old_scene->r.gauss; freestyle_scene->r.dither_intensity= old_scene->r.dither_intensity; BLI_strncpy(freestyle_scene->r.engine, old_scene->r.engine, sizeof(freestyle_scene->r.engine)); - freestyle_scene->r.planes = R_PLANES32; - freestyle_scene->r.imtype = R_PNG; + freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA; + freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG; set_scene_bg( G.main, freestyle_scene ); // Camera diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index e3f979fea8f..01567b18142 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -58,21 +58,21 @@ PyObject * Vector_from_Vec2f( Vec2f& vec ) { float vec_data[2]; // because vec->_coord is protected vec_data[0] = vec.x(); vec_data[1] = vec.y(); - return newVectorObject( vec_data, 2, Py_NEW, NULL); + return Vector_CreatePyObject( vec_data, 2, Py_NEW, NULL); } PyObject * Vector_from_Vec3f( Vec3f& vec ) { float vec_data[3]; // because vec->_coord is protected vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[2] = vec.z(); - return newVectorObject( vec_data, 3, Py_NEW, NULL); + return Vector_CreatePyObject( vec_data, 3, Py_NEW, NULL); } PyObject * Vector_from_Vec3r( Vec3r& vec ) { float vec_data[3]; // because vec->_coord is protected vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[2] = vec.z(); - return newVectorObject( vec_data, 3, Py_NEW, NULL); + return Vector_CreatePyObject( vec_data, 3, Py_NEW, NULL); } PyObject * BPy_Id_from_Id( Id& id ) { diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 36a49141fb9..9360201b035 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -128,10 +128,10 @@ static PyObject *Freestyle_blendRamp( PyObject *self, PyObject *args ) a[0] = v1->x(); b[0] = v2->x(); a[1] = v1->y(); b[1] = v2->y(); a[2] = v1->z(); b[2] = v2->z(); - ramp_blend(type, &a[0], &a[1], &a[2], fac, b); + ramp_blend(type, a, fac, b); delete v1; delete v2; - return newVectorObject( a, 3, Py_NEW, NULL); + return Vector_CreatePyObject( a, 3, Py_NEW, NULL); error: if (v1) delete v1; @@ -170,7 +170,7 @@ static PyObject *Freestyle_evaluateColorRamp( PyObject *self, PyObject *args ) PyErr_SetString(PyExc_ValueError, "failed to evaluate the color ramp"); return NULL; } - return newVectorObject( out, 4, Py_NEW, NULL); + return Vector_CreatePyObject( out, 4, Py_NEW, NULL); } #include "DNA_color_types.h" diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 4488442815d..01afc0e24eb 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -31,8 +31,11 @@ set(INC ../imbuf ../makesdna ../makesrna - ../nodes # For node muting stuff... - ../nodes/intern # For node muting stuff... + + # For node muting stuff... + ../nodes + ../nodes/intern + ../../../intern/guardedalloc ../../../intern/smoke/extern ) diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 59899dc7490..5ce3d63fe86 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -74,7 +74,7 @@ typedef struct ImBuf { * but this is problematic with texture math in imagetexture.c * avoid problems and use int. - campbell */ - unsigned char depth; /* Active amount of bits/bitplanes */ + unsigned char planes; /* Active amount of bits/bitplanes */ int channels; /* amount of channels in rect_float (0 = 4 channel default) */ /* flags */ diff --git a/source/blender/imbuf/intern/IMB_filter.h b/source/blender/imbuf/intern/IMB_filter.h index a9e9e0ae776..29e6c4950df 100644 --- a/source/blender/imbuf/intern/IMB_filter.h +++ b/source/blender/imbuf/intern/IMB_filter.h @@ -40,8 +40,8 @@ struct ImBuf; void imb_filterx(struct ImBuf *ibuf); -void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h); -void IMB_premultiply_rect_float(float *rect_float, int depth, int w, int h); +void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h); +void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h); void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1); diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 9ce587aa983..62608cbbd79 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -72,8 +72,8 @@ struct anim_index_builder; typedef struct anim_index_builder { FILE * fp; - char name[FILE_MAXDIR + FILE_MAXFILE]; - char temp_name[FILE_MAXDIR + FILE_MAXFILE]; + char name[FILE_MAX]; + char temp_name[FILE_MAX]; void * private_data; diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 5bbabd84648..d08c86aacbc 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -323,7 +323,7 @@ short imb_addrectImBuf(ImBuf *ibuf) if((ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf"))) { ibuf->mall |= IB_rect; ibuf->flags |= IB_rect; - if(ibuf->depth > 32) return (addzbufImBuf(ibuf)); + if(ibuf->planes > 32) return (addzbufImBuf(ibuf)); else return TRUE; } @@ -341,7 +341,7 @@ short imb_addtilesImBuf(ImBuf *ibuf) return (ibuf->tiles != NULL); } -ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flags) +ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags) { ImBuf *ibuf; @@ -350,7 +350,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flag if(ibuf) { ibuf->x= x; ibuf->y= y; - ibuf->depth= d; + ibuf->planes= planes; ibuf->ftype= TGA; ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */ ibuf->ppm[0]= ibuf->ppm[1]= 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */ @@ -402,7 +402,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) y = ibuf1->y; if(ibuf1->flags & IB_fields) y *= 2; - ibuf2 = IMB_allocImBuf(x, y, ibuf1->depth, flags); + ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags); if(ibuf2 == NULL) return NULL; if(flags & IB_rect) diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 479c7ed5626..29da7973654 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -148,7 +148,7 @@ void IMB_filtery(struct ImBuf *ibuf) for (;x>0;x--){ if (point) { - if (ibuf->depth > 24) filtcolum(point,y,skip); + if (ibuf->planes > 24) filtcolum(point,y,skip); point++; filtcolum(point,y,skip); point++; @@ -158,7 +158,7 @@ void IMB_filtery(struct ImBuf *ibuf) point++; } if (pointf) { - if (ibuf->depth > 24) filtcolumf(pointf,y,skip); + if (ibuf->planes > 24) filtcolumf(pointf,y,skip); pointf++; filtcolumf(pointf,y,skip); pointf++; @@ -186,7 +186,7 @@ void imb_filterx(struct ImBuf *ibuf) for (;y>0;y--){ if (point) { - if (ibuf->depth > 24) filtrow(point,x); + if (ibuf->planes > 24) filtrow(point,x); point++; filtrow(point,x); point++; @@ -196,7 +196,7 @@ void imb_filterx(struct ImBuf *ibuf) point+=skip; } if (pointf) { - if (ibuf->depth > 24) filtrowf(pointf,x); + if (ibuf->planes > 24) filtrowf(pointf,x); pointf++; filtrowf(pointf,x); pointf++; @@ -529,12 +529,12 @@ ImBuf *IMB_getmipmap(ImBuf *ibuf, int level) return (level == 0)? ibuf: ibuf->mipmap[level-1]; } -void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h) +void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h) { char *cp; int x, y, val; - if(depth == 24) { /* put alpha at 255 */ + if(planes == 24) { /* put alpha at 255 */ cp= (char *)(rect); for(y=0; y<h; y++) @@ -555,12 +555,12 @@ void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h) } } -void IMB_premultiply_rect_float(float *rect_float, int depth, int w, int h) +void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h) { float val, *cp; int x, y; - if(depth==24) { /* put alpha at 1.0 */ + if(planes==24) { /* put alpha at 1.0 */ cp= rect_float; for(y=0; y<h; y++) @@ -587,9 +587,9 @@ void IMB_premultiply_alpha(ImBuf *ibuf) return; if(ibuf->rect) - IMB_premultiply_rect(ibuf->rect, ibuf->depth, ibuf->x, ibuf->y); + IMB_premultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y); if(ibuf->rect_float) - IMB_premultiply_rect_float(ibuf->rect_float, ibuf->depth, ibuf->x, ibuf->y); + IMB_premultiply_rect_float(ibuf->rect_float, ibuf->planes, ibuf->x, ibuf->y); } diff --git a/source/blender/imbuf/intern/imbuf_cocoa.m b/source/blender/imbuf/intern/imbuf_cocoa.m index 7005558d753..b79b1358ec2 100644 --- a/source/blender/imbuf/intern/imbuf_cocoa.m +++ b/source/blender/imbuf/intern/imbuf_cocoa.m @@ -228,7 +228,7 @@ short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags) /* check for a valid number of bytes per pixel. Like the PNG writer, * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding * to gray, RGB, RGBA respectively. */ - samplesperpixel = (uint16_t)((ibuf->depth + 7) >> 3); + samplesperpixel = (uint16_t)((ibuf->planes + 7) >> 3); switch (samplesperpixel) { case 4: /*RGBA type*/ hasAlpha = YES; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 9993df61089..4088cf861e7 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -457,7 +457,7 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg( struct proxy_output_ctx * rv = MEM_callocN( sizeof(struct proxy_output_ctx), "alloc_proxy_output"); - char fname[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; // JPEG requires this width = round_up(width, 8); @@ -626,8 +626,8 @@ static void free_proxy_output_ffmpeg(struct proxy_output_ctx * ctx, int rollback) { int i; - char fname[FILE_MAXDIR+FILE_MAXFILE]; - char fname_tmp[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; + char fname_tmp[FILE_MAX]; if (!ctx) { return; @@ -782,7 +782,7 @@ static int index_rebuild_ffmpeg(struct anim * anim, for (i = 0; i < num_indexers; i++) { if (tcs_in_use & tc_types[i]) { - char fname[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; get_tc_filename(anim, tc_types[i], fname); @@ -941,8 +941,8 @@ static void index_rebuild_fallback(struct anim * anim, int cnt = IMB_anim_get_duration(anim, IMB_TC_NONE); int i, pos; AviMovie * proxy_ctx[IMB_PROXY_MAX_SLOT]; - char fname[FILE_MAXDIR+FILE_MAXFILE]; - char fname_tmp[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; + char fname_tmp[FILE_MAX]; memset(proxy_ctx, 0, sizeof(proxy_ctx)); @@ -957,7 +957,7 @@ static void index_rebuild_fallback(struct anim * anim, for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) { if (proxy_sizes_in_use & proxy_sizes[i]) { - char fname[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; get_proxy_filename(anim, proxy_sizes[i], fname, TRUE); BLI_make_existing_file(fname); @@ -1086,7 +1086,7 @@ void IMB_anim_set_index_dir(struct anim * anim, const char * dir) struct anim * IMB_anim_open_proxy( struct anim * anim, IMB_Proxy_Size preview_size) { - char fname[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; int i = IMB_proxy_size_to_array_index(preview_size); if (anim->proxy_anim[i]) { @@ -1109,7 +1109,7 @@ struct anim * IMB_anim_open_proxy( struct anim_index * IMB_anim_open_index( struct anim * anim, IMB_Timecode_Type tc) { - char fname[FILE_MAXDIR+FILE_MAXFILE]; + char fname[FILE_MAX]; int i = IMB_timecode_to_array_index(tc); if (anim->curr_idx[i]) { diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index cf7337a574b..83351b5e0e4 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -320,7 +320,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) if (bpp == 1) { ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect); - if (ibuf->depth > 32) ibuf->depth = 32; + if (ibuf->planes > 32) ibuf->planes = 32; base = ibuf->rect; zbase = (unsigned int *)ibuf->zbuf; @@ -404,7 +404,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) if (bpp == 1) { ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect); - if (ibuf->depth > 32) ibuf->depth = 32; + if (ibuf->planes > 32) ibuf->planes = 32; base = ibuf->rect; zbase = (unsigned int *)ibuf->zbuf; @@ -822,7 +822,7 @@ int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags) short zsize; int ret; - zsize = (ibuf->depth + 7) >> 3; + zsize = (ibuf->planes + 7) >> 3; if (flags & IB_zbuf && ibuf->zbuf != NULL) zsize = 8; IMB_convert_rgba_to_abgr(ibuf); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 151933d6651..568dd7a9fb7 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -101,7 +101,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) int index; - int w, h, depth; + int w, h, planes; opj_dparameters_t parameters; /* decompression parameters */ @@ -166,10 +166,10 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) switch (image->numcomps) { case 1: /* Greyscale */ case 3: /* Color */ - depth= 24; + planes= 24; break; default: /* 2 or 4 - Greyscale or Color + alpha */ - depth= 32; /* greyscale + alpha */ + planes= 32; /* greyscale + alpha */ break; } @@ -190,7 +190,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) float_divs[i]= (1<<image->comps[i].prec)-1; } - ibuf= IMB_allocImBuf(w, h, depth, use_float ? IB_rectfloat : IB_rect); + ibuf= IMB_allocImBuf(w, h, planes, use_float ? IB_rectfloat : IB_rect); if (ibuf==NULL) { if(dinfo) @@ -494,7 +494,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) { /* 32bit images == alpha channel */ /* grayscale not supported yet */ - numcomps= (ibuf->depth==32) ? 4 : 3; + numcomps= (ibuf->planes==32) ? 4 : 3; } w= ibuf->x; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 89038d7d1d2..a43a8672651 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -571,9 +571,13 @@ static int init_jpeg(FILE * outfile, struct jpeg_compress_struct * cinfo, struct cinfo->image_height = ibuf->y; cinfo->in_color_space = JCS_RGB; - if (ibuf->depth == 8) cinfo->in_color_space = JCS_GRAYSCALE; - if (ibuf->depth == 32) cinfo->in_color_space = JCS_UNKNOWN; - + if (ibuf->planes == 8) cinfo->in_color_space = JCS_GRAYSCALE; +#if 0 + /* just write RGBA as RGB, + * unsupported feature only confuses other s/w */ + + if (ibuf->planes == 32) cinfo->in_color_space = JCS_UNKNOWN; +#endif switch(cinfo->in_color_space){ case JCS_RGB: cinfo->input_components = 3; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 1084355dd74..a5a9427ea89 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -208,7 +208,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags header.channels().insert ("R", Channel (HALF)); header.channels().insert ("G", Channel (HALF)); header.channels().insert ("B", Channel (HALF)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) header.channels().insert ("A", Channel (HALF)); if (write_zbuf) // z we do as float always header.channels().insert ("Z", Channel (FLOAT)); @@ -226,7 +226,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags frameBuffer.insert ("R", Slice (HALF, (char *) &pixels[0].r, xstride, ystride)); frameBuffer.insert ("G", Slice (HALF, (char *) &pixels[0].g, xstride, ystride)); frameBuffer.insert ("B", Slice (HALF, (char *) &pixels[0].b, xstride, ystride)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) frameBuffer.insert ("A", Slice (HALF, (char *) &pixels[0].a, xstride, ystride)); if (write_zbuf) frameBuffer.insert ("Z", Slice (FLOAT, (char *)(ibuf->zbuf_float + (height-1)*width), @@ -335,7 +335,7 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag header.channels().insert ("R", Channel (FLOAT)); header.channels().insert ("G", Channel (FLOAT)); header.channels().insert ("B", Channel (FLOAT)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) header.channels().insert ("A", Channel (FLOAT)); if (write_zbuf) header.channels().insert ("Z", Channel (FLOAT)); @@ -355,7 +355,7 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag frameBuffer.insert ("R", Slice (FLOAT, (char *)rect[0], xstride, ystride)); frameBuffer.insert ("G", Slice (FLOAT, (char *)rect[1], xstride, ystride)); frameBuffer.insert ("B", Slice (FLOAT, (char *)rect[2], xstride, ystride)); - if (ibuf->depth==32 && channels >= 4) + if (ibuf->planes==32 && channels >= 4) frameBuffer.insert ("A", Slice (FLOAT, (char *)rect[3], xstride, ystride)); if (write_zbuf) frameBuffer.insert ("Z", Slice (FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width), diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index be245baef21..74047ae74f5 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -117,7 +117,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) if(flags & IB_mem) name= "<memory>"; - bytesperpixel = (ibuf->depth + 7) >> 3; + bytesperpixel = (ibuf->planes + 7) >> 3; if ((bytesperpixel > 4) || (bytesperpixel == 2)) { printf("imb_savepng: Cunsupported bytes per pixel: %d for file: '%s'\n", bytesperpixel, name); return (0); diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 6519e389a21..4ee4aa218da 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -67,7 +67,7 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1) if (ibuf1->x <= 1) return(IMB_dupImBuf(ibuf1)); - ibuf2 = IMB_allocImBuf((ibuf1->x)/2, ibuf1->y, ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf((ibuf1->x)/2, ibuf1->y, ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); _p1 = (uchar *) ibuf1->rect; @@ -128,7 +128,7 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1) do_rect= (ibuf1->rect != NULL); do_float= (ibuf1->rect_float != NULL); - ibuf2 = IMB_allocImBuf(2 * ibuf1->x , ibuf1->y , ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf(2 * ibuf1->x , ibuf1->y , ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); p1 = (int *) ibuf1->rect; @@ -187,7 +187,7 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1) do_rect= (ibuf1->rect != NULL); do_float= (ibuf1->rect_float != NULL); - ibuf2 = IMB_allocImBuf(ibuf1->x , (ibuf1->y) / 2 , ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf(ibuf1->x , (ibuf1->y) / 2 , ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); _p1 = (uchar *) ibuf1->rect; @@ -255,7 +255,7 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) do_rect= (ibuf1->rect != NULL); do_float= (ibuf1->rect_float != NULL); - ibuf2 = IMB_allocImBuf(ibuf1->x , 2 * ibuf1->y , ibuf1->depth, ibuf1->flags); + ibuf2 = IMB_allocImBuf(ibuf1->x , 2 * ibuf1->y , ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); p1 = (int *) ibuf1->rect; @@ -353,7 +353,7 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1) if (ibuf1->x <= 1) return(IMB_half_y(ibuf1)); if (ibuf1->y <= 1) return(IMB_half_x(ibuf1)); - ibuf2=IMB_allocImBuf((ibuf1->x)/2, (ibuf1->y)/2, ibuf1->depth, ibuf1->flags); + ibuf2=IMB_allocImBuf((ibuf1->x)/2, (ibuf1->y)/2, ibuf1->planes, ibuf1->flags); if (ibuf2==NULL) return (NULL); imb_onehalf_no_alloc(ibuf2, ibuf1); diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 2efed56ac2c..895f922a0da 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -200,20 +200,20 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) size = ibuf->x * ibuf->y; rect = (uchar *) ibuf->rect; - if (ibuf->depth <= 8) { + if (ibuf->planes <= 8) { while(size > 0){ if (putc(*rect, file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->depth <= 16) { + } else if (ibuf->planes <= 16) { while(size > 0){ putc(rect[0], file); if (putc(rect[1], file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->depth <= 24) { + } else if (ibuf->planes <= 24) { while(size > 0){ putc(rect[2], file); putc(rect[1], file); @@ -221,7 +221,7 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) size--; rect += 4; } - } else if (ibuf->depth <= 32) { + } else if (ibuf->planes <= 32) { while(size > 0){ putc(rect[2], file); putc(rect[1], file); @@ -244,8 +244,8 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) (void)flags; /* unused */ - buf[16] = (ibuf->depth + 0x7 ) & ~0x7; - if (ibuf->depth > 8 ){ + buf[16] = (ibuf->planes + 0x7 ) & ~0x7; + if (ibuf->planes > 8 ){ buf[2] = 10; } else{ buf[2] = 11; @@ -265,7 +265,7 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) /* Don't forget to indicate that your 32 bit * targa uses 8 bits for the alpha channel! */ - if (ibuf->depth==32) { + if (ibuf->planes==32) { buf[17] |= 0x08; } fildes = fopen(name,"wb"); @@ -279,7 +279,7 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) if (ibuf->ftype == RAWTGA) { ok = dumptarga(ibuf, fildes); } else { - switch((ibuf->depth + 7) >> 3){ + switch((ibuf->planes + 7) >> 3){ case 1: ok = makebody_tga(ibuf, fildes, tga_out1); break; @@ -582,7 +582,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) size = 0; for (col = maxcol - 1; col > 0; col >>= 1) size++; - ibuf->depth = size; + ibuf->planes = size; if (tga.mapbits != 32) { /* set alpha bits */ cmap[0] &= BIG_LONG(0x00ffffffl); @@ -643,7 +643,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) cp[3] += cp[3] >> 5; cp[0] = 0xff; } - ibuf->depth = 24; + ibuf->planes = 24; } if (tga.imgtyp == 3 || tga.imgtyp == 11){ diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index ffe255ab9eb..41278e8381a 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -363,7 +363,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im IMB_metadata_change_field(img, "Thumb::Image::Height", cheight); } img->ftype = PNG; - img->depth = 32; + img->planes = 32; if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) { #ifndef WIN32 chmod(temp, S_IRUSR | S_IWUSR); diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index d9580961cf5..2051b8d2195 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -404,7 +404,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) ib_flag = IB_rect; } - tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->depth, ib_flag); + tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ib_flag); /* simple RGBA image */ if (!(bitspersample == 32 || bitspersample == 16)) { @@ -685,7 +685,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) /* check for a valid number of bytes per pixel. Like the PNG writer, * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding * to gray, RGB, RGBA respectively. */ - samplesperpixel = (uint16)((ibuf->depth + 7) >> 3); + samplesperpixel = (uint16)((ibuf->planes + 7) >> 3); if((samplesperpixel > 4) || (samplesperpixel == 2)) { fprintf(stderr, "imb_savetiff: unsupported number of bytes per " diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index d189a692083..236d6dd4732 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -186,7 +186,9 @@ typedef struct Curve { float size[3]; float rot[3]; - short texflag, pad1; /* keep a short because of give_obdata_texspace() */ + short type; /* creation-time type of curve datablock */ + + short texflag; /* keep a short because of give_obdata_texspace() */ short drawflag, twist_mode; float twist_smooth, smallcaps_scale; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index ed3d42a9da7..4abbbd7146d 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -878,7 +878,7 @@ typedef struct WeightVGEditModifierData { struct Object *mask_tex_map_obj; /* Name of the map object. */ /* How to map the texture (using MOD_DISP_MAP_* constants). */ int mask_tex_mapping; - char mask_tex_uvlayer_name[32]; /* Name of the UV layer. */ + char mask_tex_uvlayer_name[32]; /* Name of the UV map. */ /* Padding... */ int pad_i1; @@ -923,7 +923,7 @@ typedef struct WeightVGMixModifierData { struct Tex *mask_texture; /* The texture. */ struct Object *mask_tex_map_obj; /* Name of the map object. */ int mask_tex_mapping; /* How to map the texture! */ - char mask_tex_uvlayer_name[32]; /* Name of the UV layer. */ + char mask_tex_uvlayer_name[32]; /* Name of the UV map. */ /* Padding... */ int pad_i1; @@ -970,7 +970,7 @@ typedef struct WeightVGProximityModifierData { struct Tex *mask_texture; /* The texture. */ struct Object *mask_tex_map_obj; /* Name of the map object. */ int mask_tex_mapping; /* How to map the texture! */ - char mask_tex_uvlayer_name[32]; /* Name of the UV layer. */ + char mask_tex_uvlayer_name[32]; /* Name of the UV Map. */ float min_dist, max_dist; /* Distances mapping to 0.0/1.0 weights. */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 1897f8a0353..8f22b1b31cb 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -36,6 +36,7 @@ #include "DNA_vec_types.h" #include "DNA_listBase.h" #include "DNA_texture_types.h" +#include "DNA_scene_types.h" struct ID; struct ListBase; @@ -345,7 +346,7 @@ typedef struct NodeHueSat { typedef struct NodeImageFile { char name[256]; - short imtype, subimtype, quality, codec; + struct ImageFormatData im_format; int sfra, efra; } NodeImageFile; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 9be2c14a1f5..770f09780b5 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -214,13 +214,116 @@ typedef struct SceneRenderLayer { /* note, srl->passflag is treestore element 'nr' in outliner, short still... */ +/* Generic image format settings, + * this is used for NodeImageFile and IMAGE_OT_save_as operator too. + * + * note: its a bit strange that even though this is an image format struct + * the imtype can still be used to select video formats. + * RNA ensures these enum's are only selectable for render output. + */ +typedef struct ImageFormatData { + char imtype; /* R_IMF_IMTYPE_PNG, R_... */ + /* note, video types should only ever be set from this + * structure when used from RenderData */ + char depth; /* bits per channel, R_IMF_CHAN_DEPTH_8 -> 32, + * not a flag, only set 1 at a time */ + + char planes ; /* - R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA */ + char flag; /* generic options for all image types, alpha zbuffer */ + + char quality; /* (0 - 100), eg: jpeg quality */ + char compress; /* (0 - 100), eg: png compression */ + + + /* --- format specific --- */ + + /* OpenEXR */ + char exr_codec; + + /* Cineon */ + char cineon_flag; + short cineon_white, cineon_black; + float cineon_gamma; + + /* Jpeg2000 */ + char jp2_flag; + + char pad[7]; + +} ImageFormatData; + + +/* ImageFormatData.imtype */ +#define R_IMF_IMTYPE_TARGA 0 +#define R_IMF_IMTYPE_IRIS 1 +/* #define R_HAMX 2 */ /* hamx is nomore */ +/* #define R_FTYPE 3 */ /* ftype is nomore */ +#define R_IMF_IMTYPE_JPEG90 4 +/* #define R_MOVIE 5 */ /* movie is nomore */ +#define R_IMF_IMTYPE_IRIZ 7 +#define R_IMF_IMTYPE_RAWTGA 14 +#define R_IMF_IMTYPE_AVIRAW 15 +#define R_IMF_IMTYPE_AVIJPEG 16 +#define R_IMF_IMTYPE_PNG 17 +#define R_IMF_IMTYPE_AVICODEC 18 +#define R_IMF_IMTYPE_QUICKTIME 19 +#define R_IMF_IMTYPE_BMP 20 +#define R_IMF_IMTYPE_RADHDR 21 +#define R_IMF_IMTYPE_TIFF 22 +#define R_IMF_IMTYPE_OPENEXR 23 +#define R_IMF_IMTYPE_FFMPEG 24 +#define R_IMF_IMTYPE_FRAMESERVER 25 +#define R_IMF_IMTYPE_CINEON 26 +#define R_IMF_IMTYPE_DPX 27 +#define R_IMF_IMTYPE_MULTILAYER 28 +#define R_IMF_IMTYPE_DDS 29 +#define R_IMF_IMTYPE_JP2 30 +#define R_IMF_IMTYPE_H264 31 +#define R_IMF_IMTYPE_XVID 32 +#define R_IMF_IMTYPE_THEORA 33 + +#define R_IMF_IMTYPE_INVALID 255 + +/* ImageFormatData.flag */ +#define R_IMF_FLAG_ZBUF (1<<0) /* was R_OPENEXR_ZBUF */ +#define R_IMF_FLAG_PREVIEW_JPG (1<<1) /* was R_PREVIEW_JPG */ + +/* return values from BKE_imtype_valid_depths, note this is depts per channel */ +#define R_IMF_CHAN_DEPTH_1 (1<<0) /* 1bits (unused) */ +#define R_IMF_CHAN_DEPTH_8 (1<<1) /* 8bits (default) */ +#define R_IMF_CHAN_DEPTH_12 (1<<2) /* 12bits (uncommon, jp2 supports) */ +#define R_IMF_CHAN_DEPTH_16 (1<<3) /* 16bits (tiff, halff float exr) */ +#define R_IMF_CHAN_DEPTH_24 (1<<4) /* 24bits (unused) */ +#define R_IMF_CHAN_DEPTH_32 (1<<5) /* 32bits (full float exr) */ + +/* ImageFormatData.planes */ +#define R_IMF_PLANES_RGB 24 +#define R_IMF_PLANES_RGBA 32 +#define R_IMF_PLANES_BW 8 + +/* ImageFormatData.exr_codec */ +#define R_IMF_EXR_CODEC_NONE 0 +#define R_IMF_EXR_CODEC_PXR24 1 +#define R_IMF_EXR_CODEC_ZIP 2 +#define R_IMF_EXR_CODEC_PIZ 3 +#define R_IMF_EXR_CODEC_RLE 4 + +/* ImageFormatData.jp2_flag */ +#define R_IMF_JP2_FLAG_YCC (1<<0) /* when disabled use RGB */ /* was R_JPEG2K_YCC */ +#define R_IMF_JP2_FLAG_CINE_PRESET (1<<1) /* was R_JPEG2K_CINE_PRESET */ +#define R_IMF_JP2_FLAG_CINE_48 (1<<2) /* was R_JPEG2K_CINE_48FPS */ + +/* ImageFormatData.cineon_flag */ +#define R_IMF_CINEON_FLAG_LOG (1<<0) /* was R_CINEON_LOG */ + typedef struct RenderData { + struct ImageFormatData im_format; struct AviCodecData *avicodecdata; struct QuicktimeCodecData *qtcodecdata; struct QuicktimeCodecSettings qtcodecsettings; struct FFMpegCodecData ffcodecdata; - + int cfra, sfra, efra; /* frames as in 'images' */ float subframe; /* subframe offset from cfra, in 0.0-1.0 */ int psfra, pefra; /* start+end frames of preview range */ @@ -261,8 +364,8 @@ typedef struct RenderData { * The number of part to use in the y direction */ short yparts; - - short planes, imtype, subimtype, quality; + + short planes, imtype, subimtype, quality; /*deprecated!*/ /** * Render to image editor, fullscreen or to new window. @@ -375,11 +478,11 @@ typedef struct RenderData { float simplify_aosss; /* cineon */ - short cineonwhite, cineonblack; - float cineongamma; + short cineonwhite, cineonblack; /*deprecated*/ + float cineongamma; /*deprecated*/ /* jpeg2000 */ - short jp2_preset, jp2_depth; + short jp2_preset, jp2_depth; /*deprecated*/ int rpad3; /* Dome variables */ // XXX deprecated since 2.5 @@ -995,55 +1098,21 @@ typedef struct Scene { #define R_ALPHAPREMUL 1 #define R_ALPHAKEY 2 -/* planes */ -#define R_PLANES24 24 -#define R_PLANES32 32 -#define R_PLANESBW 8 - /* color_mgt_flag */ #define R_COLOR_MANAGEMENT 1 -/* imtype */ -#define R_TARGA 0 -#define R_IRIS 1 -/* #define R_HAMX 2 */ /* hamx is nomore */ -/* #define R_FTYPE 3 */ /* ftype is nomore */ -#define R_JPEG90 4 -/*#define R_MOVIE 5*/ /* movie is nomore */ -#define R_IRIZ 7 -#define R_RAWTGA 14 -#define R_AVIRAW 15 -#define R_AVIJPEG 16 -#define R_PNG 17 -#define R_AVICODEC 18 -#define R_QUICKTIME 19 -#define R_BMP 20 -#define R_RADHDR 21 -#define R_TIFF 22 -#define R_OPENEXR 23 -#define R_FFMPEG 24 -#define R_FRAMESERVER 25 -#define R_CINEON 26 -#define R_DPX 27 -#define R_MULTILAYER 28 -#define R_DDS 29 -#define R_JP2 30 -#define R_H264 31 -#define R_XVID 32 -#define R_THEORA 33 - /* subimtype, flag options for imtype */ -#define R_OPENEXR_HALF 1 -#define R_OPENEXR_ZBUF 2 -#define R_PREVIEW_JPG 4 -#define R_CINEON_LOG 8 -#define R_TIFF_16BIT 16 - -#define R_JPEG2K_12BIT 32 /* Jpeg2000 */ -#define R_JPEG2K_16BIT 64 -#define R_JPEG2K_YCC 128 /* when disabled use RGB */ -#define R_JPEG2K_CINE_PRESET 256 -#define R_JPEG2K_CINE_48FPS 512 +#define R_OPENEXR_HALF 1 /*deprecated*/ +#define R_OPENEXR_ZBUF 2 /*deprecated*/ +#define R_PREVIEW_JPG 4 /*deprecated*/ +#define R_CINEON_LOG 8 /*deprecated*/ +#define R_TIFF_16BIT 16 /*deprecated*/ + +#define R_JPEG2K_12BIT 32 /* Jpeg2000 */ /*deprecated*/ +#define R_JPEG2K_16BIT 64 /*deprecated*/ +#define R_JPEG2K_YCC 128 /* when disabled use RGB */ /*deprecated*/ +#define R_JPEG2K_CINE_PRESET 256 /*deprecated*/ +#define R_JPEG2K_CINE_48FPS 512 /*deprecated*/ /* bake_mode: same as RE_BAKE_xxx defines */ /* bake_flag: */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 0413358bee4..dfc7761bc26 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -112,8 +112,9 @@ typedef struct uiStyle { short buttonspacex; short buttonspacey; short panelspace; + short panelouter; - short pad[2]; + short pad; } uiStyle; typedef struct uiWidgetColors { diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 8e9bc7c50f0..6d96f423afb 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -150,9 +150,9 @@ static char **types, *typedata; /* at address types[a] is string a */ static short *typelens; /* at typelens[a] is de length of type a */ static short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits), infact any 64bit system */ static short **structs, *structdata;/* at sp= structs[a] is the first address of a struct definition - sp[0] is type number - sp[1] is amount of elements - sp[2] sp[3] is typenr, namenr (etc) */ + sp[0] is type number + sp[1] is amount of elements + sp[2] sp[3] is typenr, namenr (etc) */ /** * Variable to control debug output of makesdna. * debugSDNA: diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index a908833505a..b9b90ae3c88 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -259,6 +259,7 @@ extern StructRNA RNA_HookModifier; extern StructRNA RNA_ID; extern StructRNA RNA_IKParam; extern StructRNA RNA_Image; +extern StructRNA RNA_ImageFormatSettings; extern StructRNA RNA_ImagePaint; extern StructRNA RNA_ImageSequence; extern StructRNA RNA_ImageTexture; @@ -1027,8 +1028,8 @@ StructRNA *ID_code_to_RNA_type(short idcode); /* macro which inserts the function name */ #ifdef __GNUC__ # define RNA_warning(format, args...) _RNA_warning("%s: " format "\n", __func__, ##args) -#else /* MSVC doesnt support variable length args in macros */ -# define RNA_warning _RNA_warning +#else +# define RNA_warning(format, args, ...) _RNA_warning("%s: " format "\n", __FUNCTION__, __VA_ARGS__) #endif void _RNA_warning(const char *format, ...) diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index b7ac5f394b0..8e8dd559fb1 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -187,7 +187,7 @@ void RNA_def_function_ui_description(FunctionRNA *func, const char *description) /* Dynamic Enums * strings are not freed, assumed pointing to static location. */ -void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item); +void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item); void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem); void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item); void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item, int value); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 509db622b70..fb6e2544296 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -53,6 +53,7 @@ extern EnumPropertyItem boidrule_type_items[]; extern EnumPropertyItem image_type_items[]; extern EnumPropertyItem image_color_mode_items[]; +extern EnumPropertyItem image_depth_mode_items[]; extern EnumPropertyItem beztriple_keyframe_type_items[]; extern EnumPropertyItem beztriple_handle_type_items[]; diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 6785f1f4caf..18ba3936e44 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -820,8 +820,8 @@ static void rna_def_armature(BlenderRNA *brna) {ARM_WIRE, "WIRE", 0, "Wire", "Display bones as thin wires, showing subdivision and B-Splines"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_vdeformer[] = { - {ARM_VDEF_BLENDER, "BLENDER", 0, "Blender", "Uses Blender's armature vertex deformation"}, - {ARM_VDEF_BGE_CPU, "BGE_CPU", 0, "BGE", "Uses vertex deformation code optimized for the BGE"}, + {ARM_VDEF_BLENDER, "BLENDER", 0, "Blender", "Use Blender's armature vertex deformation"}, + {ARM_VDEF_BGE_CPU, "BGE_CPU", 0, "BGE", "Use vertex deformation code optimized for the BGE"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_ghost_type_items[] = { {ARM_GHOST_CUR, "CURRENT_FRAME", 0, "Around Frame", @@ -831,7 +831,7 @@ static void rna_def_armature(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem prop_pose_position_items[]= { {0, "POSE", 0, "Pose Position", "Show armature in posed state"}, - {ARM_RESTPOS, "REST", 0, "Rest Position", "Show Armature in binding pose state. No posing possible"}, + {ARM_RESTPOS, "REST", 0, "Rest Position", "Show Armature in binding pose state (no posing possible)"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Armature", "ID"); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index d4b0372d24f..60658e98c8d 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -511,14 +511,14 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_float_default(prop, 0); RNA_def_property_range(prop, -2.0f, 2.0f); RNA_def_property_ui_range(prop, -0.5f, 0.5f, 0.001, 0.001); - RNA_def_property_ui_text(prop, "Plane Offset", "Adjusts plane on which the brush acts towards or away from the object surface"); + RNA_def_property_ui_text(prop, "Plane Offset", "Adjust plane on which the brush acts towards or away from the object surface"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop= RNA_def_property(srna, "plane_trim", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "plane_trim"); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0, 1.0f); - RNA_def_property_ui_text(prop, "Plane Trim", "If a vertex is further from offset plane than this then it is not affected"); + RNA_def_property_ui_text(prop, "Plane Trim", "If a vertex is further away from offset plane than this, then it is not affected"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE); @@ -648,17 +648,17 @@ static void rna_def_brush(BlenderRNA *brna) prop= RNA_def_property(srna, "use_persistent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PERSISTENT); - RNA_def_property_ui_text(prop, "Persistent", "Sculpts on a persistent layer of the mesh"); + RNA_def_property_ui_text(prop, "Persistent", "Sculpt on a persistent layer of the mesh"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop= RNA_def_property(srna, "use_accumulate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ACCUMULATE); - RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke dabs on top of each other"); + RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke daubs on top of each other"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop= RNA_def_property(srna, "use_space_atten", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE_ATTEN); - RNA_def_property_ui_text(prop, "Use Automatic Strength Adjustment", "Automatically adjusts strength to give consistent results for different spacings"); + RNA_def_property_ui_text(prop, "Use Automatic Strength Adjustment", "Automatically adjust strength to give consistent results for different spacings"); RNA_def_property_update(prop, 0, "rna_Brush_update"); /* adaptive space is not implemented yet */ @@ -685,7 +685,7 @@ static void rna_def_brush(BlenderRNA *brna) prop= RNA_def_property(srna, "use_restore_mesh", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RESTORE_MESH); - RNA_def_property_ui_text(prop, "Restore Mesh", "Allows a single dot to be carefully positioned"); + RNA_def_property_ui_text(prop, "Restore Mesh", "Allow a single dot to be carefully positioned"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop= RNA_def_property(srna, "use_fixed_texture", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 95f44d86058..3125c2eec08 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -588,6 +588,19 @@ static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu) freeNurb(nu); /* invalidate pointer!, no can do */ + + DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); +} + +static void rna_Curve_spline_clear(Curve *cu) +{ + ListBase *nurbs= BKE_curve_nurbs(cu); + + freeNurblist(nurbs); + + DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); } static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr) @@ -1200,6 +1213,9 @@ static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop) parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + func= RNA_def_function(srna, "clear", "rna_Curve_spline_clear"); + RNA_def_function_ui_description(func, "Remove all spline from a curve"); + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL, NULL); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 48274ffbd7a..e911c936df8 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1504,7 +1504,8 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru return dp; } else { - fprintf(stderr, "%s: \"%s.%s\" not found.\n", __func__, structname, propname); + fprintf(stderr, "%s: \"%s.%s\" (identifier \"%s\") not found.\n", + __func__, structname, propname, prop->identifier); DefRNA.error= 1; return NULL; } @@ -2695,7 +2696,7 @@ int rna_parameter_size_alloc(PropertyRNA *parm) /* Dynamic Enums */ -void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item) +void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item) { EnumPropertyItem *newitems; int tot= *totitem; diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index 893993794ba..d06ab63ca8a 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -412,7 +412,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer name"); + RNA_def_property_ui_text(prop, "UV Map", "UV map name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DynamicPaint_uvlayer_set"); prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); @@ -477,7 +477,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop= RNA_def_property(srna, "use_dry_log", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DRY_LOG); - RNA_def_property_ui_text(prop, "Slow", "Use logarithmic drying (makes high values to fade faster than low values)"); + RNA_def_property_ui_text(prop, "Slow", "Use logarithmic drying (makes high values to dry faster than low values)"); prop= RNA_def_property(srna, "use_dissolve_log", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISSOLVE_LOG); @@ -551,20 +551,20 @@ static void rna_def_canvas_surface(BlenderRNA *brna) /* output for primary surface data */ prop= RNA_def_property(srna, "output_name_a", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "output_name"); - RNA_def_property_ui_text(prop, "Output name", ""); + RNA_def_property_ui_text(prop, "Output Name", "Name used to save output from this surface"); prop= RNA_def_property(srna, "use_output_a", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT1); - RNA_def_property_ui_text(prop, "Save layer", "Output name"); + RNA_def_property_ui_text(prop, "Use Output", "Save this output layer"); /* output for secondary sufrace data */ prop= RNA_def_property(srna, "output_name_b", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "output_name2"); - RNA_def_property_ui_text(prop, "Output name", "Output name"); + RNA_def_property_ui_text(prop, "Output Name", "Name used to save output from this surface"); prop= RNA_def_property(srna, "use_output_b", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2); - RNA_def_property_ui_text(prop, "Save layer", ""); + RNA_def_property_ui_text(prop, "Use Output", "Save this output layer"); prop= RNA_def_property(srna, "preview_id", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 09f339fa7db..428f56b5130 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -218,9 +218,9 @@ static void rna_def_fluidsim_slip(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem slip_items[] = { - {OB_FSBND_NOSLIP, "NOSLIP", 0, "No Slip", "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects"}, - {OB_FSBND_PARTSLIP, "PARTIALSLIP", 0, "Partial Slip", "Mix between no-slip and free-slip. Non moving objects only!"}, - {OB_FSBND_FREESLIP, "FREESLIP", 0, "Free Slip", "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!"}, + {OB_FSBND_NOSLIP, "NOSLIP", 0, "No Slip", "Obstacle causes zero normal and tangential velocity (=sticky), default for all (only option for moving objects)"}, + {OB_FSBND_PARTSLIP, "PARTIALSLIP", 0, "Partial Slip", "Mix between no-slip and free-slip (non moving objects only!)"}, + {OB_FSBND_FREESLIP, "FREESLIP", 0, "Free Slip", "Obstacle only causes zero normal velocity (=not sticky, non moving objects only!)"}, {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "slip_type", PROP_ENUM, PROP_NONE); @@ -353,7 +353,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) prop= RNA_def_property(srna, "viscosity_exponent", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "viscosityExponent"); RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Viscosity Exponent", "Negative exponent for the viscosity value (to simplify entering small values e.g. 5*10^-6.)"); + RNA_def_property_ui_text(prop, "Viscosity Exponent", "Negative exponent for the viscosity value (to simplify entering small values e.g. 5*10^-6)"); prop= RNA_def_property(srna, "grid_levels", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "maxRefine"); @@ -365,7 +365,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "gstar"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.001, 0.1); - RNA_def_property_ui_text(prop, "Compressibility", "Allowed compressibility due to gravitational force for standing fluid. (directly affects simulation step size)"); + RNA_def_property_ui_text(prop, "Compressibility", "Allowed compressibility due to gravitational force for standing fluid (directly affects simulation step size)"); /* domain boundary settings */ @@ -375,13 +375,13 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "surfaceSmoothing"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.0, 5.0); - RNA_def_property_ui_text(prop, "Surface Smoothing", "Amount of surface smoothing. A value of 0 is off, 1 is normal smoothing and more than 1 is extra smoothing"); + RNA_def_property_ui_text(prop, "Surface Smoothing", "Amount of surface smoothing (a value of 0 is off, 1 is normal smoothing and more than 1 is extra smoothing)"); prop= RNA_def_property(srna, "surface_subdivisions", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "surfaceSubdivs"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 5); - RNA_def_property_ui_text(prop, "Surface Subdivisions", "Number of isosurface subdivisions. This is necessary for the inclusion of particles into the surface generation. Warning - can lead to longer computation times!"); + RNA_def_property_ui_text(prop, "Surface Subdivisions", "Number of isosurface subdivisions (this is necessary for the inclusion of particles into the surface generation - WARNING: can lead to longer computation times !)"); prop= RNA_def_property(srna, "use_speed_vectors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "domainNovecgen", 0); @@ -435,7 +435,7 @@ static void rna_def_fluidsim_volume(StructRNA *srna) prop= RNA_def_property(srna, "use_animated_mesh", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "domainNovecgen", 0); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Export Animated Mesh", "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it"); + RNA_def_property_ui_text(prop, "Export Animated Mesh", "Export this mesh as an animated one (slower, only use if really necessary [e.g. armatures or parented objects], animated pos/rot/scale F-Curves do not require it)"); } static void rna_def_fluidsim_active(StructRNA *srna) @@ -483,7 +483,7 @@ static void rna_def_fluidsim_obstacle(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "surfaceSmoothing"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, -2.0, 10.0); - RNA_def_property_ui_text(prop, "Impact Factor", "This is an unphysical value for moving objects - it controls the impact an obstacle has on the fluid, =0 behaves a bit like outflow (deleting fluid), =1 is default, while >1 results in high forces. Can be used to tweak total mass"); + RNA_def_property_ui_text(prop, "Impact Factor", "This is an unphysical value for moving objects - it controls the impact an obstacle has on the fluid, =0 behaves a bit like outflow (deleting fluid), =1 is default, while >1 results in high forces (can be used to tweak total mass)"); } static void rna_def_fluidsim_inflow(BlenderRNA *brna) @@ -507,7 +507,7 @@ static void rna_def_fluidsim_inflow(BlenderRNA *brna) prop= RNA_def_property(srna, "use_local_coords", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSINFLOW_LOCALCOORD); - RNA_def_property_ui_text(prop, "Local Coordinates", "Use local coordinates for inflow. (e.g. for rotating objects)"); + RNA_def_property_ui_text(prop, "Local Coordinates", "Use local coordinates for inflow (e.g. for rotating objects)"); } static void rna_def_fluidsim_outflow(BlenderRNA *brna) @@ -551,7 +551,7 @@ static void rna_def_fluidsim_particle(BlenderRNA *brna) prop= RNA_def_property(srna, "alpha_influence", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "particleInfAlpha"); RNA_def_property_range(prop, 0.0, 2.0); - RNA_def_property_ui_text(prop, "Alpha Influence", "Amount of particle alpha change, inverse of size influence: 0=off (all same alpha), 1=full. (large particles get lower alphas, smaller ones higher values)"); + RNA_def_property_ui_text(prop, "Alpha Influence", "Amount of particle alpha change, inverse of size influence: 0=off (all same alpha), 1=full (large particles get lower alphas, smaller ones higher values)"); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_maxlength(prop, 240); @@ -574,12 +574,12 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "cpsTimeStart"); RNA_def_property_range(prop, 0.0, 100.0); - RNA_def_property_ui_text(prop, "Start Time", "Specifies time when the control particles are activated"); + RNA_def_property_ui_text(prop, "Start Time", "Time when the control particles are activated"); prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "cpsTimeEnd"); RNA_def_property_range(prop, 0.0, 100.0); - RNA_def_property_ui_text(prop, "End Time", "Specifies time when the control particles are deactivated"); + RNA_def_property_ui_text(prop, "End Time", "Time when the control particles are deactivated"); prop= RNA_def_property(srna, "attraction_strength", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "attractforceStrength"); @@ -589,7 +589,7 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) prop= RNA_def_property(srna, "attraction_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "attractforceRadius"); RNA_def_property_range(prop, 0.0, 10.0); - RNA_def_property_ui_text(prop, "Attraction Radius", "Specifies the force field radius around the control object"); + RNA_def_property_ui_text(prop, "Attraction Radius", "Force field radius around the control object"); prop= RNA_def_property(srna, "velocity_strength", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "velocityforceStrength"); @@ -599,13 +599,13 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) prop= RNA_def_property(srna, "velocity_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "velocityforceRadius"); RNA_def_property_range(prop, 0.0, 10.0); - RNA_def_property_ui_text(prop, "Velocity Radius", "Specifies the force field radius around the control object"); + RNA_def_property_ui_text(prop, "Velocity Radius", "Force field radius around the control object"); prop= RNA_def_property(srna, "quality", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "cpsQuality"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 5.0, 100.0); - RNA_def_property_ui_text(prop, "Quality", "Specifies the quality which is used for object sampling. (higher = better but slower)"); + RNA_def_property_ui_text(prop, "Quality", "Quality which is used for object sampling (higher = better but slower)"); prop= RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index ad6f459f851..737ce73ff1d 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -258,20 +258,20 @@ static int rna_Image_depth_get(PointerRNA *ptr) Image *im= (Image*)ptr->data; ImBuf *ibuf; void *lock; - int depth; + int planes; ibuf= BKE_image_acquire_ibuf(im, NULL, &lock); if(!ibuf) - depth= 0; + planes= 0; else if(ibuf->rect_float) - depth= ibuf->depth * 4; + planes= ibuf->planes * 4; else - depth= ibuf->depth; + planes= ibuf->planes; BKE_image_release_ibuf(im, lock); - return depth; + return planes; } static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 07271cb1aca..b28adeafbc8 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -82,14 +82,14 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports } else { /* temp swap out the color */ - const unsigned char imb_depth_back= ibuf->depth; + const unsigned char imb_planes_back= ibuf->planes; const float dither_back= ibuf->dither; - ibuf->depth= scene->r.planes; + ibuf->planes= scene->r.im_format.planes; ibuf->dither= scene->r.dither_intensity; - if (!BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) { + if (!BKE_write_ibuf(ibuf, path, &scene->r.im_format)) { BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); } - ibuf->depth= imb_depth_back; + ibuf->planes= imb_planes_back; ibuf->dither= dither_back; } @@ -103,7 +103,7 @@ static void rna_Image_save(Image *image, ReportList *reports) { ImBuf *ibuf= BKE_image_get_ibuf(image, NULL); if(ibuf) { - char filename[FILE_MAXDIR + FILE_MAXFILE]; + char filename[FILE_MAX]; BLI_strncpy(filename, image->name, sizeof(filename)); BLI_path_abs(filename, G.main->name); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 3c909d5a8fd..683bbaff32c 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -1348,7 +1348,7 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "load", "rna_Main_texts_load"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Add a new text to the main database from a file"); - parm= RNA_def_string_file_path(func, "filepath", "Path", FILE_MAXDIR + FILE_MAXFILE, "", "path for the datablock"); + parm= RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock"); @@ -1534,7 +1534,7 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "load", "rna_Main_movieclip_load"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Add a new movie clip to the main database from a file"); - parm= RNA_def_string_file_path(func, "filepath", "Path", FILE_MAXDIR + FILE_MAXFILE, "", "path for the datablock"); + parm= RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock"); RNA_def_property_flag(parm, PROP_REQUIRED); /* return type */ parm= RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip datablock"); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 57770be57eb..ce8f903bfe2 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -443,7 +443,7 @@ static void rna_def_material_mtex(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer to use for mapping with UV texture coordinates"); + RNA_def_property_ui_text(prop, "UV Map", "UV map to use for mapping with UV texture coordinates"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "use_from_dupli", PROP_BOOLEAN, PROP_NONE); @@ -1604,7 +1604,7 @@ static void rna_def_material_strand(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "strand_uvname"); - RNA_def_property_ui_text(prop, "UV Layer", "Name of UV layer to override"); + RNA_def_property_ui_text(prop, "UV Map", "Name of UV map to override"); RNA_def_property_update(prop, 0, "rna_Material_update"); } @@ -1841,13 +1841,13 @@ void RNA_def_material(BlenderRNA *brna) prop= RNA_def_property(srna, "use_face_texture", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE); RNA_def_property_ui_text(prop, "Face Textures", - "Replace the object's base color with color from face assigned image textures"); + "Replace the object's base color with color from UV map image textures"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "use_face_texture_alpha", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE_ALPHA); RNA_def_property_ui_text(prop, "Face Textures Alpha", - "Replace the object's base alpha value with alpha from face assigned image textures"); + "Replace the object's base alpha value with alpha from UV map image textures"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "use_cast_shadows_only", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 47de66dd560..c7909d2aa7d 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1417,7 +1417,7 @@ static void rna_def_mtface(BlenderRNA *brna) const int uv_dim[]= {4, 2}; srna= RNA_def_struct(brna, "MeshTextureFaceLayer", NULL); - RNA_def_struct_ui_text(srna, "Mesh Texture Face Layer", "Layer of texture faces in a Mesh datablock"); + RNA_def_struct_ui_text(srna, "Mesh UV Map", "UV map with assigned image textures in a Mesh datablock"); RNA_def_struct_sdna(srna, "CustomDataLayer"); RNA_def_struct_path_func(srna, "rna_MeshTextureFaceLayer_path"); RNA_def_struct_ui_icon(srna, ICON_GROUP_UVS); @@ -1425,25 +1425,25 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshTextureFaceLayer_name_set"); - RNA_def_property_ui_text(prop, "Name", "Name of UV unwrapping layer"); + RNA_def_property_ui_text(prop, "Name", "Name of UV map"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_get", "rna_MeshTextureFaceLayer_active_set"); - RNA_def_property_ui_text(prop, "Active", "Set the layer as active for display and editing"); + RNA_def_property_ui_text(prop, "Active", "Set the map as active for display and editing"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0); RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_render_get", "rna_MeshTextureFaceLayer_active_render_set"); - RNA_def_property_ui_text(prop, "Active Render", "Set the layer as active for rendering"); + RNA_def_property_ui_text(prop, "Active Render", "Set the map as active for rendering"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "active_clone", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "active_clone", 0); RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_clone_get", "rna_MeshTextureFaceLayer_clone_set"); - RNA_def_property_ui_text(prop, "Active Clone", "Set the layer as active for cloning"); + RNA_def_property_ui_text(prop, "Active Clone", "Set the map as active for cloning"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); @@ -1455,7 +1455,7 @@ static void rna_def_mtface(BlenderRNA *brna) srna= RNA_def_struct(brna, "MeshTextureFace", NULL); RNA_def_struct_sdna(srna, "MTFace"); - RNA_def_struct_ui_text(srna, "Mesh Texture Face", "UV mapping, texturing and game engine data for a face"); + RNA_def_struct_ui_text(srna, "Mesh UV Map Face", "UV map and image texture for a face"); RNA_def_struct_path_func(srna, "rna_MeshTextureFace_path"); RNA_def_struct_ui_icon(srna, ICON_FACESEL_HLT); @@ -1751,7 +1751,7 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) prop= RNA_def_property(srna, "active_tface", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshTextureFace"); RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_mtface_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Active Texture Face", "Active Texture Face"); + RNA_def_property_ui_text(prop, "Active UV Map Face", "Active UV Map Face"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); func= RNA_def_function(srna, "add", "ED_mesh_faces_add"); @@ -1875,12 +1875,12 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "UVTextures"); srna= RNA_def_struct(brna, "UVTextures", NULL); RNA_def_struct_sdna(srna, "Mesh"); - RNA_def_struct_ui_text(srna, "UV Textures", "Collection of uv textures"); + RNA_def_struct_ui_text(srna, "UV Maps", "Collection of UV maps"); func= RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh"); - RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name"); + RNA_def_string(func, "name", "UVMap", 0, "", "UV map name"); parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer"); RNA_def_function_return(func, parm); @@ -1895,13 +1895,13 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active UV Texture", "Active UV texture"); + RNA_def_property_ui_text(prop, "Active UV Map", "Active UV Map"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_funcs(prop, "rna_Mesh_active_uv_texture_index_get", "rna_Mesh_active_uv_texture_index_set", "rna_Mesh_active_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Active UV Texture Index", "Active UV texture index"); + RNA_def_property_ui_text(prop, "Active UV Map Index", "Active UV Map index"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); } @@ -1949,29 +1949,29 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", NULL, NULL, NULL, "rna_Mesh_uv_textures_length", NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); - RNA_def_property_ui_text(prop, "UV Textures", ""); + RNA_def_property_ui_text(prop, "UV Maps", ""); rna_def_uv_textures(brna, prop); prop= RNA_def_property(srna, "uv_texture_clone", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_clone_get", "rna_Mesh_uv_texture_clone_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Clone UV Texture", "UV texture to be used as cloning source"); + RNA_def_property_ui_text(prop, "Clone UV Map", "UV map to be used as cloning source"); prop= RNA_def_property(srna, "uv_texture_clone_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_clone_index_get", "rna_Mesh_uv_texture_clone_index_set", "rna_Mesh_active_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Clone UV Texture Index", "Clone UV texture index"); + RNA_def_property_ui_text(prop, "Clone UV Map Index", "Clone UV texture index"); prop= RNA_def_property(srna, "uv_texture_stencil", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); RNA_def_property_pointer_funcs(prop, "rna_Mesh_uv_texture_stencil_get", "rna_Mesh_uv_texture_stencil_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Mask UV Texture", "UV texture to mask the painted area"); + RNA_def_property_ui_text(prop, "Mask UV Map", "UV map to mask the painted area"); prop= RNA_def_property(srna, "uv_texture_stencil_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_funcs(prop, "rna_Mesh_uv_texture_stencil_index_get", "rna_Mesh_uv_texture_stencil_index_set", "rna_Mesh_active_uv_texture_index_range"); - RNA_def_property_ui_text(prop, "Mask UV Texture Index", "Mask UV texture index"); + RNA_def_property_ui_text(prop, "Mask UV Map Index", "Mask UV map index"); /* Vertex colors */ diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 323fb6780fb..5f948a3a243 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -147,6 +147,17 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Meta } } +static void rna_MetaBall_elements_clear(MetaBall *mb) +{ + BLI_freelistN(&mb->elems); + + /* cheating way for importers to avoid slow updates */ + if(mb->id.us > 0) { + DAG_id_tag_update(&mb->id, 0); + WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); + } +} + #else static void rna_def_metaelement(BlenderRNA *brna) @@ -234,17 +245,20 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Meta Elements", "Collection of metaball elements"); func= RNA_def_function(srna, "new", "rna_MetaBall_elements_new"); - RNA_def_function_ui_description(func, "Add a new spline to the curve"); + RNA_def_function_ui_description(func, "Add a new element to the metaball"); RNA_def_enum(func, "type", metaelem_type_items, MB_BALL, "", "type for the new meta-element"); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The newly created meta-element"); RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_MetaBall_elements_remove"); - RNA_def_function_ui_description(func, "Remove a spline from a curve"); + RNA_def_function_ui_description(func, "Remove an element from the metaball"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + func= RNA_def_function(srna, "clear", "rna_MetaBall_elements_clear"); + RNA_def_function_ui_description(func, "Remove all elements from the metaball"); + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); RNA_def_property_ui_text(prop, "Active Element", "Last selected element"); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 6885000ce18..477f3135b70 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -805,7 +805,7 @@ static void rna_def_modifier_generic_map_info(StructRNA *srna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer name"); + RNA_def_property_ui_text(prop, "UV Map", "UV map name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MappingInfo_uvlayer_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -1233,7 +1233,7 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer name"); + RNA_def_property_ui_text(prop, "UV Map", "UV map name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WaveModifier_uvlayer_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -1604,7 +1604,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer name"); + RNA_def_property_ui_text(prop, "UV Map", "UV map name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_UVProjectModifier_uvlayer_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2001,7 +2001,7 @@ static void rna_def_modifier_explode(BlenderRNA *brna) prop= RNA_def_property(srna, "particle_uv", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvname"); RNA_def_property_string_maxlength(prop, 32); - RNA_def_property_ui_text(prop, "Particle UV", "UV Layer to change with particle age"); + RNA_def_property_ui_text(prop, "Particle UV", "UV map to change with particle age"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } @@ -2571,10 +2571,10 @@ static void rna_def_modifier_screw(BlenderRNA *brna) static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) { static EnumPropertyItem weightvg_mask_tex_map_items[] = { - {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", ""}, - {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", ""}, - {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", ""}, - {MOD_DISP_MAP_UV, "UV", 0, "UV", ""}, + {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", "Use local generated coordinates"}, + {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", "Use global coordinates"}, + {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", "Use local generated coordinates of another object"}, + {MOD_DISP_MAP_UV, "UV", 0, "UV", "Use coordinates from an UV layer"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem weightvg_mask_tex_used_items[] = { @@ -2592,7 +2592,7 @@ static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "mask_constant", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Influence", "Global influence of current modifications on vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2620,7 +2620,7 @@ static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "mask_tex_uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "mask_tex_uvlayer_name"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer name"); + RNA_def_property_ui_text(prop, "UV Map", "UV map name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightVGModifier_mask_uvlayer_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2635,14 +2635,15 @@ static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) static void rna_def_modifier_weightvgedit(BlenderRNA *brna) { static EnumPropertyItem weightvg_edit_falloff_type_items[] = { - {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", ""}, + {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", "Null action"}, {MOD_WVG_MAPPING_CURVE, "CURVE", ICON_RNDCURVE, "Custom Curve", ""}, {MOD_WVG_MAPPING_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""}, {MOD_WVG_MAPPING_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""}, {MOD_WVG_MAPPING_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""}, {MOD_WVG_MAPPING_SPHERE, "ICON_SPHERECURVE", ICON_SPHERECURVE, "Sphere", ""}, {MOD_WVG_MAPPING_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""}, - {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE, "Median Step", ""}, /* Would need a better icon... */ + {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE /* Would need a better icon... */, "Median Step", + "Map all values below 0.5 to 0.0, and all others to 1.0"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; @@ -2679,7 +2680,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop= RNA_def_property(srna, "default_weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Default Weight", "Default weight a vertex will have if " "it is not in the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2692,7 +2693,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop= RNA_def_property(srna, "add_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "add_threshold"); RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Add Threshold", "Lower bound for a vertex's weight " "to be added to the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2700,7 +2701,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop= RNA_def_property(srna, "remove_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rem_threshold"); RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Rem Threshold", "Upper bound for a vertex's weight " "to be removed from the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2712,21 +2713,21 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) static void rna_def_modifier_weightvgmix(BlenderRNA *brna) { static EnumPropertyItem weightvg_mix_modes_items[] = { - {MOD_WVG_MIX_SET, "SET", 0, "Replace weights", ""}, - {MOD_WVG_MIX_ADD, "ADD", 0, "Add to weights", ""}, - {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract from weights", ""}, - {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply weights", ""}, - {MOD_WVG_MIX_DIV, "DIV", 0, "Divide weights", ""}, - {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", ""}, - {MOD_WVG_MIX_AVG, "AVG", 0, "Average", ""}, + {MOD_WVG_MIX_SET, "SET", 0, "Replace", "Replace VGroup A's weights by VGroup b's ones"}, + {MOD_WVG_MIX_ADD, "ADD", 0, "Add", "Add VGroup B's weights to VGroup A's ones"}, + {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract", "Subtract VGroup B's weights from VGroup A's ones"}, + {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply", "Multiply VGroup A's weights by VGroup B's ones"}, + {MOD_WVG_MIX_DIV, "DIV", 0, "Divide", "Divide VGroup A's weights by VGroup B's ones"}, + {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", "Difference between VGroup A's and VGroup B's weigths"}, + {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weigths"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem weightvg_mix_set_items[] = { - {MOD_WVG_SET_ALL, "ALL", 0, "All vertices", ""}, - {MOD_WVG_SET_A, "A", 0, "Vertices from group A", ""}, - {MOD_WVG_SET_B, "B", 0, "Vertices from group B", ""}, - {MOD_WVG_SET_OR, "OR", 0, "Vertices from one group", ""}, - {MOD_WVG_SET_AND, "AND", 0, "Vertices from both groups", ""}, + {MOD_WVG_SET_ALL, "ALL", 0, "All", "Affect all vertices (might add some to VGroup A)"}, + {MOD_WVG_SET_A, "A", 0, "VGroup A", "Affect vertices in VGroup A"}, + {MOD_WVG_SET_B, "B", 0, "VGroup B", "Affect vertices in VGroup B (might add some to VGroup A)"}, + {MOD_WVG_SET_OR, "OR", 0, "VGroup A or B", "Affect vertices in at least one of both VGroups (might add some to VGroup A)"}, + {MOD_WVG_SET_AND, "AND", 0, "VGroup A and B", "Affect vertices in both groups"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; @@ -2752,14 +2753,14 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna) prop= RNA_def_property(srna, "default_weight_a", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Default Weight A", "Default weight a vertex will have if " "it is not in the first vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "default_weight_b", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Default Weight B", "Default weight a vertex will have if " "it is not in the second vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2796,14 +2797,15 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem weightvg_proximity_falloff_type_items[] = { - {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", ""}, + {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", "Null action"}, /* No curve mapping here! */ {MOD_WVG_MAPPING_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""}, {MOD_WVG_MAPPING_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""}, {MOD_WVG_MAPPING_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""}, {MOD_WVG_MAPPING_SPHERE, "ICON_SPHERECURVE", ICON_SPHERECURVE, "Sphere", ""}, {MOD_WVG_MAPPING_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""}, - {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE, "Median Step", ""}, /* Would need a better icon... */ + {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE /* Would need a better icon... */, "Median Step", + "Map all values below 0.5 to 0.0, and all others to 1.0"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 30889bb25f6..af7b3303df1 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -645,6 +645,26 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNod } } +static void rna_NodeTree_node_clear(bNodeTree *ntree) +{ + bNode *node= ntree->nodes.first; + + while(node) { + bNode *next_node= node->next; + + if (node->id) + id_us_min(node->id); + + nodeFreeNode(ntree, node); + + node= next_node; + } + + ntreeUpdateTree(ntree); /* update group node socket links*/ + + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); +} + static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, bNodeSocket *in, bNodeSocket *out) { bNodeLink *ret; @@ -687,6 +707,22 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNod } } +static void rna_NodeTree_link_clear(bNodeTree *ntree) +{ + bNodeLink *link= ntree->links.first; + + while(link) { + bNodeLink *next_link= link->next; + + nodeRemLink(ntree, link); + + link= next_link; + } + ntreeUpdateTree(ntree); + + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); +} + static bNodeSocket *rna_NodeTree_input_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type) { /* XXX should check if tree is a group here! no good way to do this currently. */ @@ -1151,7 +1187,7 @@ static void def_sh_geometry(StructRNA *srna) prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_ui_text(prop, "UV Layer", ""); + RNA_def_property_ui_text(prop, "UV Map", ""); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "color_layer", PROP_STRING, PROP_NONE); @@ -1688,30 +1724,6 @@ static void def_cmp_output_file(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem type_items[] = { - {R_TARGA, "TARGA", 0, "Targa", ""}, - {R_RAWTGA, "RAW_TARGA", 0, "Targa Raw", ""}, - {R_PNG, "PNG", 0, "PNG", ""}, -#ifdef WITH_DDS - {R_DDS, "DDS", 0, "DirectDraw Surface", ""}, -#endif - {R_BMP, "BMP", 0, "BMP", ""}, - {R_JPEG90, "JPEG", 0, "JPEG", ""}, - {R_IRIS, "IRIS", 0, "IRIS", ""}, - {R_RADHDR, "RADIANCE_HDR", 0, "Radiance HDR", ""}, - {R_CINEON, "CINEON", 0, "Cineon", ""}, - {R_DPX, "DPX", 0, "DPX", ""}, - {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""}, - {0, NULL, 0, NULL, NULL}}; - - static EnumPropertyItem openexr_codec_items[] = { - {0, "NONE", 0, "None", ""}, - {1, "PXR24", 0, "Pxr24 (lossy)", ""}, - {2, "ZIP", 0, "ZIP (lossless)", ""}, - {3, "PIZ", 0, "PIZ (lossless)", ""}, - {4, "RLE", 0, "RLE (lossless)", ""}, - {0, NULL, 0, NULL, NULL}}; - RNA_def_struct_sdna_from(srna, "NodeImageFile", "storage"); prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); @@ -1719,28 +1731,11 @@ static void def_cmp_output_file(StructRNA *srna) RNA_def_property_ui_text(prop, "File Path", "Output path for the image, same functionality as render output"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "image_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "imtype"); - RNA_def_property_enum_items(prop, type_items); - RNA_def_property_ui_text(prop, "Image Type", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "use_exr_half", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_OPENEXR_HALF); - RNA_def_property_ui_text(prop, "Half", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "exr_codec", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "codec"); - RNA_def_property_enum_items(prop, openexr_codec_items); - RNA_def_property_ui_text(prop, "Codec", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "quality", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "quality"); - RNA_def_property_range(prop, 1, 100); - RNA_def_property_ui_text(prop, "Quality", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + prop= RNA_def_property(srna, "image_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "im_format"); + RNA_def_property_struct_type(prop, "ImageFormatSettings"); + RNA_def_property_ui_text(prop, "Image Format", ""); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "sfra"); @@ -2869,6 +2864,9 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "link", "NodeLink", "", "The node link to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_link_clear"); + RNA_def_function_ui_description(func, "remove all node links from the node tree"); } static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2897,6 +2895,9 @@ static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2925,6 +2926,9 @@ static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2953,6 +2957,9 @@ static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_node_socket(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6e797146f12..80563f66b17 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1156,6 +1156,16 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, b WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); } +static void rna_Object_constraints_clear(Object *object) +{ + free_constraints(&object->constraints); + + ED_object_constraint_update(object); + ED_object_constraint_set_active(object, NULL); + + WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); +} + static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, const char *name, int type) { return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); @@ -1164,6 +1174,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md) { ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); +} + +static void rna_Object_modifier_clear(Object *object, bContext *C) +{ + ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); } static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) @@ -1174,7 +1193,7 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) memcpy(values, bb->vec, sizeof(bb->vec)); } else { - fill_vn(values, sizeof(bb->vec)/sizeof(float), 0.0f); + fill_vn_fl(values, sizeof(bb->vec)/sizeof(float), 0.0f); } } @@ -1195,6 +1214,13 @@ static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); } +static void rna_Object_vgroup_clear(Object *ob) +{ + ED_vgroup_clear(ob); + + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); +} + static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len, int *index, float weight, int assignmode) { @@ -1636,6 +1662,9 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) /* constraint to remove */ parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_constraints_clear"); + RNA_def_function_ui_description(func, "Remove all constraint from this object"); } /* object.modifiers */ @@ -1684,6 +1713,11 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) /* target to remove*/ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + /* clear all modifiers */ + func= RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all modifiers from the object"); } /* object.particle_systems */ @@ -1758,6 +1792,9 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete vertex group from object"); parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_vgroup_clear"); + RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 592c3baec46..2997acd2267 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -214,21 +214,16 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Object *ob = ptr->id.data; PointCache *cache= ptr->data; - PTCacheID *pid; - ListBase pidlist; + ListBase lb; - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + while(cache->prev) + cache= cache->prev; - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) { - rna_iterator_listbase_begin(iter, pid->ptcaches, NULL); - break; - } - } + lb.first= cache; + lb.last= NULL; /* not used by listbase_begin */ - BLI_freelistN(&pidlist); + rna_iterator_listbase_begin(iter, &lb, NULL); } static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, int *max) { @@ -308,8 +303,7 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max) for(pid=pidlist.first; pid; pid=pid->next) { if(pid->cache == cache) { - if(ELEM3(pid->type, PTCACHE_TYPE_CLOTH, PTCACHE_TYPE_SMOKE_DOMAIN, PTCACHE_TYPE_SMOKE_HIGHRES)) - *max= 1; + *max= pid->max_step; break; } } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 2e62a08408f..2b26a09a646 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1287,7 +1287,7 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_ui_text(prop, "UV Layer", "UV layer to use for mapping with UV texture coordinates"); + RNA_def_property_ui_text(prop, "UV Map", "UV map to use for mapping with UV texture coordinates"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop= RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE); @@ -2717,17 +2717,17 @@ static void rna_def_particle_system(BlenderRNA *brna) prop= RNA_def_property(srna, "billboard_normal_uv", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "bb_uvname[0]"); RNA_def_property_string_maxlength(prop, 32); - RNA_def_property_ui_text(prop, "Billboard Normal UV", "UV Layer to control billboard normals"); + RNA_def_property_ui_text(prop, "Billboard Normal UV", "UV map to control billboard normals"); prop= RNA_def_property(srna, "billboard_time_index_uv", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "bb_uvname[1]"); RNA_def_property_string_maxlength(prop, 32); - RNA_def_property_ui_text(prop, "Billboard Time Index UV", "UV Layer to control billboard time index (X-Y)"); + RNA_def_property_ui_text(prop, "Billboard Time Index UV", "UV map to control billboard time index (X-Y)"); prop= RNA_def_property(srna, "billboard_split_uv", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "bb_uvname[2]"); RNA_def_property_string_maxlength(prop, 32); - RNA_def_property_ui_text(prop, "Billboard Split UV", "UV Layer to control billboard splitting"); + RNA_def_property_ui_text(prop, "Billboard Split UV", "UV map to control billboard splitting"); /* vertex groups */ diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index 3566197659c..e8ef61b6d74 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -153,7 +153,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) /* GameFloatProperty */ srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty"); - RNA_def_struct_ui_text(srna, "Game Float Property", "Game engine user defined floating pointer number property"); + RNA_def_struct_ui_text(srna, "Game Float Property", "Game engine user defined floating point number property"); RNA_def_struct_sdna(srna, "bProperty"); prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b08bdd7d223..04947c6d892 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -103,65 +103,132 @@ EnumPropertyItem snap_element_items[] = { {SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"}, {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem image_type_items[] = { - {0, "", 0, "Image", NULL}, - {R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"}, + +/* workaround for duplice enums, + * have each enum line as a defne then conditionally set it or not + */ + +#define R_IMF_ENUM_BMP {R_IMF_IMTYPE_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"}, +#define R_IMF_ENUM_IRIS {R_IMF_IMTYPE_IRIS, "IRIS", ICON_FILE_IMAGE, "Iris", "Output image in (old!) SGI IRIS format"}, +#define R_IMF_ENUM_PNG {R_IMF_IMTYPE_PNG, "PNG", ICON_FILE_IMAGE, "PNG", "Output image in PNG format"}, +#define R_IMF_ENUM_JPEG {R_IMF_IMTYPE_JPEG90, "JPEG", ICON_FILE_IMAGE, "JPEG", "Output image in JPEG format"}, +#define R_IMF_ENUM_TAGA {R_IMF_IMTYPE_TARGA, "TARGA", ICON_FILE_IMAGE, "Targa", "Output image in Targa format"}, +#define R_IMF_ENUM_TAGA_RAW {R_IMF_IMTYPE_RAWTGA, "TARGA_RAW", ICON_FILE_IMAGE, "Targa Raw", "Output image in uncompressed Targa format"}, + + #ifdef WITH_DDS - {R_DDS, "DDS", ICON_FILE_IMAGE, "DDS", "Output image in DDS format"}, +# define R_IMF_ENUM_DDS {R_IMF_IMTYPE_DDS, "DDS", ICON_FILE_IMAGE, "DDS", "Output image in DDS format"}, +#else +# define R_IMF_ENUM_DDS #endif - {R_IRIS, "IRIS", ICON_FILE_IMAGE, "Iris", "Output image in (old!) SGI IRIS format"}, - {R_PNG, "PNG", ICON_FILE_IMAGE, "PNG", "Output image in PNG format"}, - {R_JPEG90, "JPEG", ICON_FILE_IMAGE, "JPEG", "Output image in JPEG format"}, + #ifdef WITH_OPENJPEG - {R_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", "Output image in JPEG 2000 format"}, +# define R_IMF_ENUM_JPEG2K {R_IMF_IMTYPE_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", "Output image in JPEG 2000 format"}, +#else +# define R_IMF_ENUM_JPEG2K #endif - {R_TARGA, "TARGA", ICON_FILE_IMAGE, "Targa", "Output image in Targa format"}, - {R_RAWTGA, "TARGA_RAW", ICON_FILE_IMAGE, "Targa Raw", "Output image in uncompressed Targa format"}, - {0, "", 0, " ", NULL}, + #ifdef WITH_CINEON - {R_CINEON, "CINEON", ICON_FILE_IMAGE, "Cineon", "Output image in Cineon format"}, - {R_DPX, "DPX",ICON_FILE_IMAGE, "DPX", "Output image in DPX format"}, +# define R_IMF_ENUM_CINEON {R_IMF_IMTYPE_CINEON, "CINEON", ICON_FILE_IMAGE, "Cineon", "Output image in Cineon format"}, +# define R_IMF_ENUM_DPX {R_IMF_IMTYPE_DPX, "DPX",ICON_FILE_IMAGE, "DPX", "Output image in DPX format"}, +#else +# define R_IMF_ENUM_CINEON +# define R_IMF_ENUM_DPX #endif + #ifdef WITH_OPENEXR - {R_MULTILAYER, "MULTILAYER", ICON_FILE_IMAGE, "MultiLayer", "Output image in multilayer OpenEXR format"}, - {R_OPENEXR, "OPEN_EXR", ICON_FILE_IMAGE, "OpenEXR", "Output image in OpenEXR format"}, +# define R_IMF_ENUM_EXR_MULTI {R_IMF_IMTYPE_MULTILAYER, "MULTILAYER", ICON_FILE_IMAGE, "MultiLayer", "Output image in multilayer OpenEXR format"}, +# define R_IMF_ENUM_EXR {R_IMF_IMTYPE_OPENEXR, "OPEN_EXR", ICON_FILE_IMAGE, "OpenEXR", "Output image in OpenEXR format"}, +#else +# define R_IMF_ENUM_EXR_MULTI +# define R_IMF_ENUM_EXR #endif + #ifdef WITH_HDR - {R_RADHDR, "HDR", ICON_FILE_IMAGE, "Radiance HDR", "Output image in Radiance HDR format"}, +# define R_IMF_ENUM_HDR {R_IMF_IMTYPE_RADHDR, "HDR", ICON_FILE_IMAGE, "Radiance HDR", "Output image in Radiance HDR format"}, +#else +# define R_IMF_ENUM_HDR #endif + #ifdef WITH_TIFF - {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", "Output image in TIFF format"}, +# define R_IMF_ENUM_TIFF {R_IMF_IMTYPE_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", "Output image in TIFF format"}, +#else +# define R_IMF_ENUM_TIFF #endif + + +#define IMAGE_TYPE_ITEMS_IMAGE_ONLY \ + R_IMF_ENUM_BMP \ + R_IMF_ENUM_DDS \ + R_IMF_ENUM_IRIS \ + R_IMF_ENUM_PNG \ + R_IMF_ENUM_JPEG \ + R_IMF_ENUM_JPEG2K \ + R_IMF_ENUM_TAGA \ + R_IMF_ENUM_TAGA_RAW \ + {0, "", 0, " ", NULL}, \ + R_IMF_ENUM_CINEON \ + R_IMF_ENUM_DPX \ + R_IMF_ENUM_EXR_MULTI \ + R_IMF_ENUM_EXR \ + R_IMF_ENUM_HDR \ + R_IMF_ENUM_TIFF \ + + +EnumPropertyItem image_only_type_items[] = { + + IMAGE_TYPE_ITEMS_IMAGE_ONLY + + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem image_type_items[] = { + {0, "", 0, "Image", NULL}, + + IMAGE_TYPE_ITEMS_IMAGE_ONLY + {0, "", 0, "Movie", NULL}, #ifdef _WIN32 - {R_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", "Output video in AVI format"}, // XXX Missing codec menu + {R_IMF_IMTYPE_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", "Output video in AVI format"}, // XXX Missing codec menu #endif - {R_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", "Output video in AVI JPEG format"}, - {R_AVIRAW, "AVI_RAW", ICON_FILE_MOVIE, "AVI Raw", "Output video in AVI Raw format"}, + {R_IMF_IMTYPE_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", "Output video in AVI JPEG format"}, + {R_IMF_IMTYPE_AVIRAW, "AVI_RAW", ICON_FILE_MOVIE, "AVI Raw", "Output video in AVI Raw format"}, #ifdef WITH_FRAMESERVER - {R_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", "Output image to a frameserver"}, + {R_IMF_IMTYPE_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", "Output image to a frameserver"}, #endif #ifdef WITH_FFMPEG - {R_H264, "H264", ICON_FILE_MOVIE, "H.264", "Output video in H.264 format"}, - {R_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "MPEG", "Output video in MPEG format"}, - {R_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", "Output video in Ogg format"}, + {R_IMF_IMTYPE_H264, "H264", ICON_FILE_MOVIE, "H.264", "Output video in H.264 format"}, + {R_IMF_IMTYPE_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "MPEG", "Output video in MPEG format"}, + {R_IMF_IMTYPE_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", "Output video in Ogg format"}, #endif #ifdef WITH_QUICKTIME # ifdef USE_QTKIT - {R_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, + {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, # else - {R_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, + {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, # endif #endif #ifdef WITH_FFMPEG - {R_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"}, + {R_IMF_IMTYPE_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"}, #endif {0, NULL, 0, NULL, NULL}}; EnumPropertyItem image_color_mode_items[] ={ - {R_PLANESBW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, - {R_PLANES24, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, - {R_PLANES32, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, + {R_IMF_PLANES_BW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, + {R_IMF_PLANES_RGB, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, + {R_IMF_PLANES_RGBA, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, + {0, NULL, 0, NULL, NULL}}; + +#define IMAGE_COLOR_MODE_BW image_color_mode_items[0] +#define IMAGE_COLOR_MODE_RGB image_color_mode_items[1] +#define IMAGE_COLOR_MODE_RGBA image_color_mode_items[2] + +EnumPropertyItem image_color_depth_items[] = { + /* 1 (monochrome) not used */ + {R_IMF_CHAN_DEPTH_8, "8", 0, "8", "8 bit color channels"}, + {R_IMF_CHAN_DEPTH_12, "12", 0, "12", "12 bit color channels"}, + {R_IMF_CHAN_DEPTH_16, "16", 0, "16", "16 bit color channels"}, + /* 24 not used */ + {R_IMF_CHAN_DEPTH_32, "32", 0, "32", "32 bit color channels"}, {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -532,7 +599,7 @@ static int rna_RenderSettings_threads_get(PointerRNA *ptr) static int rna_RenderSettings_is_movie_fomat_get(PointerRNA *ptr) { RenderData *rd= (RenderData*)ptr->data; - return BKE_imtype_is_movie(rd->imtype); + return BKE_imtype_is_movie(rd->im_format.imtype); } static int rna_RenderSettings_save_buffers_get(PointerRNA *ptr) @@ -551,71 +618,175 @@ static int rna_RenderSettings_full_sample_get(PointerRNA *ptr) return (rd->scemode & R_FULL_SAMPLE) && !(rd->mode & R_BORDER); } -static void rna_RenderSettings_file_format_set(PointerRNA *ptr, int value) +static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) { - RenderData *rd= (RenderData*)ptr->data; + ImageFormatData *imf= (ImageFormatData *)ptr->data; + ID *id= ptr->id.data; + const char is_render= (id && GS(id->name) == ID_SCE); + /* see note below on why this is */ + const char chan_flag= BKE_imtype_valid_channels(imf->imtype) | (is_render ? IMA_CHAN_FLAG_BW : 0); + + imf->imtype= value; - rd->imtype= value; + /* ensure depth and color settings match */ + if ( ((imf->planes == R_IMF_PLANES_BW) && !(chan_flag & IMA_CHAN_FLAG_BW)) || + ((imf->planes == R_IMF_PLANES_RGBA) && !(chan_flag & IMA_CHAN_FLAG_ALPHA))) + { + imf->planes= R_IMF_PLANES_RGB; + } + + /* ensure usable depth */ + { + const int depth_ok= BKE_imtype_valid_depths(imf->imtype); + if ((imf->depth & depth_ok) == 0) { + /* set first available depth */ + char depth_ls[]= {R_IMF_CHAN_DEPTH_32, + R_IMF_CHAN_DEPTH_24, + R_IMF_CHAN_DEPTH_16, + R_IMF_CHAN_DEPTH_12, + R_IMF_CHAN_DEPTH_8, + R_IMF_CHAN_DEPTH_1, + 0}; + int i; + + for (i= 0; depth_ls[i]; i++) { + if (depth_ok & depth_ls[i]) { + imf->depth= depth_ls[i]; + break; + } + } + } + } + + if (id && GS(id->name) == ID_SCE) { + Scene *scene= ptr->id.data; + RenderData *rd= &scene->r; #ifdef WITH_FFMPEG - ffmpeg_verify_image_type(rd); + ffmpeg_verify_image_type(rd); #endif #ifdef WITH_QUICKTIME - quicktime_verify_image_type(rd); + quicktime_verify_image_type(rd); #endif + (void)rd; + } } -static int rna_SceneRender_file_ext_length(PointerRNA *ptr) +static EnumPropertyItem *rna_ImageFormatSettings_file_format_itemf(bContext *C, PointerRNA *ptr, + PropertyRNA *UNUSED(prop), int *free) { - RenderData *rd= (RenderData*)ptr->data; - char ext[8]; - ext[0]= '\0'; - BKE_add_image_extension(ext, rd->imtype); - return strlen(ext); + ID *id= ptr->id.data; + if (id && GS(id->name) == ID_SCE) { + return image_type_items; + } + else { + return image_only_type_items; + } } -static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) +static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, PointerRNA *ptr, + PropertyRNA *UNUSED(prop), int *free) { - RenderData *rd= (RenderData*)ptr->data; - str[0]= '\0'; - BKE_add_image_extension(str, rd->imtype); + ImageFormatData *imf= (ImageFormatData *)ptr->data; + ID *id= ptr->id.data; + const char is_render= (id && GS(id->name) == ID_SCE); + + /* note, we need to act differently for render + * where 'BW' will force greyscale even if the output format writes + * as RGBA, this is age old blender convention and not sure how useful + * it really is but keep it for now - campbell */ + const char chan_flag= BKE_imtype_valid_channels(imf->imtype) | (is_render ? IMA_CHAN_FLAG_BW : 0); + + if (chan_flag == (IMA_CHAN_FLAG_BW|IMA_CHAN_FLAG_RGB|IMA_CHAN_FLAG_ALPHA)) { + return image_color_mode_items; + } + else { + int totitem= 0; + EnumPropertyItem *item= NULL; + + if (chan_flag & IMA_CHAN_FLAG_BW) RNA_enum_item_add(&item, &totitem, &IMAGE_COLOR_MODE_BW); + if (chan_flag & IMA_CHAN_FLAG_RGB) RNA_enum_item_add(&item, &totitem, &IMAGE_COLOR_MODE_RGB); + if (chan_flag & IMA_CHAN_FLAG_ALPHA) RNA_enum_item_add(&item, &totitem, &IMAGE_COLOR_MODE_RGBA); + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; + } } -void rna_RenderSettings_jpeg2k_preset_update(RenderData *rd) +static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, PointerRNA *ptr, + PropertyRNA *UNUSED(prop), int *free) { - rd->subimtype &= ~(R_JPEG2K_12BIT|R_JPEG2K_16BIT | R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS); - - switch(rd->jp2_depth) { - case 8: break; - case 12: rd->subimtype |= R_JPEG2K_12BIT; break; - case 16: rd->subimtype |= R_JPEG2K_16BIT; break; + ImageFormatData *imf= (ImageFormatData *)ptr->data; + + if (imf == NULL) { + return image_color_depth_items; } - - switch(rd->jp2_preset) { - case 1: rd->subimtype |= R_JPEG2K_CINE_PRESET; break; - case 2: rd->subimtype |= R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS; break; - case 3: rd->subimtype |= R_JPEG2K_CINE_PRESET; break; - case 4: rd->subimtype |= R_JPEG2K_CINE_PRESET; break; - case 5: rd->subimtype |= R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS; break; - case 6: rd->subimtype |= R_JPEG2K_CINE_PRESET; break; - case 7: rd->subimtype |= R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS; break; + else { + const int depth_ok= BKE_imtype_valid_depths(imf->imtype); + const int is_float= ELEM3(imf->imtype, R_IMF_IMTYPE_RADHDR, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER); + + EnumPropertyItem *item_8bit= &image_color_depth_items[0]; + EnumPropertyItem *item_12bit= &image_color_depth_items[1]; + EnumPropertyItem *item_16bit= &image_color_depth_items[2]; + EnumPropertyItem *item_32bit= &image_color_depth_items[3]; + + int totitem= 0; + EnumPropertyItem *item= NULL; + EnumPropertyItem tmp = {0, "", 0, "", ""}; + + if (depth_ok & R_IMF_CHAN_DEPTH_8) { + RNA_enum_item_add(&item, &totitem, item_8bit); + } + + if (depth_ok & R_IMF_CHAN_DEPTH_12) { + RNA_enum_item_add(&item, &totitem, item_12bit); + } + + if (depth_ok & R_IMF_CHAN_DEPTH_16) { + if (is_float) { + tmp= *item_16bit; + tmp.name= "Float (Half)"; + RNA_enum_item_add(&item, &totitem, &tmp); + } + else { + RNA_enum_item_add(&item, &totitem, item_16bit); + } + } + + if (depth_ok & R_IMF_CHAN_DEPTH_32) { + if (is_float) { + tmp= *item_32bit; + tmp.name= "Float (Full)"; + RNA_enum_item_add(&item, &totitem, &tmp); + } + else { + RNA_enum_item_add(&item, &totitem, item_32bit); + } + } + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; } } -#ifdef WITH_OPENJPEG -static void rna_RenderSettings_jpeg2k_preset_set(PointerRNA *ptr, int value) +static int rna_SceneRender_file_ext_length(PointerRNA *ptr) { RenderData *rd= (RenderData*)ptr->data; - rd->jp2_preset= value; - rna_RenderSettings_jpeg2k_preset_update(rd); + char ext[8]; + ext[0]= '\0'; + BKE_add_image_extension(ext, rd->im_format.imtype); + return strlen(ext); } -static void rna_RenderSettings_jpeg2k_depth_set(PointerRNA *ptr, int value) +static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) { RenderData *rd= (RenderData*)ptr->data; - rd->jp2_depth= value; - rna_RenderSettings_jpeg2k_preset_update(rd); + str[0]= '\0'; + BKE_add_image_extension(str, rd->im_format.imtype); } -#endif #ifdef WITH_QUICKTIME static int rna_RenderSettings_qtcodecsettings_codecType_get(PointerRNA *ptr) @@ -1053,6 +1224,10 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) marker->frame= 1; BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); BLI_addtail(&scene->markers, marker); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); + return marker; } @@ -1065,6 +1240,17 @@ static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *m /* XXX, invalidates PyObject */ MEM_freeN(marker); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); +} + +static void rna_TimeLine_clear(Scene *scene) +{ + BLI_freelistN(&scene->markers); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); } static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char name[]) @@ -2684,6 +2870,138 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } +/* use for render output and image save operator, + * note: there are some cases where the members act differently when this is + * used from a scene, video formats can only be selected for render output + * for example, this is checked by seeing if the ptr->id.data is a Scene id */ + +static void rna_def_scene_image_format_data(BlenderRNA *brna) +{ +#ifdef WITH_OPENEXR + static EnumPropertyItem exr_codec_items[] = { + {R_IMF_EXR_CODEC_NONE, "NONE", 0, "None", ""}, + {R_IMF_EXR_CODEC_PXR24, "PXR24", 0, "Pxr24 (lossy)", ""}, + {R_IMF_EXR_CODEC_ZIP, "ZIP", 0, "ZIP (lossless)", ""}, + {R_IMF_EXR_CODEC_PIZ, "PIZ", 0, "PIZ (lossless)", ""}, + {R_IMF_EXR_CODEC_RLE, "RLE", 0, "RLE (lossless)", ""}, + {0, NULL, 0, NULL, NULL}}; +#endif + + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "ImageFormatSettings", NULL); + RNA_def_struct_sdna(srna, "ImageFormatData"); + RNA_def_struct_nested(brna, srna, "Scene"); + // RNA_def_struct_path_func(srna, "rna_RenderSettings_path"); // no need for the path, its not animated! + RNA_def_struct_ui_text(srna, "Image Format", "Settings for image formats"); + + prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "imtype"); + RNA_def_property_enum_items(prop, image_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_ImageFormatSettings_file_format_set", "rna_ImageFormatSettings_file_format_itemf"); + RNA_def_property_ui_text(prop, "File Format", "File format to save the rendered images as"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "planes"); + RNA_def_property_enum_items(prop, image_color_mode_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ImageFormatSettings_color_mode_itemf"); + RNA_def_property_ui_text(prop, "Color Mode", + "Choose BW for saving greyscale images, RGB for saving red, green and blue channels, " + "and RGBA for saving red, green, blue and alpha channels"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "color_depth", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "depth"); + RNA_def_property_enum_items(prop, image_color_depth_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ImageFormatSettings_color_depth_itemf"); + RNA_def_property_ui_text(prop, "Color Depth", "Bit depth per channel"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + /* was 'file_quality' */ + prop= RNA_def_property(srna, "quality", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "quality"); + RNA_def_property_range(prop, 0, 100); /* 0 is needed for compression. */ + RNA_def_property_ui_text(prop, "Quality", "Quality for image formats that support lossy compression"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + /* was shared with file_quality */ + prop= RNA_def_property(srna, "compression", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "compress"); + RNA_def_property_range(prop, 0, 100); /* 0 is needed for compression. */ + RNA_def_property_ui_text(prop, "Compression", "Compression level for formats that support lossless compression"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + /* flag */ + prop= RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", R_IMF_FLAG_ZBUF); + RNA_def_property_ui_text(prop, "Z Buffer", "Save the z-depth per pixel (32 bit unsigned int z-buffer)Save the z-depth per pixel (32 bit unsigned int z-buffer)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", R_IMF_FLAG_PREVIEW_JPG); + RNA_def_property_ui_text(prop, "Preview", "When rendering animations, save JPG preview images in same directory"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + /* format spesific */ + +#ifdef WITH_OPENEXR + /* OpenEXR */ + + prop= RNA_def_property(srna, "exr_codec", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "exr_codec"); + RNA_def_property_enum_items(prop, exr_codec_items); + RNA_def_property_ui_text(prop, "Codec", "Codec settings for OpenEXR"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + +#endif + + +#ifdef WITH_OPENJPEG + /* Jpeg 2000 */ + prop= RNA_def_property(srna, "use_jpeg2k_ycc", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "jp2_flag", R_IMF_JP2_FLAG_YCC); + RNA_def_property_ui_text(prop, "YCC", "Save luminance-chrominance-chrominance channels instead of RGB colors"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "use_jpeg2k_cinema_preset", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "jp2_flag", R_IMF_JP2_FLAG_CINE_PRESET); + RNA_def_property_ui_text(prop, "Cinema", "Use Openjpeg Cinema Preset"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "use_jpeg2k_cinema_48", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "jp2_flag", R_IMF_JP2_FLAG_CINE_48); + RNA_def_property_ui_text(prop, "Cinema (48)", "Use Openjpeg Cinema Preset (48fps)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); +#endif + + /* Cineon and DPX */ + + prop= RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_CINEON_LOG); + RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "cineon_black", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "cineon_black"); + RNA_def_property_range(prop, 0, 1024); + RNA_def_property_ui_text(prop, "B", "Log conversion reference blackpoint"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "cineon_white", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "cineon_white"); + RNA_def_property_range(prop, 0, 1024); + RNA_def_property_ui_text(prop, "W", "Log conversion reference whitepoint"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "cineon_gamma", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "cineon_gamma"); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_text(prop, "G", "Log conversion gamma"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); +} + static void rna_def_scene_render_data(BlenderRNA *brna) { StructRNA *srna; @@ -2774,35 +3092,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, "AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"}, {R_FIXED_THREADS, "FIXED", 0, "Fixed", "Manually determine the number of threads"}, {0, NULL, 0, NULL, NULL}}; - -#ifdef WITH_OPENEXR - static EnumPropertyItem exr_codec_items[] = { - {0, "NONE", 0, "None", ""}, - {1, "PXR24", 0, "Pxr24 (lossy)", ""}, - {2, "ZIP", 0, "ZIP (lossless)", ""}, - {3, "PIZ", 0, "PIZ (lossless)", ""}, - {4, "RLE", 0, "RLE (lossless)", ""}, - {0, NULL, 0, NULL, NULL}}; -#endif - -#ifdef WITH_OPENJPEG - static EnumPropertyItem jp2_preset_items[] = { - {0, "NO_PRESET", 0, "No Preset", ""}, - {1, "CINE_24FPS", 0, "Cinema 24fps 2048x1080", ""}, - {2, "CINE_48FPS", 0, "Cinema 48fps 2048x1080", ""}, - {3, "CINE_24FPS_4K", 0, "Cinema 24fps 4096x2160", ""}, - {4, "CINE_SCOPE_24FPS", 0, "Cine-Scope 24fps 2048x858", ""}, - {5, "CINE_SCOPE_48FPS", 0, "Cine-Scope 48fps 2048x858", ""}, - {6, "CINE_FLAT_24FPS", 0, "Cine-Flat 24fps 1998x1080", ""}, - {7, "CINE_FLAT_48FPS", 0, "Cine-Flat 48fps 1998x1080", ""}, - {0, NULL, 0, NULL, NULL}}; - - static EnumPropertyItem jp2_depth_items[] = { - {8, "8", 0, "8", "8 bit color channels"}, - {12, "12", 0, "12", "12 bit color channels"}, - {16, "16", 0, "16", "16 bit color channels"}, - {0, NULL, 0, NULL, NULL}}; -#endif #ifdef WITH_QUICKTIME static EnumPropertyItem quicktime_codec_type_items[] = { @@ -2898,14 +3187,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Scene"); RNA_def_struct_path_func(srna, "rna_RenderSettings_path"); RNA_def_struct_ui_text(srna, "Render Data", "Rendering settings for a Scene datablock"); - - prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "planes"); - RNA_def_property_enum_items(prop, image_color_mode_items); - RNA_def_property_ui_text(prop, "Color Mode", - "Choose BW for saving greyscale images, RGB for saving red, green and blue channels, " - "and RGBA for saving red, green, blue and alpha channels"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + /* Render Data */ + prop= RNA_def_property(srna, "image_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "im_format"); + RNA_def_property_struct_type(prop, "ImageFormatSettings"); + RNA_def_property_ui_text(prop, "Image Format", ""); prop= RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xsch"); @@ -2949,94 +3237,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect Y", "Vertical aspect ratio - for anamorphic or non-square pixel output"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); - - /* JPEG and AVI JPEG */ - - prop= RNA_def_property(srna, "file_quality", PROP_INT, PROP_PERCENTAGE); - RNA_def_property_int_sdna(prop, NULL, "quality"); - RNA_def_property_range(prop, 0, 100); /* 0 is needed for compression. */ - RNA_def_property_ui_text(prop, "Quality", "Quality of JPEG images, AVI Jpeg and SGI movies, compression for PNG's"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - /* Tiff */ - - prop= RNA_def_property(srna, "use_tiff_16bit", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_TIFF_16BIT); - RNA_def_property_ui_text(prop, "16 Bit", "Save TIFF with 16 bits per channel"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - /* Cineon and DPX */ - - prop= RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_CINEON_LOG); - RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "cineon_black", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "cineonblack"); - RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "B", "Log conversion reference blackpoint"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "cineon_white", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "cineonwhite"); - RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "W", "Log conversion reference whitepoint"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "cineon_gamma", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "cineongamma"); - RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "G", "Log conversion gamma"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - -#ifdef WITH_OPENEXR - /* OpenEXR */ - - prop= RNA_def_property(srna, "exr_codec", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "quality"); - RNA_def_property_enum_items(prop, exr_codec_items); - RNA_def_property_ui_text(prop, "Codec", "Codec settings for OpenEXR"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "use_exr_half", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_OPENEXR_HALF); - RNA_def_property_ui_text(prop, "Half", "Use 16 bit floats instead of 32 bit floats per channel"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "exr_zbuf", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_OPENEXR_ZBUF); - RNA_def_property_ui_text(prop, "Zbuf", "Save the z-depth per pixel (32 bit unsigned int z-buffer)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "exr_preview", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_PREVIEW_JPG); - RNA_def_property_ui_text(prop, "Preview", "When rendering animations, save JPG preview images in same directory"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); -#endif - -#ifdef WITH_OPENJPEG - /* Jpeg 2000 */ - - prop= RNA_def_property(srna, "jpeg2k_preset", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "jp2_preset"); - RNA_def_property_enum_items(prop, jp2_preset_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_jpeg2k_preset_set", NULL); - RNA_def_property_ui_text(prop, "Preset", "Use a DCI Standard preset for saving jpeg2000"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "jpeg2k_depth", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "jp2_depth"); - RNA_def_property_enum_items(prop, jp2_depth_items); - RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_jpeg2k_depth_set", NULL); - RNA_def_property_ui_text(prop, "Depth", "Bit depth per channel"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - - prop= RNA_def_property(srna, "jpeg2k_ycc", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_JPEG2K_YCC); - RNA_def_property_ui_text(prop, "YCC", "Save luminance-chrominance-chrominance channels instead of RGB colors"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); -#endif #ifdef WITH_QUICKTIME /* QuickTime */ @@ -3464,13 +3664,15 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "File Extensions", "Add the file format extensions to the rendered file name (eg: filename + .jpg)"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - + +#if 0 /* moved */ prop= RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "imtype"); RNA_def_property_enum_items(prop, image_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_file_format_set", NULL); RNA_def_property_ui_text(prop, "File Format", "File format to save the rendered images as"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); +#endif prop= RNA_def_property(srna, "file_extension", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_SceneRender_file_ext_get", "rna_SceneRender_file_ext_length", NULL); @@ -3855,6 +4057,9 @@ static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_TimeLine_clear"); + RNA_def_function_ui_description(func, "Remove all timeline markers"); } /* scene.keying_sets */ @@ -4251,6 +4456,7 @@ void RNA_def_scene(BlenderRNA *brna) /* Nestled Data */ rna_def_tool_settings(brna); rna_def_unit_settings(brna); + rna_def_scene_image_format_data(brna); rna_def_scene_render_data(brna); rna_def_scene_game_data(brna); rna_def_scene_render_layer(brna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 6816903090d..9d0149726c3 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -74,10 +74,10 @@ static void rna_Scene_update_tagged(Scene *scene) static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) { - if(BKE_imtype_is_movie(rd->imtype)) + if(BKE_imtype_is_movie(rd->im_format.imtype)) BKE_makeanimstring(name, rd); else - BKE_makepicstring(name, rd->pic, G.main->name, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION, TRUE); + BKE_makepicstring(name, rd->pic, G.main->name, (frame==INT_MIN) ? rd->cfra : frame, rd->im_format.imtype, rd->scemode & R_EXTENSION, TRUE); } #ifdef WITH_COLLADA diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 7e113c85bf6..d0a50ba6bad 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -339,7 +339,7 @@ static void rna_def_image_paint(BlenderRNA *brna) prop= RNA_def_property(srna, "use_stencil_layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL); - RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV layer buttons"); + RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV map buttons"); prop= RNA_def_property(srna, "invert_stencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL_INV); @@ -347,8 +347,8 @@ static void rna_def_image_paint(BlenderRNA *brna) prop= RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE); - RNA_def_property_ui_text(prop, "Clone Layer", - "Use another UV layer as clone source, otherwise use 3D the cursor as the source"); + RNA_def_property_ui_text(prop, "Clone Map", + "Use another UV map as clone source, otherwise use 3D the cursor as the source"); /* integers */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index a33622cf8a1..495a83f4bbe 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -911,6 +911,12 @@ static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic * } } +static void rna_BackgroundImage_clear(View3D *v3d) +{ + ED_view3D_background_image_clear(v3d); + WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, v3d); +} + /* Space Node Editor */ static int rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, PointerRNA value) @@ -1328,6 +1334,9 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_BackgroundImage_clear"); + RNA_def_function_ui_description(func, "Remove all background images"); } static void rna_def_space_view3d(BlenderRNA *brna) @@ -1612,9 +1621,9 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Camera Path", "Show reconstructed camera path"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); - prop= RNA_def_property(srna, "show_tracks_name", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "show_bundle_names", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_BUNDLENAME); - RNA_def_property_ui_text(prop, "Show Track Names", "Show names for tracks objects"); + RNA_def_property_ui_text(prop, "Show 3D Marker Names", "Show names for reconstructed tracks objects"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); /* region */ @@ -2915,7 +2924,7 @@ static void rna_def_space_clip(BlenderRNA *brna) /* show bundles */ prop= RNA_def_property(srna, "show_bundles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, "Show Bundles", "Show projection of bundles into footage"); + RNA_def_property_ui_text(prop, "Show Bundles", "Show projection of 3D markers into footage"); RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_BUNDLES); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index f1a6bb1b921..88ea78cd0da 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -49,7 +49,7 @@ void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const cha scene = CTX_data_scene(C); } - RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.imtype, layout); + RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout); } void clear_envmap(struct EnvMap *env, bContext *C) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 269860e1d7e..eb3512083aa 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -702,7 +702,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Scale Influence", "Influence of stabilization algorithm on footage scale"); RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate"); - /* use_stabilize_rotation */ + /* use_stabilize_rotation */ prop= RNA_def_property(srna, "use_stabilize_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_STABILIZE_ROTATION); RNA_def_property_ui_text(prop, "Stabilize Rotation", "Stabilize horizon line on the shot"); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 4c97a926513..96667c95042 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -397,6 +397,11 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); RNA_def_boolean(func, "compact", 0, "", "Use more compact layout"); + func= RNA_def_function(srna, "template_image_settings", "uiTemplateImageSettings"); + RNA_def_function_ui_description(func, "User interface for setting image format options"); + parm= RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); + func= RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip"); RNA_def_function_ui_description(func, "Item(s). User interface for selecting movie clips and their source paths"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index ad2b49e5d41..418e9120458 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2646,7 +2646,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"}, {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, - /*{25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"},*/ + {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"}, /* using the utf8 flipped form of Persian (فارسی) */ {26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_PE"}, {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 34c8c4cc1b1..8696bd12502 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -102,7 +102,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) // fluid/inflow settings // fss->iniVel --> automatically set to 0 - modifier_path_init(fss->surfdataPath, sizeof(fss->surfdataPath), "fluid_cache"); + modifier_path_init(fss->surfdataPath, sizeof(fss->surfdataPath), "cache_fluid"); // first init of bounding box // no bounding box needed @@ -447,7 +447,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim { int displaymode = 0; int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */ - char targetFile[FILE_MAXFILE+FILE_MAXDIR]; + char targetFile[FILE_MAX]; FluidsimSettings *fss = fluidmd->fss; DerivedMesh *dm = NULL; MFace *mface; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 3ba49f26449..f79ee0ca5fb 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -78,10 +78,10 @@ static void init_ocean_modifier(struct OceanModifierData *omd) BKE_free_ocean_data(omd->ocean); BKE_init_ocean(omd->ocean, omd->resolution*omd->resolution, omd->resolution*omd->resolution, omd->spatial_size, omd->spatial_size, - omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, - omd->depth, omd->time, - do_heightfield, do_chop, do_normals, do_jacobian, - omd->seed); + omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, + omd->depth, omd->time, + do_heightfield, do_chop, do_normals, do_jacobian, + omd->seed); } static void simulate_ocean_modifier(struct OceanModifierData *omd) @@ -90,7 +90,7 @@ static void simulate_ocean_modifier(struct OceanModifierData *omd) BKE_simulate_ocean(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount); } -#endif // WITH_OCEANSIM +#endif /* WITH_OCEANSIM */ @@ -127,7 +127,7 @@ static void initData(ModifierData *md) omd->repeat_x = 1; omd->repeat_y = 1; - modifier_path_init(omd->cachepath, sizeof(omd->cachepath), "ocean_cache"); + modifier_path_init(omd->cachepath, sizeof(omd->cachepath), "cache_ocean"); omd->cached = 0; omd->bakestart = 1; @@ -261,22 +261,16 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa #endif #ifdef WITH_OCEANSIM -MINLINE float ocean_co(OceanModifierData *omd, float v) -{ - //float scale = 1.0 / (omd->size * omd->spatial_size); - //*v = (*v * scale) + 0.5; - return (v / (omd->size * omd->spatial_size)) + 0.5f; -} #define OMP_MIN_RES 18 static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) { DerivedMesh *result; - MVert *mv; - MFace *mf; - MTFace *tf; + MVert *mverts; + MFace *mfaces; + int *origindex; int cdlayer; @@ -303,17 +297,19 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) result = CDDM_new(num_verts, num_edges, num_faces); - mv = CDDM_get_verts(result); - mf = CDDM_get_faces(result); + mverts = CDDM_get_verts(result); + mfaces = CDDM_get_faces(result); + origindex= result->getFaceDataArray(result, CD_ORIGINDEX); /* create vertices */ #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) for (y=0; y < res_y+1; y++) { for (x=0; x < res_x+1; x++) { const int i = y*(res_x+1) + x; - mv[i].co[0] = ox + (x * sx); - mv[i].co[1] = oy + (y * sy); - mv[i].co[2] = 0; + float *co= mverts[i].co; + co[0] = ox + (x * sx); + co[1] = oy + (y * sy); + co[2] = 0; } } @@ -323,12 +319,16 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) for (x=0; x < res_x; x++) { const int fi = y*res_x + x; const int vi = y*(res_x+1) + x; - mf[fi].v1 = vi; - mf[fi].v2 = vi + 1; - mf[fi].v3 = vi + 1 + res_x+1; - mf[fi].v4 = vi + res_x+1; + MFace *mf= &mfaces[fi]; + mf->v1 = vi; + mf->v2 = vi + 1; + mf->v3 = vi + 1 + res_x+1; + mf->v4 = vi + res_x+1; - mf[fi].flag |= ME_SMOOTH; + mf->flag |= ME_SMOOTH; + + /* generated geometry does not map to original faces */ + origindex[fi] = ORIGINDEX_NONE; } } @@ -336,28 +336,29 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) /* add uvs */ cdlayer= CustomData_number_of_layers(&result->faceData, CD_MTFACE); - if(cdlayer >= MAX_MTFACE) - return result; - CustomData_add_layer(&result->faceData, CD_MTFACE, CD_CALLOC, NULL, num_faces); - tf = CustomData_get_layer(&result->faceData, CD_MTFACE); - - ix = 1.0 / rx; - iy = 1.0 / ry; - #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y; y++) { - for (x=0; x < res_x; x++) { - const int i = y*res_x + x; - tf[i].uv[0][0] = x * ix; - tf[i].uv[0][1] = y * iy; - - tf[i].uv[1][0] = (x+1) * ix; - tf[i].uv[1][1] = y * iy; - - tf[i].uv[2][0] = (x+1) * ix; - tf[i].uv[2][1] = (y+1) * iy; - - tf[i].uv[3][0] = x * ix; - tf[i].uv[3][1] = (y+1) * iy; + if(cdlayer < MAX_MTFACE) { + MTFace *tfaces= CustomData_add_layer(&result->faceData, CD_MTFACE, CD_CALLOC, NULL, num_faces); + + if (tfaces) { /* unlikely to fail */ + ix = 1.0 / rx; + iy = 1.0 / ry; + #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) + for (y=0; y < res_y; y++) { + for (x=0; x < res_x; x++) { + const int i = y*res_x + x; + tfaces[i].uv[0][0] = x * ix; + tfaces[i].uv[0][1] = y * iy; + + tfaces[i].uv[1][0] = (x+1) * ix; + tfaces[i].uv[1][1] = y * iy; + + tfaces[i].uv[2][0] = (x+1) * ix; + tfaces[i].uv[2][1] = (y+1) * iy; + + tfaces[i].uv[3][0] = x * ix; + tfaces[i].uv[3][1] = (y+1) * iy; + } + } } } @@ -373,10 +374,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, DerivedMesh *dm=NULL; OceanResult ocr; - MVert *mv; - MFace *mf; - - int cdlayer; + MVert *mverts, *mv; int i, j; @@ -385,6 +383,14 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, int cfra; + /* use cached & inverted value for speed + * expanded this would read... + * + * (axis / (omd->size * omd->spatial_size)) + 0.5f) */ +#define OCEAN_CO(_size_co_inv, _v) ((_v * _size_co_inv) + 0.5f) + + const float size_co_inv= 1.0f / (omd->size * omd->spatial_size); + /* update modifier */ if (omd->refresh & MOD_OCEAN_REFRESH_ADD) omd->ocean = BKE_add_ocean(); @@ -399,7 +405,8 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, if (omd->cached == TRUE) { if (!omd->oceancache) init_cache_data(ob, omd); BKE_simulate_ocean_cache(omd->oceancache, md->scene->r.cfra); - } else { + } + else { simulate_ocean_modifier(omd); } @@ -416,62 +423,45 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, num_verts = dm->getNumVerts(dm); num_faces = dm->getNumFaces(dm); + mverts = dm->getVertArray(dm); + /* add vcols before displacement - allows lookup based on position */ if (omd->flag & MOD_OCEAN_GENERATE_FOAM) { - MCol *mc; - float foam; - char cf; - - float u=0.0, v=0.0; - - cdlayer= CustomData_number_of_layers(&dm->faceData, CD_MCOL); - if(cdlayer >= MAX_MCOL) - return dm; - - CustomData_add_layer_named(&dm->faceData, CD_MCOL, CD_CALLOC, NULL, num_faces, omd->foamlayername); - - mc = dm->getFaceDataArray(dm, CD_MCOL); - mv = dm->getVertArray(dm); - mf = dm->getFaceArray(dm); - - for (i = 0; i < num_faces; i++, mf++) { - for (j=0; j<4; j++) { - - if (j == 3 && !mf->v4) continue; - - switch(j) { - case 0: - u = ocean_co(omd, mv[mf->v1].co[0]); - v = ocean_co(omd, mv[mf->v1].co[1]); - break; - case 1: - u = ocean_co(omd, mv[mf->v2].co[0]); - v = ocean_co(omd, mv[mf->v2].co[1]); - break; - case 2: - u = ocean_co(omd, mv[mf->v3].co[0]); - v = ocean_co(omd, mv[mf->v3].co[1]); - break; - case 3: - u = ocean_co(omd, mv[mf->v4].co[0]); - v = ocean_co(omd, mv[mf->v4].co[1]); - - break; - } - - if (omd->oceancache && omd->cached==TRUE) { - BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); - foam = ocr.foam; - CLAMP(foam, 0.0f, 1.0f); - } else { - BKE_ocean_eval_uv(omd->ocean, &ocr, u, v); - foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage); + int cdlayer= CustomData_number_of_layers(&dm->faceData, CD_MCOL); + + if(cdlayer < MAX_MCOL) { + MCol *mcols= CustomData_add_layer_named(&dm->faceData, CD_MCOL, CD_CALLOC, NULL, num_faces, omd->foamlayername); + + if (mcols) { /* unlikely to fail */ + MCol *mc; + MFace *mfaces= dm->getFaceArray(dm); + MFace *mf; + + float foam; + + for (i = 0, mf= mfaces; i < num_faces; i++, mf++) { + j= mf->v4 ? 3 : 2; + do { + const float *co= mverts[*(&mf->v1 + j)].co; + const float u = OCEAN_CO(size_co_inv, co[0]); + const float v = OCEAN_CO(size_co_inv, co[1]); + + if (omd->oceancache && omd->cached==TRUE) { + BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); + foam = ocr.foam; + CLAMP(foam, 0.0f, 1.0f); + } + else { + BKE_ocean_eval_uv(omd->ocean, &ocr, u, v); + foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage); + } + + mc= &mcols[i*4 + j]; + mc->r = mc->g = mc->b = (char)(foam * 255); + /* mc->a = 255; */ /* no need to set */ + } while (j--); } - - cf = (char)(foam*255); - mc[i*4 + j].r = mc[i*4 + j].g = mc[i*4 + j].b = cf; - mc[i*4 + j].a = 255; } } } @@ -479,26 +469,25 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, /* displace the geometry */ - mv = dm->getVertArray(dm); - //#pragma omp parallel for private(i, ocr) if (omd->resolution > OMP_MIN_RES) - for (i=0; i< num_verts; i++) { - const float u = ocean_co(omd, mv[i].co[0]); - const float v = ocean_co(omd, mv[i].co[1]); + for (i=0, mv= mverts; i< num_verts; i++, mv++) { + const float u = OCEAN_CO(size_co_inv, mv->co[0]); + const float v = OCEAN_CO(size_co_inv, mv->co[1]); if (omd->oceancache && omd->cached==TRUE) BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); else BKE_ocean_eval_uv(omd->ocean, &ocr, u, v); - mv[i].co[2] += ocr.disp[1]; + mv->co[2] += ocr.disp[1]; if (omd->chop_amount > 0.0f) { - mv[i].co[0] += ocr.disp[0]; - mv[i].co[1] += ocr.disp[2]; + mv->co[0] += ocr.disp[0]; + mv->co[1] += ocr.disp[2]; } } + #undef OCEAN_CO return dm; } diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index e3abc16f98f..584aa6dc206 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -170,7 +170,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if(num_projectors == 0) return dm; - /* make sure there are UV layers available */ + /* make sure there are UV Maps available */ if(!CustomData_has_layer(&dm->faceData, CD_MTFACE)) return dm; @@ -259,7 +259,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); } - /* make sure we are not modifying the original UV layer */ + /* make sure we are not modifying the original UV map */ tface = CustomData_duplicate_referenced_layer_named(&dm->faceData, CD_MTFACE, uvname); diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 8effe4d7c1b..a30c5da07c8 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -466,6 +466,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (use_trgt_verts || use_trgt_edges || use_trgt_faces) { DerivedMesh *target_dm = obr->derivedFinal; + short free_target_dm = FALSE; if (!target_dm) { if (ELEM3(obr->type, OB_CURVE, OB_SURF, OB_FONT)) target_dm = CDDM_from_curve(obr); @@ -476,6 +477,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der else target_dm = CDDM_from_mesh(me, obr); } + free_target_dm = TRUE; } /* We must check that we do have a valid target_dm! */ @@ -495,6 +497,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if(dists_f) new_w[i] = minf(dists_f[i], new_w[i]); } + if(free_target_dm) target_dm->release(target_dm); if(dists_v) MEM_freeN(dists_v); if(dists_e) MEM_freeN(dists_e); if(dists_f) MEM_freeN(dists_f); diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index 4a303e911e2..0296fa417d6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -49,9 +49,9 @@ static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *f copy_v3_v3(col, in1); if(node->custom2) - ramp_blend(node->custom1, col, col+1, col+2, in2[3]*fac[0], in2); + ramp_blend(node->custom1, col, in2[3]*fac[0], in2); else - ramp_blend(node->custom1, col, col+1, col+2, fac[0], in2); + ramp_blend(node->custom1, col, fac[0], in2); copy_v3_v3(out, col); out[3]= in1[3]; } diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index b2177002e82..50a196deb07 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -70,14 +70,14 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack * if(in[1]->data) { CompBuf *zbuf= in[1]->data; if(zbuf->type==CB_VAL && zbuf->x==cbuf->x && zbuf->y==cbuf->y) { - nif->subimtype|= R_OPENEXR_ZBUF; + nif->im_format.flag |= R_IMF_FLAG_ZBUF; ibuf->zbuf_float= zbuf->rect; } } - BKE_makepicstring(string, nif->name, bmain->name, rd->cfra, nif->imtype, (rd->scemode & R_EXTENSION), TRUE); + BKE_makepicstring(string, nif->name, bmain->name, rd->cfra, nif->im_format.imtype, (rd->scemode & R_EXTENSION), TRUE); - if(0 == BKE_write_ibuf(ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality)) + if(0 == BKE_write_ibuf(ibuf, string, &nif->im_format)) printf("Cannot save Node File Output to %s\n", string); else printf("Saved: %s\n", string); @@ -100,9 +100,10 @@ static void node_composit_init_output_file(bNodeTree *UNUSED(ntree), bNode* node if(scene) { BLI_strncpy(nif->name, scene->r.pic, sizeof(nif->name)); - nif->imtype= scene->r.imtype; - nif->subimtype= scene->r.subimtype; - nif->quality= scene->r.quality; + nif->im_format= scene->r.im_format; + if (BKE_imtype_is_movie(nif->im_format.imtype)) { + nif->im_format.imtype= R_IMF_IMTYPE_OPENEXR; + } nif->sfra= scene->r.sfra; nif->efra= scene->r.efra; } diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index 2b28eae4085..cf6f400ee2a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -61,7 +61,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i int i; if(ngeo->uvname[0]) { - /* find uv layer by name */ + /* find uv map by name */ for(i = 0; i < shi->totuv; i++) { if(strcmp(shi->uv[i].name, ngeo->uvname)==0) { suv= &shi->uv[i]; diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index e7350612b5b..4a740a2cfdd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -58,7 +58,7 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), bNode *node, bNodeStack nodestack_get_vec(col, SOCK_VECTOR, in[1]); nodestack_get_vec(vec, SOCK_VECTOR, in[2]); - ramp_blend(node->custom1, col, col+1, col+2, fac, vec); + ramp_blend(node->custom1, col, fac, vec); copy_v3_v3(out[0]->vec, col); } diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index b4b25a10537..9e76309bce9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -110,7 +110,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor copy_v4_v4( out, mortar ); } else { copy_v4_v4( out, bricks1 ); - ramp_blend( MA_RAMP_BLEND, out, out+1, out+2, tint, bricks2 ); + ramp_blend( MA_RAMP_BLEND, out, tint, bricks2 ); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c index 13816088ea7..41115076ec1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c @@ -56,7 +56,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor CLAMP(fac, 0.0f, 1.0f); copy_v4_v4(out, col1); - ramp_blend(node->custom1, out, out+1, out+2, fac, col2); + ramp_blend(node->custom1, out, fac, col2); } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index fac8b02fb85..efc8228c01c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -79,7 +79,7 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char } else { copy_v4_v4(result, col1); - ramp_blend(MA_RAMP_BLEND, result, result+1, result+2, texres.tin, col2); + ramp_blend(MA_RAMP_BLEND, result, texres.tin, col2); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 3a0f11d5417..d408b874b84 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -85,7 +85,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor } else { copy_v4_v4(out, col1); - ramp_blend(MA_RAMP_BLEND, out, out+1, out+2, texres.tin, col2); + ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2); } } } diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 7fbd8baa558..8d68a407e62 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -385,8 +385,12 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) if (PyBytes_Check(py_str)) { return PyBytes_AS_STRING(py_str); } + else if ((*coerce= PyUnicode_EncodeFSDefault(py_str))) { + return PyBytes_AS_STRING(*coerce); + } else { - return PyBytes_AS_STRING((*coerce= PyUnicode_EncodeFSDefault(py_str))); + /* leave error raised from EncodeFS */ + return NULL; } } } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 7dee2ce6fb4..b7ead49633c 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -200,7 +200,7 @@ void BPY_python_start(int argc, const char **argv) PyThreadState *py_tstate= NULL; /* not essential but nice to set our name */ - static wchar_t program_path_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */ + static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */ BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t)); Py_SetProgramName(program_path_wchar); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 3bde38d1445..9b42335dfe5 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -619,11 +619,11 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_ALL_VECTOR_SUBTYPES: if (len>=2 && len <= 4) { if (is_thick) { - ret= newVectorObject(NULL, len, Py_NEW, NULL); + ret= Vector_CreatePyObject(NULL, len, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((VectorObject *)ret)->vec); } else { - PyObject *vec_cb= newVectorObject_cb(ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC); + PyObject *vec_cb= Vector_CreatePyObject_cb(ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC); Py_DECREF(ret); /* the vector owns now */ ret= vec_cb; /* return the vector instead */ } @@ -632,22 +632,22 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_MATRIX: if (len==16) { if (is_thick) { - ret= newMatrixObject(NULL, 4, 4, Py_NEW, NULL); + ret= Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr); } else { - PyObject *mat_cb= newMatrixObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE); + PyObject *mat_cb= Matrix_CreatePyObject_cb(ret, 4,4, mathutils_rna_matrix_cb_index, FALSE); Py_DECREF(ret); /* the matrix owns now */ ret= mat_cb; /* return the matrix instead */ } } else if (len==9) { if (is_thick) { - ret= newMatrixObject(NULL, 3, 3, Py_NEW, NULL); + ret= Matrix_CreatePyObject(NULL, 3, 3, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((MatrixObject *)ret)->contigPtr); } else { - PyObject *mat_cb= newMatrixObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE); + PyObject *mat_cb= Matrix_CreatePyObject_cb(ret, 3,3, mathutils_rna_matrix_cb_index, FALSE); Py_DECREF(ret); /* the matrix owns now */ ret= mat_cb; /* return the matrix instead */ } @@ -661,23 +661,23 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) PropertyRNA *prop_eul_order= NULL; short order= pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ); - ret= newEulerObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA + ret= Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul); } else { /* order will be updated from callback on use */ - PyObject *eul_cb= newEulerObject_cb(ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA + PyObject *eul_cb= Euler_CreatePyObject_cb(ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL); // TODO, get order from RNA Py_DECREF(ret); /* the euler owns now */ ret= eul_cb; /* return the euler instead */ } } else if (len==4) { if (is_thick) { - ret= newQuaternionObject(NULL, Py_NEW, NULL); + ret= Quaternion_CreatePyObject(NULL, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((QuaternionObject *)ret)->quat); } else { - PyObject *quat_cb= newQuaternionObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT); + PyObject *quat_cb= Quaternion_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT); Py_DECREF(ret); /* the quat owns now */ ret= quat_cb; /* return the quat instead */ } @@ -687,11 +687,11 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_COLOR_GAMMA: if (len==3) { /* color */ if (is_thick) { - ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA + ret= Color_CreatePyObject(NULL, Py_NEW, NULL); // TODO, get order from RNA RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col); } else { - PyObject *col_cb= newColorObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR); + PyObject *col_cb= Color_CreatePyObject_cb(ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR); Py_DECREF(ret); /* the color owns now */ ret= col_cb; /* return the color instead */ } @@ -4543,15 +4543,15 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat switch(RNA_property_subtype(prop)) { #ifdef USE_MATHUTILS case PROP_ALL_VECTOR_SUBTYPES: - ret= newVectorObject(data, len, Py_NEW, NULL); + ret= Vector_CreatePyObject(data, len, Py_NEW, NULL); break; case PROP_MATRIX: if (len==16) { - ret= newMatrixObject(data, 4, 4, Py_NEW, NULL); + ret= Matrix_CreatePyObject(data, 4, 4, Py_NEW, NULL); break; } else if (len==9) { - ret= newMatrixObject(data, 3, 3, Py_NEW, NULL); + ret= Matrix_CreatePyObject(data, 3, 3, Py_NEW, NULL); break; } /* pass through */ @@ -6376,10 +6376,14 @@ static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict) if ((order= PyDict_GetItem(class_dict, bpy_intern_str_order)) && PyList_CheckExact(order)) { for (pos= 0; pos<PyList_GET_SIZE(order); pos++) { key= PyList_GET_ITEM(order, pos); - item= PyDict_GetItem(class_dict, key); - ret= deferred_register_prop(srna, key, item); - if (ret != 0) - break; + /* however unlikely its possible + * fails in py 3.3 beta with __qualname__ */ + if ((item= PyDict_GetItem(class_dict, key))) { + ret= deferred_register_prop(srna, key, item); + if (ret != 0) { + break; + } + } } } else { diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 79628cf5ae9..8409344a9fe 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -61,7 +61,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) "more then a single arg given"); return NULL; } - return newColorObject(col, Py_NEW, type); + return Color_CreatePyObject(col, Py_NEW, type); } //-----------------------------METHODS---------------------------- @@ -104,7 +104,7 @@ static PyObject *Color_copy(ColorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newColorObject(self->col, Py_NEW, Py_TYPE(self)); + return Color_CreatePyObject(self->col, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- @@ -384,7 +384,7 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) add_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE); - return newColorObject(col, Py_NEW, Py_TYPE(v1)); + return Color_CreatePyObject(col, Py_NEW, Py_TYPE(v1)); } /* addition in-place: obj += obj */ @@ -433,7 +433,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) sub_vn_vnvn(col, color1->col, color2->col, COLOR_SIZE); - return newColorObject(col, Py_NEW, Py_TYPE(v1)); + return Color_CreatePyObject(col, Py_NEW, Py_TYPE(v1)); } /* subtraction in-place: obj -= obj */ @@ -465,7 +465,7 @@ static PyObject *color_mul_float(ColorObject *color, const float scalar) { float tcol[COLOR_SIZE]; mul_vn_vn_fl(tcol, color->col, COLOR_SIZE, scalar); - return newColorObject(tcol, Py_NEW, Py_TYPE(color)); + return Color_CreatePyObject(tcol, Py_NEW, Py_TYPE(color)); } @@ -612,7 +612,7 @@ static PyObject *Color_neg(ColorObject *self) return NULL; negate_vn_vn(tcol, self->col, COLOR_SIZE); - return newColorObject(tcol, Py_NEW, Py_TYPE(self)); + return Color_CreatePyObject(tcol, Py_NEW, Py_TYPE(self)); } @@ -821,13 +821,13 @@ PyTypeObject color_Type = { NULL, //tp_weaklist NULL //tp_del }; -//------------------------newColorObject (internal)------------- +//------------------------Color_CreatePyObject (internal)------------- //creates a new color object /*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER (i.e. it was allocated elsewhere by MEM_mallocN()) pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON (i.e. it must be created here with PyMEM_malloc())*/ -PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) +PyObject *Color_CreatePyObject(float *col, int type, PyTypeObject *base_type) { ColorObject *self; @@ -860,9 +860,9 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) return (PyObject *)self; } -PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) +PyObject *Color_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - ColorObject *self= (ColorObject *)newColorObject(NULL, Py_NEW, NULL); + ColorObject *self= (ColorObject *)Color_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h index 6c84b5f596d..f218d653ec9 100644 --- a/source/blender/python/mathutils/mathutils_Color.h +++ b/source/blender/python/mathutils/mathutils_Color.h @@ -48,7 +48,7 @@ be stored in py_data) or be a wrapper for data allocated through blender (stored in blend_data). This is an either/or struct not both*/ //prototypes -PyObject *newColorObject( float *col, int type, PyTypeObject *base_type); -PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); +PyObject *Color_CreatePyObject( float *col, int type, PyTypeObject *base_type); +PyObject *Color_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); #endif /* MATHUTILS_COLOR_H */ diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index ce9ac5fbbb5..9bf6687fb5e 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -71,7 +71,7 @@ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; break; } - return newEulerObject(eul, order, Py_NEW, type); + return Euler_CreatePyObject(eul, order, Py_NEW, type); } /* internal use, assume read callback is done */ @@ -142,7 +142,7 @@ static PyObject *Euler_to_quaternion(EulerObject * self) eulO_to_quat(quat, self->eul, self->order); - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } //return a matrix representation of the euler @@ -163,7 +163,7 @@ static PyObject *Euler_to_matrix(EulerObject * self) eulO_to_mat3((float (*)[3])mat, self->eul, self->order); - return newMatrixObject(mat, 3, 3 , Py_NEW, NULL); + return Matrix_CreatePyObject(mat, 3, 3 , Py_NEW, NULL); } PyDoc_STRVAR(Euler_zero_doc, @@ -241,7 +241,7 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value) return NULL; eulO_to_mat3(self_rmat, self->eul, self->order); - mul_m3_m3m3(rmat, self_rmat, other_rmat); + mul_m3_m3m3(rmat, other_rmat, self_rmat); mat3_to_compatible_eulO(self->eul, self->eul, self->order, rmat); @@ -293,7 +293,7 @@ static PyObject *Euler_copy(EulerObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newEulerObject(self->eul, self->order, Py_NEW, Py_TYPE(self)); + return Euler_CreatePyObject(self->eul, self->order, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- @@ -664,13 +664,13 @@ PyTypeObject euler_Type = { NULL, //tp_weaklist NULL //tp_del }; -//------------------------newEulerObject (internal)------------- +//------------------------Euler_CreatePyObject (internal)------------- //creates a new euler object /*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER (i.e. it was allocated elsewhere by MEM_mallocN()) pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON (i.e. it must be created here with PyMEM_malloc())*/ -PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_type) +PyObject *Euler_CreatePyObject(float *eul, short order, int type, PyTypeObject *base_type) { EulerObject *self; @@ -707,9 +707,9 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t return (PyObject *)self; } -PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) +PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype) { - EulerObject *self= (EulerObject *)newEulerObject(NULL, order, Py_NEW, NULL); + EulerObject *self= (EulerObject *)Euler_CreatePyObject(NULL, order, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 46f5910f31f..5760d08e1f6 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -50,8 +50,8 @@ be stored in py_data) or be a wrapper for data allocated through blender (stored in blend_data). This is an either/or struct not both*/ //prototypes -PyObject *newEulerObject( float *eul, short order, int type, PyTypeObject *base_type); -PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype); +PyObject *Euler_CreatePyObject( float *eul, short order, int type, PyTypeObject *base_type); +PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype); short euler_order_from_string(const char *str, const char *error_prefix); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 1472b6886f6..2f62f7141cf 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -125,7 +125,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) switch(PyTuple_GET_SIZE(args)) { case 0: - return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, type); + return (PyObject *) Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type); case 1: { PyObject *arg= PyTuple_GET_ITEM(args, 0); @@ -140,7 +140,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (col_size >= 2 && col_size <= 4) { /* sane row & col size, new matrix and assign as slice */ - PyObject *matrix= newMatrixObject(NULL, row_size, col_size, Py_NEW, type); + PyObject *matrix= Matrix_CreatePyObject(NULL, row_size, col_size, Py_NEW, type); if (Matrix_ass_slice((MatrixObject *)matrix, 0, INT_MAX, arg) == 0) { return matrix; } @@ -284,7 +284,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } @@ -308,7 +308,7 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) /* create a identity matrix and add translation */ unit_m4((float(*)[4]) mat); copy_v3_v3(mat + 12, tvec); /* 12, 13, 14 */ - return newMatrixObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); } //----------------------------------mathutils.Matrix.Scale() ------------- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. @@ -395,7 +395,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } //----------------------------------mathutils.Matrix.OrthoProjection() --- //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. @@ -512,7 +512,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } PyDoc_STRVAR(C_Matrix_Shear_doc, @@ -613,7 +613,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) matrix_3x3_as_4x4(mat); } //pass to matrix creation - return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); + return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } void matrix_as_3x3(float mat[3][3], MatrixObject *self) @@ -673,7 +673,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) mat4_to_quat(quat, (float (*)[4])self->contigPtr); } - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } /*---------------------------matrix.toEuler() --------------------*/ @@ -747,7 +747,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) else mat3_to_eulO(eul, order, mat); } - return newEulerObject(eul, order, Py_NEW, NULL); + return Euler_CreatePyObject(eul, order, Py_NEW, NULL); } PyDoc_STRVAR(Matrix_resize_4x4_doc, @@ -827,12 +827,12 @@ static PyObject *Matrix_to_4x4(MatrixObject *self) return NULL; if (self->col_size==4 && self->row_size==4) { - return (PyObject *)newMatrixObject(self->contigPtr, 4, 4, Py_NEW, Py_TYPE(self)); + return (PyObject *)Matrix_CreatePyObject(self->contigPtr, 4, 4, Py_NEW, Py_TYPE(self)); } else if (self->col_size==3 && self->row_size==3) { float mat[4][4]; copy_m4_m3(mat, (float (*)[3])self->contigPtr); - return (PyObject *)newMatrixObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self)); + return (PyObject *)Matrix_CreatePyObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self)); } /* TODO, 2x2 matrix */ @@ -865,7 +865,7 @@ static PyObject *Matrix_to_3x3(MatrixObject *self) matrix_as_3x3(mat, self); - return newMatrixObject((float *)mat, 3, 3, Py_NEW, Py_TYPE(self)); + return Matrix_CreatePyObject((float *)mat, 3, 3, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Matrix_to_translation_doc, @@ -888,7 +888,7 @@ static PyObject *Matrix_to_translation(MatrixObject *self) return NULL; } - return newVectorObject(self->matrix[3], 3, Py_NEW, NULL); + return Vector_CreatePyObject(self->matrix[3], 3, Py_NEW, NULL); } PyDoc_STRVAR(Matrix_to_scale_doc, @@ -923,7 +923,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) /* compatible mat4_to_loc_rot_size */ mat3_to_rot_size(rot, size, mat); - return newVectorObject(size, 3, Py_NEW, NULL); + return Vector_CreatePyObject(size, 3, Py_NEW, NULL); } /*---------------------------matrix.invert() ---------------------*/ @@ -1041,7 +1041,7 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value) } matrix_as_3x3(self_rmat, self); - mul_m3_m3m3(rmat, self_rmat, other_rmat); + mul_m3_m3m3(rmat, other_rmat, self_rmat); copy_m3_m3((float (*)[3])(self->contigPtr), rmat); @@ -1080,9 +1080,9 @@ static PyObject *Matrix_decompose(MatrixObject *self) mat3_to_quat(quat, rot); ret= PyTuple_New(3); - PyTuple_SET_ITEM(ret, 0, newVectorObject(loc, 3, Py_NEW, NULL)); - PyTuple_SET_ITEM(ret, 1, newQuaternionObject(quat, Py_NEW, NULL)); - PyTuple_SET_ITEM(ret, 2, newVectorObject(size, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(loc, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 1, Quaternion_CreatePyObject(quat, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 2, Vector_CreatePyObject(size, 3, Py_NEW, NULL)); return ret; } @@ -1133,7 +1133,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) return NULL; } - return (PyObject*)newMatrixObject(mat, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); + return (PyObject*)Matrix_CreatePyObject(mat, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); } /*---------------------------matrix.determinant() ----------------*/ @@ -1223,7 +1223,7 @@ PyDoc_STRVAR(Matrix_zero_doc, ); static PyObject *Matrix_zero(MatrixObject *self) { - fill_vn(self->contigPtr, self->row_size * self->col_size, 0.0f); + fill_vn_fl(self->contigPtr, self->row_size * self->col_size, 0.0f); if (BaseMath_WriteCallback(self) == -1) return NULL; @@ -1286,7 +1286,7 @@ static PyObject *Matrix_copy(MatrixObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return (PyObject*)newMatrixObject((float (*))self->contigPtr, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); + return (PyObject*)Matrix_CreatePyObject((float (*))self->contigPtr, self->row_size, self->col_size, Py_NEW, Py_TYPE(self)); } /*----------------------------print object (internal)-------------*/ @@ -1383,7 +1383,7 @@ static PyObject *Matrix_item(MatrixObject *self, int i) "array index out of range"); return NULL; } - return newVectorObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, i); + return Vector_CreatePyObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, i); } /*----------------------------object[]------------------------- sequence accessor (set) */ @@ -1428,7 +1428,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) tuple= PyTuple_New(end - begin); for (count= begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, - newVectorObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, count)); + Vector_CreatePyObject_cb((PyObject *)self, self->col_size, mathutils_matrix_vector_cb_index, count)); } @@ -1514,7 +1514,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) add_vn_vnvn(mat, mat1->contigPtr, mat2->contigPtr, mat1->row_size * mat1->col_size); - return newMatrixObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); + return Matrix_CreatePyObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } /*------------------------obj - obj------------------------------ subtraction*/ @@ -1547,7 +1547,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) sub_vn_vnvn(mat, mat1->contigPtr, mat2->contigPtr, mat1->row_size * mat1->col_size); - return newMatrixObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); + return Matrix_CreatePyObject(mat, mat1->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } /*------------------------obj * obj------------------------------ mulplication*/ @@ -1555,7 +1555,7 @@ static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar) { float tmat[16]; mul_vn_vn_fl(tmat, mat->contigPtr, mat->row_size * mat->col_size, scalar); - return newMatrixObject(tmat, mat->row_size, mat->col_size, Py_NEW, Py_TYPE(mat)); + return Matrix_CreatePyObject(tmat, mat->row_size, mat->col_size, Py_NEW, Py_TYPE(mat)); } static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) @@ -1594,7 +1594,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } } - return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); + return Matrix_CreatePyObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } else if (mat2) { /*FLOAT/INT * MATRIX */ @@ -1613,7 +1613,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) return NULL; } - return newVectorObject(tvec, vec2->size, Py_NEW, Py_TYPE(m2)); + return Vector_CreatePyObject(tvec, vec2->size, Py_NEW, Py_TYPE(m2)); } /*FLOAT/INT * MATRIX */ else if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { @@ -1940,7 +1940,7 @@ PyTypeObject matrix_Type = { NULL /*tp_del*/ }; -/*------------------------newMatrixObject (internal)------------- +/*------------------------Matrix_CreatePyObject (internal)------------- creates a new matrix object self->matrix self->contiguous_ptr (reference to data.xxx) [0]------------->[0] @@ -1956,7 +1956,7 @@ self->matrix[1][1] = self->contigPtr[4] */ (i.e. it was allocated elsewhere by MEM_mallocN()) pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON (i.e. it must be created here with PyMEM_malloc())*/ -PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type) +PyObject *Matrix_CreatePyObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type) { MatrixObject *self; int x, row, col; @@ -2022,9 +2022,9 @@ PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsign return (PyObject *) self; } -PyObject *newMatrixObject_cb(PyObject *cb_user, int rowSize, int colSize, int cb_type, int cb_subtype) +PyObject *Matrix_CreatePyObject_cb(PyObject *cb_user, int rowSize, int colSize, int cb_type, int cb_subtype) { - MatrixObject *self= (MatrixObject *)newMatrixObject(NULL, rowSize, colSize, Py_NEW, NULL); + MatrixObject *self= (MatrixObject *)Matrix_CreatePyObject(NULL, rowSize, colSize, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index 275f4270787..d1984d7299d 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -51,8 +51,8 @@ be stored in py_data) or be a wrapper for data allocated through blender (stored in blend_data). This is an either/or struct not both*/ /*prototypes*/ -PyObject *newMatrixObject(float *mat, const unsigned short row_size, const unsigned short col_size, int type, PyTypeObject *base_type); -PyObject *newMatrixObject_cb(PyObject *user, int row_size, int col_size, int cb_type, int cb_subtype); +PyObject *Matrix_CreatePyObject(float *mat, const unsigned short row_size, const unsigned short col_size, int type, PyTypeObject *base_type); +PyObject *Matrix_CreatePyObject_cb(PyObject *user, int row_size, int col_size, int cb_type, int cb_subtype); extern int mathutils_matrix_vector_cb_index; extern struct Mathutils_Callback mathutils_matrix_vector_cb; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 8a6c4909e94..44cd28a7c3d 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -120,7 +120,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) else quat_to_eulO(eul, order, tquat); } - return newEulerObject(eul, order, Py_NEW, NULL); + return Euler_CreatePyObject(eul, order, Py_NEW, NULL); } //----------------------------Quaternion.toMatrix()------------------ PyDoc_STRVAR(Quaternion_to_matrix_doc, @@ -139,7 +139,7 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self) return NULL; quat_to_mat3((float (*)[3])mat, self->quat); - return newMatrixObject(mat, 3, 3, Py_NEW, NULL); + return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL); } //----------------------------Quaternion.toMatrix()------------------ @@ -169,7 +169,7 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) quat__axis_angle_sanitize(axis, &angle); ret= PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, newVectorObject(axis, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(axis, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(angle)); return ret; } @@ -197,7 +197,7 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value) return NULL; mul_qt_qtqt(quat, self->quat, tquat); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } //----------------------------Quaternion.dot(other)------------------ @@ -246,7 +246,7 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject rotation_between_quats_to_quat(quat, self->quat, tquat); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Quaternion_slerp_doc, @@ -288,7 +288,7 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args) interp_qt_qtqt(quat, self->quat, tquat, fac); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Quaternion_rotate_doc, @@ -312,7 +312,7 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value) length= normalize_qt_qt(tquat, self->quat); quat_to_mat3(self_rmat, tquat); - mul_m3_m3m3(rmat, self_rmat, other_rmat); + mul_m3_m3m3(rmat, other_rmat, self_rmat); mat3_to_quat(self->quat, rmat); mul_qt_fl(self->quat, length); /* maintain length after rotating */ @@ -464,7 +464,7 @@ static PyObject *Quaternion_copy(QuaternionObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newQuaternionObject(self->quat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(self->quat, Py_NEW, Py_TYPE(self)); } //----------------------------print object (internal)-------------- @@ -721,7 +721,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2) return NULL; add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } //------------------------obj - obj------------------------------ //subtraction @@ -749,7 +749,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2) quat[x] = quat1->quat[x] - quat2->quat[x]; } - return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar) @@ -757,7 +757,7 @@ static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar) float tquat[4]; copy_qt_qt(tquat, quat->quat); mul_qt_fl(tquat, scalar); - return newQuaternionObject(tquat, Py_NEW, Py_TYPE(quat)); + return Quaternion_CreatePyObject(tquat, Py_NEW, Py_TYPE(quat)); } //------------------------obj * obj------------------------------ @@ -780,7 +780,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) if (quat1 && quat2) { /* QUAT*QUAT (cross product) */ mul_qt_qtqt(quat, quat1->quat, quat2->quat); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); + return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } /* the only case this can happen (for a supported type is "FLOAT*QUAT") */ else if (quat2) { /* FLOAT*QUAT */ @@ -808,7 +808,7 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) copy_v3_v3(tvec, vec2->vec); mul_qt_v3(quat1->quat, tvec); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec2)); + return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(vec2)); } /* QUAT * FLOAT */ else if ((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) { @@ -836,7 +836,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self) return NULL; negate_v4_v4(tquat, self->quat); - return newQuaternionObject(tquat, Py_NEW, Py_TYPE(self)); + return Quaternion_CreatePyObject(tquat, Py_NEW, Py_TYPE(self)); } @@ -982,7 +982,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos quat__axis_angle_sanitize(axis, NULL); - return (PyObject *) newVectorObject(axis, 3, Py_NEW, NULL); + return (PyObject *) Vector_CreatePyObject(axis, 3, Py_NEW, NULL); } static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) @@ -1045,7 +1045,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw break; /* PyArg_ParseTuple assures no more then 2 */ } - return newQuaternionObject(quat, Py_NEW, type); + return Quaternion_CreatePyObject(quat, Py_NEW, type); } static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self) @@ -1190,13 +1190,13 @@ PyTypeObject quaternion_Type = { NULL, //tp_weaklist NULL, //tp_del }; -//------------------------newQuaternionObject (internal)------------- +//------------------------Quaternion_CreatePyObject (internal)------------- //creates a new quaternion object /*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER (i.e. it was allocated elsewhere by MEM_mallocN()) pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON (i.e. it must be created here with PyMEM_malloc())*/ -PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type) +PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_type) { QuaternionObject *self; @@ -1229,9 +1229,9 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type) return (PyObject *) self; } -PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) +PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { - QuaternionObject *self= (QuaternionObject *)newQuaternionObject(NULL, Py_NEW, NULL); + QuaternionObject *self= (QuaternionObject *)Quaternion_CreatePyObject(NULL, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h index 13060ed9ff9..a34720769fa 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.h +++ b/source/blender/python/mathutils/mathutils_Quaternion.h @@ -48,7 +48,7 @@ be stored in py_data) or be a wrapper for data allocated through blender (stored in blend_data). This is an either/or struct not both*/ //prototypes -PyObject *newQuaternionObject( float *quat, int type, PyTypeObject *base_type); -PyObject *newQuaternionObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); +PyObject *Quaternion_CreatePyObject( float *quat, int type, PyTypeObject *base_type); +PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, int cb_type, int cb_subtype); #endif /* MATHUTILS_QUAT_H */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index f70bd42e2b6..1dff33887e3 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -70,7 +70,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED "more then a single arg given"); return NULL; } - return newVectorObject(vec, size, Py_NEW, type); + return Vector_CreatePyObject(vec, size, Py_NEW, type); } static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self) @@ -95,7 +95,7 @@ PyDoc_STRVAR(Vector_zero_doc, ); static PyObject *Vector_zero(VectorObject *self) { - fill_vn(self->vec, self->size, 0.0f); + fill_vn_fl(self->vec, self->size, 0.0f); if (BaseMath_WriteCallback(self) == -1) return NULL; @@ -116,19 +116,10 @@ PyDoc_STRVAR(Vector_normalize_doc, ); static PyObject *Vector_normalize(VectorObject *self) { - int i; - float norm = 0.0f; - if (BaseMath_ReadCallback(self) == -1) return NULL; - for (i = 0; i < self->size; i++) { - norm += self->vec[i] * self->vec[i]; - } - norm = (float) sqrt(norm); - for (i = 0; i < self->size; i++) { - self->vec[i] /= norm; - } + normalize_vn(self->vec, self->size); (void)BaseMath_WriteCallback(self); Py_RETURN_NONE; @@ -273,7 +264,7 @@ static PyObject *Vector_to_2d(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newVectorObject(self->vec, 2, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(self->vec, 2, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_to_3d_doc, ".. method:: to_3d()\n" @@ -291,7 +282,7 @@ static PyObject *Vector_to_3d(VectorObject *self) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3)); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_to_4d_doc, ".. method:: to_4d()\n" @@ -309,7 +300,7 @@ static PyObject *Vector_to_4d(VectorObject *self) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4)); - return newVectorObject(tvec, 4, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(tvec, 4, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_to_tuple_doc, @@ -484,7 +475,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) vec_to_quat(quat, vec, track, up); - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } /* @@ -527,7 +518,7 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) normalize_v3(mirror); reflect_v3_v3v3(reflect, vec, mirror); - return newVectorObject(reflect, self->size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(reflect, self->size, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_cross_doc, @@ -553,7 +544,7 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) return NULL; - ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self)); + ret= (VectorObject *)Vector_CreatePyObject(NULL, 3, Py_NEW, Py_TYPE(self)); cross_v3_v3v3(ret->vec, self->vec, tvec); return (PyObject *)ret; } @@ -571,8 +562,6 @@ PyDoc_STRVAR(Vector_dot_doc, static PyObject *Vector_dot(VectorObject *self, PyObject *value) { float tvec[MAX_DIMENSIONS]; - double dot = 0.0; - int x; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -580,11 +569,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value) if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) return NULL; - for (x = 0; x < self->size; x++) { - dot += (double)(self->vec[x] * tvec[x]); - } - - return PyFloat_FromDouble(dot); + return PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size)); } PyDoc_STRVAR(Vector_angle_doc, @@ -682,7 +667,7 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) rotation_between_vecs_to_quat(quat, vec_a, vec_b); - return newQuaternionObject(quat, Py_NEW, NULL); + return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } PyDoc_STRVAR(Vector_project_doc, @@ -722,7 +707,7 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) for (x = 0; x < size; x++) { vec[x] = (float)dot * tvec[x]; } - return newVectorObject(vec, size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(vec, size, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_lerp_doc, @@ -759,7 +744,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) for (x = 0; x < size; x++) { vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]); } - return newVectorObject(vec, size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(vec, size, Py_NEW, Py_TYPE(self)); } PyDoc_STRVAR(Vector_rotate_doc, @@ -808,7 +793,7 @@ static PyObject *Vector_copy(VectorObject *self) if (BaseMath_ReadCallback(self) == -1) return NULL; - return newVectorObject(self->vec, self->size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(self->vec, self->size, Py_NEW, Py_TYPE(self)); } static PyObject *Vector_repr(VectorObject *self) @@ -975,7 +960,7 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) add_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->size); - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); + return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /* addition in-place: obj += obj */ @@ -1038,7 +1023,7 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) sub_vn_vnvn(vec, vec1->vec, vec2->vec, vec1->size); - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); + return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /* subtraction in-place: obj -= obj */ @@ -1123,7 +1108,7 @@ static PyObject *vector_mul_float(VectorObject *vec, const float scalar) { float tvec[MAX_DIMENSIONS]; mul_vn_vn_fl(tvec, vec->vec, vec->size, scalar); - return newVectorObject(tvec, vec->size, Py_NEW, Py_TYPE(vec)); + return Vector_CreatePyObject(tvec, vec->size, Py_NEW, Py_TYPE(vec)); } static PyObject *Vector_mul(PyObject *v1, PyObject *v2) @@ -1145,9 +1130,6 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) /* make sure v1 is always the vector */ if (vec1 && vec2) { - int i; - double dot = 0.0f; - if (vec1->size != vec2->size) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " @@ -1156,10 +1138,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) } /*dot product*/ - for (i = 0; i < vec1->size; i++) { - dot += (double)(vec1->vec[i] * vec2->vec[i]); - } - return PyFloat_FromDouble(dot); + return PyFloat_FromDouble(dot_vn_vn(vec1->vec, vec2->vec, vec1->size)); } else if (vec1) { if (MatrixObject_Check(v2)) { @@ -1172,7 +1151,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) return NULL; } - return newVectorObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); + return Vector_CreatePyObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); } else if (QuaternionObject_Check(v2)) { /* VEC * QUAT */ @@ -1198,7 +1177,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) copy_v3_v3(tvec, vec1->vec); mul_qt_v3(quat2->quat, tvec); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); + return Vector_CreatePyObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); #endif /* ------ to be removed ------*/ } @@ -1332,7 +1311,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) for (i = 0; i < vec1->size; i++) { vec[i] = vec1->vec[i] / scalar; } - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); + return Vector_CreatePyObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /* divide in-place: obj /= obj */ @@ -1378,7 +1357,7 @@ static PyObject *Vector_neg(VectorObject *self) return NULL; negate_vn_vn(tvec, self->vec, self->size); - return newVectorObject(tvec, self->size, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(tvec, self->size, Py_NEW, Py_TYPE(self)); } /*------------------------vec_magnitude_nosqrt (internal) - for comparing only */ @@ -1644,7 +1623,6 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) static int Vector_setLength(VectorObject *self, PyObject *value) { double dot = 0.0f, param; - int i; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1661,13 +1639,11 @@ static int Vector_setLength(VectorObject *self, PyObject *value) return -1; } if (param == 0.0) { - fill_vn(self->vec, self->size, 0.0f); + fill_vn_fl(self->vec, self->size, 0.0f); return 0; } - for (i = 0; i < self->size; i++) { - dot += (double)(self->vec[i] * self->vec[i]); - } + dot= dot_vn_vn(self->vec, self->vec, self->size); if (!dot) /* cant sqrt zero */ return 0; @@ -1679,9 +1655,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value) dot= dot/param; - for (i = 0; i < self->size; i++) { - self->vec[i]= self->vec[i] / (float)dot; - } + mul_vn_fl(self->vec, self->size, 1.0/dot); (void)BaseMath_WriteCallback(self); /* checked already */ @@ -1691,16 +1665,10 @@ static int Vector_setLength(VectorObject *self, PyObject *value) /* vector.length_squared */ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure)) { - double dot = 0.0f; - int i; - if (BaseMath_ReadCallback(self) == -1) return NULL; - for (i = 0; i < self->size; i++) { - dot += (double)(self->vec[i] * self->vec[i]); - } - return PyFloat_FromDouble(dot); + return PyFloat_FromDouble(dot_vn_vn(self->vec, self->vec, self->size)); } /* Get a new Vector according to the provided swizzle. This function has little @@ -1734,7 +1702,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) axis_to++; } - return newVectorObject(vec, axis_to, Py_NEW, Py_TYPE(self)); + return Vector_CreatePyObject(vec, axis_to, Py_NEW, Py_TYPE(self)); } /* Set the items of this vector using a swizzle. @@ -2396,13 +2364,13 @@ PyTypeObject vector_Type = { NULL }; -/*------------------------newVectorObject (internal)------------- +/*------------------------Vector_CreatePyObject (internal)------------- creates a new vector object pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER (i.e. it was allocated elsewhere by MEM_mallocN()) pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON (i.e. it must be created here with PyMEM_malloc())*/ -PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObject *base_type) +PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type) { VectorObject *self; @@ -2432,7 +2400,7 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje memcpy(self->vec, vec, size * sizeof(float)); } else { /* new empty */ - fill_vn(self->vec, size, 0.0f); + fill_vn_fl(self->vec, size, 0.0f); if (size == 4) { /* do the homogenous thing */ self->vec[3] = 1.0f; } @@ -2446,10 +2414,10 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje return (PyObject *) self; } -PyObject *newVectorObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype) +PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype) { float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */ - VectorObject *self= (VectorObject *)newVectorObject(dummy, size, Py_NEW, NULL); + VectorObject *self= (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL); if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h index 610805fcee0..c1550aabb25 100644 --- a/source/blender/python/mathutils/mathutils_Vector.h +++ b/source/blender/python/mathutils/mathutils_Vector.h @@ -45,7 +45,7 @@ typedef struct { } VectorObject; /*prototypes*/ -PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObject *base_type); -PyObject *newVectorObject_cb(PyObject *user, int size, int callback_type, int subtype); +PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type); +PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, int callback_type, int subtype); #endif /* MATHUTILS_VECTOR_H */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 2f79dfd9914..c5e0d2ab95d 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -158,7 +158,7 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* mul_v3_fl(dir, t); add_v3_v3v3(pvec, orig, dir); - return newVectorObject(pvec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(pvec, 3, Py_NEW, NULL); } /* Line-Line intersection using algorithm from mathworld.wolfram.com */ @@ -242,8 +242,8 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject } else { tuple= PyTuple_New(2); - PyTuple_SET_ITEM(tuple, 0, newVectorObject(i1, vec1->size, Py_NEW, NULL)); - PyTuple_SET_ITEM(tuple, 1, newVectorObject(i2, vec1->size, Py_NEW, NULL)); + PyTuple_SET_ITEM(tuple, 0, Vector_CreatePyObject(i1, vec1->size, Py_NEW, NULL)); + PyTuple_SET_ITEM(tuple, 1, Vector_CreatePyObject(i2, vec1->size, Py_NEW, NULL)); return tuple; } } @@ -338,7 +338,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args) normal_quad_v3(n, vec1->vec, vec2->vec, vec3->vec, vec4->vec); } - return newVectorObject(n, 3, Py_NEW, NULL); + return Vector_CreatePyObject(n, 3, Py_NEW, NULL); } //--------------------------------- AREA FUNCTIONS-------------------- @@ -433,7 +433,7 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj } if (isect_seg_seg_v2_point(line_a1->vec, line_a2->vec, line_b1->vec, line_b2->vec, vi) == 1) { - return newVectorObject(vi, 2, Py_NEW, NULL); + return Vector_CreatePyObject(vi, 2, Py_NEW, NULL); } else { Py_RETURN_NONE; @@ -490,7 +490,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec } if (isect_line_plane_v3(isect, line_a->vec, line_b->vec, plane_co->vec, plane_no->vec, no_flip) == 1) { - return newVectorObject(isect, 3, Py_NEW, NULL); + return Vector_CreatePyObject(isect, 3, Py_NEW, NULL); } else { Py_RETURN_NONE; @@ -552,8 +552,8 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje normalize_v3(isect_no); ret= PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_co, 3, Py_NEW, NULL)); - PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_no, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_co, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_no, 3, Py_NEW, NULL)); return ret; } @@ -626,10 +626,10 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje use_b= FALSE; } - if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 3, Py_NEW, NULL)); } + if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 3, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); } - if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 3, Py_NEW, NULL)); } + if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 3, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); } return ret; @@ -699,10 +699,10 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO use_b= FALSE; } - if (use_a) { PyTuple_SET_ITEM(ret, 0, newVectorObject(isect_a, 2, Py_NEW, NULL)); } + if (use_a) { PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(isect_a, 2, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 0, Py_None); Py_INCREF(Py_None); } - if (use_b) { PyTuple_SET_ITEM(ret, 1, newVectorObject(isect_b, 2, Py_NEW, NULL)); } + if (use_b) { PyTuple_SET_ITEM(ret, 1, Vector_CreatePyObject(isect_b, 2, Py_NEW, NULL)); } else { PyTuple_SET_ITEM(ret, 1, Py_None); Py_INCREF(Py_None); } return ret; @@ -758,7 +758,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec lambda= closest_to_line_v3(pt_out, pt_in, l1, l2); ret= PyTuple_New(2); - PyTuple_SET_ITEM(ret, 0, newVectorObject(pt_out, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 0, Vector_CreatePyObject(pt_out, 3, Py_NEW, NULL)); PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(lambda)); return ret; } @@ -939,7 +939,7 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec); - return newVectorObject(vec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); } #ifndef MATH_STANDALONE @@ -1015,7 +1015,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* list= PyList_New(resolu); fp= coord_array; for (i=0; i<resolu; i++, fp= fp+dims) { - PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW, NULL)); + PyList_SET_ITEM(list, i, Vector_CreatePyObject(fp, dims, Py_NEW, NULL)); } MEM_freeN(coord_array); return list; diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index e0a87b33b5f..b26781d8026 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -779,7 +779,7 @@ void free_qtcomponentdata(void) { void quicktime_verify_image_type(RenderData *rd) { - if (rd->imtype == R_QUICKTIME) { + if (rd->imtype == R_IMF_IMTYPE_QUICKTIME) { if ((rd->qtcodecsettings.codecType<= 0) || (rd->qtcodecsettings.codecSpatialQuality <0) || (rd->qtcodecsettings.codecSpatialQuality > 100)) { diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index 5c0460d4e74..ffda20ead7f 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -689,7 +689,7 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) void quicktime_verify_image_type(RenderData *rd) { - if (rd->imtype == R_QUICKTIME) { + if (rd->imtype == R_IMF_IMTYPE_QUICKTIME) { if ((rd->qtcodecsettings.codecType== 0) || (rd->qtcodecsettings.codecSpatialQuality <0) || (rd->qtcodecsettings.codecSpatialQuality > 100)) { diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 4fe8829eee2..ba211ba396d 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -228,7 +228,7 @@ int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const cha struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); extern const float default_envmap_layout[]; -int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, int imtype, float layout[12]); +int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]); /* do a full sample buffer compo */ void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index c3d7f79b61f..b3948bcde77 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1284,7 +1284,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * re->recty= winy; } - if(re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->imtype) && + if(re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->im_format.imtype) && (re->rectx < 16 || re->recty < 16) )) { BKE_report(re->reports, RPT_ERROR, "Image too small"); re->ok= 0; @@ -3034,13 +3034,13 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr do_render_all_options(re); if(write_still && !G.afbreek) { - if(BKE_imtype_is_movie(scene->r.imtype)) { + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { /* operator checks this but incase its called from elsewhere */ printf("Error: cant write single images with a movie format!\n"); } else { char name[FILE_MAX]; - BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE); + BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); /* reports only used for Movie */ do_write_image_or_movie(re, bmain, scene, NULL, name); @@ -3073,7 +3073,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie RE_AcquireResultImage(re, &rres); /* write movie or image */ - if(BKE_imtype_is_movie(scene->r.imtype)) { + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { int dofree = 0; /* note; the way it gets 32 bits rects is weak... */ if(rres.rect32==NULL) { @@ -3091,16 +3091,16 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie if(name_override) BLI_strncpy(name, name_override, sizeof(name)); else - BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); + BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); - if(re->r.imtype==R_MULTILAYER) { + if(re->r.im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { if(re->result) { - RE_WriteRenderResult(re->reports, re->result, name, scene->r.quality); + RE_WriteRenderResult(re->reports, re->result, name, scene->r.im_format.compress); printf("Saved: %s", name); } } else { - ImBuf *ibuf= IMB_allocImBuf(rres.rectx, rres.recty, scene->r.planes, 0); + ImBuf *ibuf= IMB_allocImBuf(rres.rectx, rres.recty, scene->r.im_format.planes, 0); /* if not exists, BKE_write_ibuf makes one */ ibuf->rect= (unsigned int *)rres.rect32; @@ -3115,7 +3115,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* sequence editor can generate 8bpc render buffers */ if (ibuf->rect) { ibuf->profile = IB_PROFILE_SRGB; - if (ELEM(scene->r.imtype, R_OPENEXR, R_RADHDR)) + if (BKE_imtype_valid_depths(scene->r.im_format.imtype) & (R_IMF_CHAN_DEPTH_12|R_IMF_CHAN_DEPTH_16|R_IMF_CHAN_DEPTH_24|R_IMF_CHAN_DEPTH_32)) IMB_float_from_rect(ibuf); } else { ibuf->profile = IB_PROFILE_LINEAR_RGB; @@ -3124,14 +3124,14 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* color -> greyscale */ /* editing directly would alter the render view */ - if(scene->r.planes == 8) { + if(scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); IMB_freeImBuf(ibuf); ibuf= ibuf_bw; } - ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); if(ok==0) { printf("Render error: cannot save %s\n", name); @@ -3139,12 +3139,15 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie else printf("Saved: %s", name); /* optional preview images for exr */ - if(ok && scene->r.imtype==R_OPENEXR && (scene->r.subimtype & R_PREVIEW_JPG)) { + if(ok && scene->r.im_format.imtype==R_IMF_IMTYPE_OPENEXR && (scene->r.im_format.flag & R_IMF_FLAG_PREVIEW_JPG)) { + ImageFormatData imf= scene->r.im_format; + imf.imtype= R_IMF_IMTYPE_JPEG90; + if(BLI_testextensie(name, ".exr")) name[strlen(name)-4]= 0; - BKE_add_image_extension(name, R_JPEG90); - ibuf->depth= 24; - BKE_write_ibuf_stamp(scene, camera, ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality); + BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90); + ibuf->planes= 24; + BKE_write_ibuf_stamp(scene, camera, ibuf, name, &imf); printf("\nSaved: %s", name); } @@ -3165,7 +3168,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* saves images to disk */ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra) { - bMovieHandle *mh= BKE_get_movie_handle(scene->r.imtype); + bMovieHandle *mh= BKE_get_movie_handle(scene->r.im_format.imtype); int cfrao= scene->r.cfra; int nfra; @@ -3179,7 +3182,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri re->flag |= R_ANIMATION; - if(BKE_imtype_is_movie(scene->r.imtype)) + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports)) G.afbreek= 1; @@ -3234,9 +3237,9 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri nfra+= tfra; /* Touch/NoOverwrite options are only valid for image's */ - if(BKE_imtype_is_movie(scene->r.imtype) == 0) { + if(BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) - BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); + BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) { printf("skipping existing frame \"%s\"\n", name); @@ -3266,7 +3269,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if(G.afbreek==1) { /* remove touched file */ - if(BKE_imtype_is_movie(scene->r.imtype) == 0) { + if(BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_file_size(name) == 0) { BLI_delete(name, 0, 0); } @@ -3282,7 +3285,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri } /* end movie */ - if(BKE_imtype_is_movie(scene->r.imtype)) + if(BKE_imtype_is_movie(scene->r.im_format.imtype)) mh->end_movie(); scene->r.cfra= cfrao; @@ -3425,8 +3428,9 @@ void RE_result_load_from_file(RenderResult *result, ReportList *reports, const c const float default_envmap_layout[] = { 0,0, 1,0, 2,0, 0,1, 1,1, 2,1 }; -int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, const char *relpath, int imtype, float layout[12]) +int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, const char *relpath, const char imtype, float layout[12]) { + ImageFormatData imf; ImBuf *ibuf=NULL; int ok; int dx; @@ -3438,6 +3442,9 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, return 0; } + imf= scene->r.im_format; + imf.imtype= imtype; + dx= env->cube[1]->x; if (env->type == ENV_CUBE) { @@ -3468,7 +3475,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, BLI_strncpy(filepath, relpath, sizeof(filepath)); BLI_path_abs(filepath, G.main->name); - ok= BKE_write_ibuf(ibuf, filepath, imtype, scene->r.subimtype, scene->r.quality); + ok= BKE_write_ibuf(ibuf, filepath, &imf); IMB_freeImBuf(ibuf); diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index a78cc3e2288..b62484a6995 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -587,7 +587,7 @@ void shadeSunView(float col_r[3], const float view[3]) xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &sun_collector[0], &sun_collector[1], &sun_collector[2], lar->sunsky->sky_colorspace); - ramp_blend(lar->sunsky->skyblendtype, col_r, col_r+1, col_r+2, lar->sunsky->skyblendfac, sun_collector); + ramp_blend(lar->sunsky->skyblendtype, col_r, lar->sunsky->skyblendfac, sun_collector); } } } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 323f04cbd04..9459745cdbc 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1484,32 +1484,32 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa case MTEX_BLEND_HUE: fact*= facg; copy_v3_v3(in, out); - ramp_blend(MA_RAMP_HUE, in, in+1, in+2, fact, tex); + ramp_blend(MA_RAMP_HUE, in, fact, tex); break; case MTEX_BLEND_SAT: fact*= facg; copy_v3_v3(in, out); - ramp_blend(MA_RAMP_SAT, in, in+1, in+2, fact, tex); + ramp_blend(MA_RAMP_SAT, in, fact, tex); break; case MTEX_BLEND_VAL: fact*= facg; copy_v3_v3(in, out); - ramp_blend(MA_RAMP_VAL, in, in+1, in+2, fact, tex); + ramp_blend(MA_RAMP_VAL, in, fact, tex); break; case MTEX_BLEND_COLOR: fact*= facg; copy_v3_v3(in, out); - ramp_blend(MA_RAMP_COLOR, in, in+1, in+2, fact, tex); + ramp_blend(MA_RAMP_COLOR, in, fact, tex); break; case MTEX_SOFT_LIGHT: fact*= facg; copy_v3_v3(in, out); - ramp_blend(MA_RAMP_SOFT, in, in+1, in+2, fact, tex); + ramp_blend(MA_RAMP_SOFT, in, fact, tex); break; case MTEX_LIN_LIGHT: fact*= facg; copy_v3_v3(in, out); - ramp_blend(MA_RAMP_LINEAR, in, in+1, in+2, fact, tex); + ramp_blend(MA_RAMP_LINEAR, in, fact, tex); break; } } @@ -3684,7 +3684,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const int i, layers = CustomData_number_of_layers(&orcoDm->faceData, CD_MTFACE); int layer_index = CustomData_get_layer_index(&orcoDm->faceData, CD_MTFACE); - /* for every uv layer set coords and name */ + /* for every uv map set coords and name */ for (i=0; i<layers; i++) { if(layer_index >= 0) { float *uv1, *uv2, *uv3; @@ -3708,7 +3708,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const shi.uv[i].uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ } } - /* active uv layer */ + /* active uv map */ shi.actuv = CustomData_get_active_layer_index(&orcoDm->faceData,CD_MTFACE) - layer_index; shi.totuv = layers; } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 456702e0827..5559d2ff34c 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2458,7 +2458,7 @@ static int get_next_bake_face(BakeShade *bs) imb_freerectImBuf(ibuf); /* clear image */ if(R.r.bake_flag & R_BAKE_CLEAR) - IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ R.bakebuf= ima; @@ -2566,7 +2566,7 @@ static void *do_bake_thread(void *bs_v) void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) { /* must check before filtering */ - const short is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_alphatest_ibuf(ibuf); /* Margin */ if(filter) { @@ -2575,10 +2575,10 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) /* if the bake results in new alpha then change the image setting */ if(is_new_alpha) { - ibuf->depth= 32; + ibuf->planes= R_IMF_PLANES_RGBA; } else { - if(filter && ibuf->depth != 32) { + if(filter && ibuf->planes != R_IMF_PLANES_RGBA) { /* clear alpha added by filtering */ IMB_rectfill_alpha(ibuf, 1.0f); } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index d82ccd05c1e..9bc2529568f 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -908,7 +908,7 @@ static void ramp_diffuse_result(float *diff, ShadeInput *shi) /* blending method */ fac= col[3]*ma->rampfac_col; - ramp_blend(ma->rampblend_col, diff, diff+1, diff+2, fac, col); + ramp_blend(ma->rampblend_col, diff, fac, col); } } } @@ -955,7 +955,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa colt[1]= shi->g; colt[2]= shi->b; - ramp_blend(ma->rampblend_col, colt, colt+1, colt+2, fac, col); + ramp_blend(ma->rampblend_col, colt, fac, col); /* output to */ diff[0] += r * colt[0]; @@ -970,20 +970,20 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa } } -static void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi) +static void ramp_spec_result(float spec_col[3], ShadeInput *shi) { Material *ma= shi->mat; if(ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) { float col[4]; - float fac= 0.3f*(*specr) + 0.58f*(*specg) + 0.12f*(*specb); + float fac= 0.3f*spec_col[0] + 0.58f*spec_col[1] + 0.12f*spec_col[2]; do_colorband(ma->ramp_spec, fac, col); /* blending method */ fac= col[3]*ma->rampfac_spec; - ramp_blend(ma->rampblend_spec, specr, specg, specb, fac, col); + ramp_blend(ma->rampblend_spec, spec_col, fac, col); } } @@ -1023,7 +1023,7 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3]) /* blending method */ fac= col[3]*ma->rampfac_spec; - ramp_blend(ma->rampblend_spec, spec, spec+1, spec+2, fac, col); + ramp_blend(ma->rampblend_spec, spec, fac, col); } } @@ -1879,7 +1879,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shr->combined, shi); } - if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shr->spec+1, shr->spec+2, shi); + if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shi); /* refcol is for envmap only */ if(shi->refcol[0]!=0.0f) { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 1a7031c7d31..1df7f3228a0 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -464,7 +464,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory) { ListBase wmbase; - char tstr[FILE_MAXDIR+FILE_MAXFILE]; + char tstr[FILE_MAX]; int success= 0; free_ttfont(); /* still weird... what does it here? */ @@ -597,7 +597,7 @@ void WM_read_history(void) static void write_history(void) { struct RecentFile *recent, *next_recent; - char name[FILE_MAXDIR+FILE_MAXFILE]; + char name[FILE_MAX]; char *user_config_dir; FILE *fp; int i; @@ -810,7 +810,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) { wmWindowManager *wm= CTX_wm_manager(C); wmWindow *win= CTX_wm_window(C); - char filepath[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAX]; int fileflags; /* check current window and close it if temp */ @@ -922,7 +922,7 @@ void wm_autosave_delete(void) wm_autosave_location(filename); if(BLI_exists(filename)) { - char str[FILE_MAXDIR+FILE_MAXFILE]; + char str[FILE_MAX]; BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); /* if global undo; remove tempsave, otherwise rename */ diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index d2bc9cf8ba2..ef463989c64 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -258,9 +258,9 @@ static void draw_filled_lasso(wmGesture *gt) glColor4f(1.0, 1.0, 1.0, 0.05); glBegin(GL_TRIANGLES); for (efa = fillfacebase.first; efa; efa=efa->next) { - glVertex2f(efa->v1->co[0], efa->v1->co[1]); - glVertex2f(efa->v2->co[0], efa->v2->co[1]); - glVertex2f(efa->v3->co[0], efa->v3->co[1]); + glVertex2fv(efa->v1->co); + glVertex2fv(efa->v2->co); + glVertex2fv(efa->v3->co); } glEnd(); glDisable(GL_BLEND); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 2e191a5ab6d..c75395456dd 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -597,6 +597,8 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap * /* create diff keymap */ diffmap= wm_keymap_new(km->idname, km->spaceid, km->regionid); diffmap->flag |= KEYMAP_DIFF; + if(defaultmap->flag & KEYMAP_MODAL) + diffmap->flag |= KEYMAP_MODAL; wm_keymap_diff(diffmap, defaultmap, km, origmap, addonmap); /* add to list if not empty */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0c538865501..26f59189e47 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1072,6 +1072,15 @@ static void wm_operator_ui_popup_cancel(void *userData) MEM_freeN(data); } +static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval) +{ + wmOpPopUp *data= arg; + wmOperator *op= data->op; + + if(op && retval > 0) + WM_operator_call(C, op); +} + int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) { wmOpPopUp *data= MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); @@ -1079,7 +1088,7 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) data->width= width; data->height= height; data->free_op= TRUE; /* if this runs and gets registered we may want not to free it */ - uiPupBlockEx(C, wm_operator_ui_create, wm_operator_ui_popup_cancel, data); + uiPupBlockEx(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data); return OPERATOR_RUNNING_MODAL; } @@ -1110,7 +1119,7 @@ int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int h data->free_op= TRUE; /* if this runs and gets registered we may want not to free it */ /* op is not executed until popup OK but is clicked */ - uiPupBlockEx(C, wm_block_dialog_create, wm_operator_ui_popup_cancel, data); + uiPupBlockEx(C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data); return OPERATOR_RUNNING_MODAL; } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 3a1c0da4c4d..4e74df6c4bc 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -157,7 +157,7 @@ double elbeemEstimateMemreq(int res, float sx, float sy, float sz, int refine, c struct Render *RE_NewRender(const char *name){return (struct Render*) NULL;} void RE_SwapResult(struct Render *re, struct RenderResult **rr){} void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame){} -int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, int imtype, float layout[12]) { return 0; } +int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]) { return 0; } /* rna */ float *give_cursor(struct Scene *scene, struct View3D *v3d){return (float *) NULL;} @@ -266,6 +266,7 @@ void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar){} void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist){} struct BGpic *ED_view3D_background_image_new(struct View3D *v3d){return (struct BGpic *) NULL;} void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic){} +void ED_view3D_background_image_clear(struct View3D *v3d){} void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist){} int text_file_modified(struct Text *text){return 0;} void ED_node_shader_default(struct Material *ma){} @@ -273,6 +274,7 @@ void ED_screen_animation_timer_update(struct bContext *C, int redraws){} void ED_base_object_select(struct Base *base, short mode){} int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md){return 0;} int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type){return 0;} +void ED_object_modifier_clear(struct Scene *scene, struct Object *ob){} void ED_object_enter_editmode(struct bContext *C, int flag){} void ED_object_exit_editmode(struct bContext *C, int flag){} int uiLayoutGetActive(struct uiLayout *layout){return 0;} @@ -306,6 +308,7 @@ void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum){} void ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum){} void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup){} +void ED_vgroup_clear(struct Object *ob){} void ED_vgroup_object_is_edit_mode(struct Object *ob){} void ED_sequencer_update_view(struct bContext *C, int view){} @@ -391,6 +394,7 @@ void uiTemplateKeymapItemProperties(struct uiLayout *layout, struct PointerRNA * void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact){} void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname){} void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact){} +void uiTemplateImageSettings(struct uiLayout *layout, struct PointerRNA *imfptr){} /* rna render */ struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h){return (struct RenderResult *) NULL;} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 11147193cf6..24195c3f679 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -41,34 +41,6 @@ blender_include_dirs( ../blender/windowmanager ) -if(WITH_CODEC_QUICKTIME) - add_definitions(-DWITH_QUICKTIME) -endif() - -if(WITH_IMAGE_OPENEXR) - add_definitions(-DWITH_OPENEXR) -endif() - -if(WITH_IMAGE_OPENJPEG) - add_definitions(-DWITH_OPENJPEG) -endif() - -if(WITH_IMAGE_TIFF) - add_definitions(-DWITH_TIFF) -endif() - -if(WITH_IMAGE_DDS) - add_definitions(-DWITH_DDS) -endif() - -if(WITH_IMAGE_CINEON) - add_definitions(-DWITH_CINEON) -endif() - -if(WITH_IMAGE_HDR) - add_definitions(-DWITH_HDR) -endif() - if(WITH_LIBMV) blender_include_dirs(../../extern/libmv) add_definitions(-DWITH_LIBMV) diff --git a/source/creator/creator.c b/source/creator/creator.c index 35076d6fe7e..f093de567dd 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -77,6 +77,7 @@ #include "BKE_node.h" #include "BKE_report.h" #include "BKE_sound.h" +#include "BKE_image.h" #include "IMB_imbuf.h" // for IMB_init @@ -302,7 +303,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) printf (" $BLENDER_USER_CONFIG Directory for user configuration files.\n"); printf (" $BLENDER_USER_SCRIPTS Directory for user scripts.\n"); printf (" $BLENDER_SYSTEM_SCRIPTS Directory for system wide scripts.\n"); - printf (" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n"); + printf (" $BLENDER_USER_DAT`AFILES Directory for user data files (icons, translations, ..).\n"); printf (" $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.\n"); printf (" $BLENDER_SYSTEM_PYTHON Directory for system python libraries.\n"); #ifdef WIN32 @@ -584,40 +585,14 @@ static int set_image_type(int argc, const char **argv, void *data) const char *imtype = argv[1]; Scene *scene= CTX_data_scene(C); if (scene) { - if (!strcmp(imtype,"TGA")) scene->r.imtype = R_TARGA; - else if (!strcmp(imtype,"IRIS")) scene->r.imtype = R_IRIS; -#ifdef WITH_DDS - else if (!strcmp(imtype,"DDS")) scene->r.imtype = R_DDS; -#endif - else if (!strcmp(imtype,"JPEG")) scene->r.imtype = R_JPEG90; - else if (!strcmp(imtype,"IRIZ")) scene->r.imtype = R_IRIZ; - else if (!strcmp(imtype,"RAWTGA")) scene->r.imtype = R_RAWTGA; - else if (!strcmp(imtype,"AVIRAW")) scene->r.imtype = R_AVIRAW; - else if (!strcmp(imtype,"AVIJPEG")) scene->r.imtype = R_AVIJPEG; - else if (!strcmp(imtype,"PNG")) scene->r.imtype = R_PNG; - else if (!strcmp(imtype,"AVICODEC")) scene->r.imtype = R_AVICODEC; - else if (!strcmp(imtype,"QUICKTIME")) scene->r.imtype = R_QUICKTIME; - else if (!strcmp(imtype,"BMP")) scene->r.imtype = R_BMP; -#ifdef WITH_HDR - else if (!strcmp(imtype,"HDR")) scene->r.imtype = R_RADHDR; -#endif -#ifdef WITH_TIFF - else if (!strcmp(imtype,"TIFF")) scene->r.imtype = R_TIFF; -#endif -#ifdef WITH_OPENEXR - else if (!strcmp(imtype,"EXR")) scene->r.imtype = R_OPENEXR; - else if (!strcmp(imtype,"MULTILAYER")) scene->r.imtype = R_MULTILAYER; -#endif - else if (!strcmp(imtype,"MPEG")) scene->r.imtype = R_FFMPEG; - else if (!strcmp(imtype,"FRAMESERVER")) scene->r.imtype = R_FRAMESERVER; -#ifdef WITH_CINEON - else if (!strcmp(imtype,"CINEON")) scene->r.imtype = R_CINEON; - else if (!strcmp(imtype,"DPX")) scene->r.imtype = R_DPX; -#endif -#ifdef WITH_OPENJPEG - else if (!strcmp(imtype,"JP2")) scene->r.imtype = R_JP2; -#endif - else printf("\nError: Format from '-F / --render-format' not known or not compiled in this release.\n"); + const char imtype_new= BKE_imtype_from_arg(imtype); + + if (imtype_new == R_IMF_IMTYPE_INVALID) { + printf("\nError: Format from '-F / --render-format' not known or not compiled in this release.\n"); + } + else { + scene->r.im_format.imtype= imtype_new; + } } else { printf("\nError: no blend loaded. order the arguments so '-F / --render-format' is after the blend is loaded.\n"); @@ -890,7 +865,7 @@ static int run_python(int argc, const char **argv, void *data) /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */ if (argc > 1) { /* Make the path absolute because its needed for relative linked blends to be found */ - char filename[FILE_MAXDIR + FILE_MAXFILE]; + char filename[FILE_MAX]; BLI_strncpy(filename, argv[1], sizeof(filename)); BLI_path_cwd(filename); @@ -951,7 +926,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) bContext *C = data; /* Make the path absolute because its needed for relative linked blends to be found */ - char filename[FILE_MAXDIR + FILE_MAXFILE]; + char filename[FILE_MAX]; BLI_strncpy(filename, argv[0], sizeof(filename)); BLI_path_cwd(filename); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 9d2e8751a41..14346cd8260 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -265,7 +265,7 @@ void BL_MakeScreenShot(ScrArea *curarea, const char* filename) ImBuf *ibuf; BLI_path_abs(path, G.main->name); /* BKE_add_image_extension() checks for if extension was already set */ - BKE_add_image_extension(path, R_PNG); /* scene->r.imtype */ + BKE_add_image_extension(path, R_IMF_IMTYPE_PNG); /* scene->r.im_format.imtype */ ibuf= IMB_allocImBuf(dumpsx, dumpsy, 24, 0); ibuf->rect= dumprect; ibuf->ftype= PNG; diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index abc45293542..1bfe5945bbc 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -144,6 +144,7 @@ void BL_ActionActuator::SetLocalTime(float curtime) case ACT_ACTION_PLAY: // Clamp m_localtime = m_endframe; + ((KX_GameObject*)GetParent())->StopAction(m_layer); break; case ACT_ACTION_LOOP_END: // Put the time back to the beginning @@ -237,14 +238,14 @@ bool BL_ActionActuator::Update(double curtime, bool frame) RemoveAllEvents(); } + // "Active" actions need to keep updating their current frame if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE)) - { m_localtime = obj->GetActionFrame(m_layer); - ResetStartTime(curtime); - } if (m_flag & ACT_FLAG_ATTEMPT_PLAY) SetLocalTime(curtime); + else + ResetStartTime(curtime); // Handle a frame property if it's defined if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0) @@ -299,6 +300,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent) { m_flag &= ~ACT_FLAG_ATTEMPT_PLAY; + m_localtime = obj->GetActionFrame(m_layer); bAction *curr_action = obj->GetCurrentAction(m_layer); if (curr_action && curr_action != m_action) { diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 1da4b388823..c463068d52c 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -295,7 +295,7 @@ PyObject* BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str mul_v3_fl(joints,norm); break; } - return newVectorObject(joints, 3, Py_NEW, NULL); + return Vector_CreatePyObject(joints, 3, Py_NEW, NULL); } int BL_ArmatureChannel::py_attr_set_joint_rotation(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -434,7 +434,7 @@ PyAttributeDef BL_ArmatureBone::AttributesPtr[] = { KX_PYATTRIBUTE_FLOAT_VECTOR_RO("arm_head",Bone,arm_head,3), KX_PYATTRIBUTE_FLOAT_VECTOR_RO("arm_tail",Bone,arm_tail,3), KX_PYATTRIBUTE_FLOAT_MATRIX_RO("arm_mat",Bone,arm_mat,4), - KX_PYATTRIBUTE_FLOAT_MATRIX_RO("bone_mat",Bone,bone_mat,4), + KX_PYATTRIBUTE_FLOAT_MATRIX_RO("bone_mat",Bone,bone_mat,3), KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureBone,py_bone_get_parent), KX_PYATTRIBUTE_RO_FUNCTION("children",BL_ArmatureBone,py_bone_get_children), { NULL } //Sentinel diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index f263bf15f02..d50ec0f414e 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -418,7 +418,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * return NULL; } #ifdef USE_MATHUTILS - return newVectorObject(val, attrdef->m_imax, Py_NEW, NULL); + return Vector_CreatePyObject(val, attrdef->m_imax, Py_NEW, NULL); #else PyObject* resultlist = PyList_New(attrdef->m_imax); for (unsigned int i=0; i<attrdef->m_imax; i++) @@ -435,7 +435,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * return NULL; } #ifdef USE_MATHUTILS - return newMatrixObject(val, attrdef->m_imin, attrdef->m_imax, Py_WRAP, NULL); + return Matrix_CreatePyObject(val, attrdef->m_imin, attrdef->m_imax, Py_WRAP, NULL); #else PyObject* collist = PyList_New(attrdef->m_imin); for (unsigned int i=0; i<attrdef->m_imin; i++) @@ -457,7 +457,7 @@ PyObject *PyObjectPlus::py_get_attrdef(PyObject *self_py, const PyAttributeDef * MT_Vector3 *val = reinterpret_cast<MT_Vector3*>(ptr); #ifdef USE_MATHUTILS float fval[3]= {(*val)[0], (*val)[1], (*val)[2]}; - return newVectorObject(fval, 3, Py_NEW, NULL); + return Vector_CreatePyObject(fval, 3, Py_NEW, NULL); #else PyObject* resultlist = PyList_New(3); for (unsigned int i=0; i<3; i++) diff --git a/source/gameengine/GamePlayer/common/bmfont.cpp b/source/gameengine/GamePlayer/common/bmfont.cpp index b03d7f40bdd..dd7126b2944 100644 --- a/source/gameengine/GamePlayer/common/bmfont.cpp +++ b/source/gameengine/GamePlayer/common/bmfont.cpp @@ -171,7 +171,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) ibuf->userdata = bmfont; ibuf->userflags |= IB_BITMAPFONT; - if (ibuf->depth < 32) { + if (ibuf->planes < 32) { // we're going to fake alpha here: calcAlpha(ibuf); } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 140dbadee60..e84df921fd5 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -270,12 +270,12 @@ static void get_filename(int argc, char **argv, char *filename) if (argc > 1) { if (BLI_exists(argv[argc-1])) { - BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(filename, argv[argc-1], FILE_MAX); } if (::strncmp(argv[argc-1], "-psn_", 5)==0) { static char firstfilebuf[512]; if (GHOST_HACK_getFirstFile(firstfilebuf)) { - BLI_strncpy(filename, firstfilebuf, FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(filename, firstfilebuf, FILE_MAX); } } } @@ -289,7 +289,7 @@ static void get_filename(int argc, char **argv, char *filename) //::printf("looking for file: %s\n", filename); if (BLI_exists(gamefile)) - BLI_strncpy(filename, gamefile, FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(filename, gamefile, FILE_MAX); delete [] gamefile; } @@ -298,7 +298,7 @@ static void get_filename(int argc, char **argv, char *filename) filename[0] = '\0'; if(argc > 1) - BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(filename, argv[argc-1], FILE_MAX); #endif // !_APPLE } @@ -406,6 +406,7 @@ int main(int argc, char** argv) initglobals(); + U.gameflags |= USER_DISABLE_VBO; // We load our own G.main, so free the one that initglobals() gives us free_main(G.main); G.main = NULL; @@ -736,8 +737,8 @@ int main(int argc, char** argv) STR_String exitstring = ""; GPG_Application app(system); bool firstTimeRunning = true; - char filename[FILE_MAXDIR + FILE_MAXFILE]; - char pathname[FILE_MAXDIR + FILE_MAXFILE]; + char filename[FILE_MAX]; + char pathname[FILE_MAX]; char *titlename; get_filename(argc_py_clamped, argv, filename); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c240a7fcf84..18b8c0d533d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -2000,7 +2000,7 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldPosition()); @@ -2022,7 +2022,7 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalPosition()); @@ -2044,7 +2044,7 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); if (self->GetPhysicsController()) @@ -2056,7 +2056,7 @@ PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB PyObject* KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); + return Matrix_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldOrientation()); @@ -2081,7 +2081,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newMatrixObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); + return Matrix_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalOrientation()); @@ -2105,7 +2105,7 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldScaling()); @@ -2115,7 +2115,7 @@ PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIB PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalScaling()); @@ -2138,7 +2138,7 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE PyObject* KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetLinearVelocity(false)); @@ -2160,7 +2160,7 @@ int KX_GameObject::pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRI PyObject* KX_GameObject::pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetLinearVelocity(true)); @@ -2182,7 +2182,7 @@ int KX_GameObject::pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRI PyObject* KX_GameObject::pyattr_get_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetAngularVelocity(false)); @@ -2204,7 +2204,7 @@ int KX_GameObject::pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTR PyObject* KX_GameObject::pyattr_get_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetAngularVelocity(true)); @@ -2297,7 +2297,7 @@ PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DE PyObject* KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); #else KX_GameObject* self= static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->GetObjectColor()); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index b7420b3c3f0..aed9ff2b81d 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -462,7 +462,7 @@ Mathutils_Callback mathutils_obactu_vector_cb = { PyObject* KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_LINV); } int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) @@ -478,7 +478,7 @@ int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *a PyObject* KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - return newVectorObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); + return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxobactu_vector_cb_index, MATHUTILS_VEC_CB_ANGV); } int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index a221020c1ef..dd32284a807 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -100,7 +100,7 @@ PyObject* PyObjectFrom(const MT_Matrix4x4 &mat) #ifdef USE_MATHUTILS float fmat[16]; mat.getValue(fmat); - return newMatrixObject(fmat, 4, 4, Py_NEW, NULL); + return Matrix_CreatePyObject(fmat, 4, 4, Py_NEW, NULL); #else PyObject *collist = PyList_New(4); PyObject *col; @@ -124,7 +124,7 @@ PyObject* PyObjectFrom(const MT_Matrix3x3 &mat) #ifdef USE_MATHUTILS float fmat[9]; mat.getValue3x3(fmat); - return newMatrixObject(fmat, 3, 3, Py_NEW, NULL); + return Matrix_CreatePyObject(fmat, 3, 3, Py_NEW, NULL); #else PyObject *collist = PyList_New(3); PyObject *col; @@ -147,7 +147,7 @@ PyObject* PyObjectFrom(const MT_Quaternion &qrot) { /* NOTE, were re-ordering here for Mathutils compat */ float fvec[4]= {qrot[3], qrot[0], qrot[1], qrot[2]}; - return newQuaternionObject(fvec, Py_NEW, NULL); + return Quaternion_CreatePyObject(fvec, Py_NEW, NULL); } #endif @@ -155,7 +155,7 @@ PyObject* PyObjectFrom(const MT_Tuple4 &vec) { #ifdef USE_MATHUTILS float fvec[4]= {vec[0], vec[1], vec[2], vec[3]}; - return newVectorObject(fvec, 4, Py_NEW, NULL); + return Vector_CreatePyObject(fvec, 4, Py_NEW, NULL); #else PyObject *list = PyList_New(4); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); @@ -170,7 +170,7 @@ PyObject* PyObjectFrom(const MT_Tuple3 &vec) { #ifdef USE_MATHUTILS float fvec[3]= {vec[0], vec[1], vec[2]}; - return newVectorObject(fvec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(fvec, 3, Py_NEW, NULL); #else PyObject *list = PyList_New(3); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); @@ -184,7 +184,7 @@ PyObject* PyObjectFrom(const MT_Tuple2 &vec) { #ifdef USE_MATHUTILS float fvec[2]= {vec[0], vec[1]}; - return newVectorObject(fvec, 2, Py_NEW, NULL); + return Vector_CreatePyObject(fvec, 2, Py_NEW, NULL); #else PyObject *list = PyList_New(2); PyList_SET_ITEM(list, 0, PyFloat_FromDouble(vec[0])); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 02e6ebea71b..d9822d131eb 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -147,8 +147,8 @@ extern "C" { #ifdef WITH_PYTHON static RAS_ICanvas* gp_Canvas = NULL; -static char gp_GamePythonPath[FILE_MAXDIR + FILE_MAXFILE] = ""; -static char gp_GamePythonPathOrig[FILE_MAXDIR + FILE_MAXFILE] = ""; // not super happy about this, but we need to remember the first loaded file for the global/dict load save +static char gp_GamePythonPath[FILE_MAX] = ""; +static char gp_GamePythonPathOrig[FILE_MAX] = ""; // not super happy about this, but we need to remember the first loaded file for the global/dict load save static SCA_PythonKeyboard* gp_PythonKeyboard = NULL; static SCA_PythonMouse* gp_PythonMouse = NULL; @@ -237,13 +237,13 @@ The function also converts the directory separator to the local file system form static PyObject* gPyExpandPath(PyObject*, PyObject* args) { - char expanded[FILE_MAXDIR + FILE_MAXFILE]; + char expanded[FILE_MAX]; char* filename; if (!PyArg_ParseTuple(args,"s:ExpandPath",&filename)) return NULL; - BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(expanded, filename, FILE_MAX); BLI_path_abs(expanded, gp_GamePythonPath); return PyUnicode_DecodeFSDefault(expanded); } @@ -496,7 +496,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) list = PyList_New(0); if (searchpath) { - BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE); + BLI_strncpy(cpath, searchpath, FILE_MAX); BLI_path_abs(cpath, gp_GamePythonPath); } else { /* Get the dir only */ @@ -1728,7 +1728,7 @@ static void backupPySysObjects(void) static void initPySysObjects__append(PyObject *sys_path, const char *filename) { PyObject *item; - char expanded[FILE_MAXDIR + FILE_MAXFILE]; + char expanded[FILE_MAX]; BLI_split_dir_part(filename, expanded, sizeof(expanded)); /* get the dir part of filename only */ BLI_path_abs(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */ diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index e1ddd7fce1e..40e9f899ef0 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -329,7 +329,17 @@ PyObject * Texture_refresh (Texture * self, PyObject * args) // get texture size short * orgSize = self->m_source->m_image->getSize(); // calc scaled sizes - short size[] = {ImageBase::calcSize(orgSize[0]), ImageBase::calcSize(orgSize[1])}; + short size[2]; + if (GLEW_ARB_texture_non_power_of_two) + { + size[0] = orgSize[0]; + size[1] = orgSize[1]; + } + else + { + size[0] = ImageBase::calcSize(orgSize[0]); + size[1] = ImageBase::calcSize(orgSize[1]); + } // scale texture if needed if (size[0] != orgSize[0] || size[1] != orgSize[1]) { diff --git a/source/tests/pep8.py b/source/tests/pep8.py index 0c7c90a2382..4b957f20907 100644 --- a/source/tests/pep8.py +++ b/source/tests/pep8.py @@ -122,12 +122,13 @@ def main(): "W0232," # class has no __init__, Operator/Panel/Menu etc "W0142," # Used * or ** magic # even needed in some cases - "R0903," # bake_action] Too many statements (68/50) + "R0902," # Too many instance attributes + "R0903," # Too many statements "R0911," # Too many return statements "R0912," # Too many branches "R0913," # Too many arguments "R0914," # Too many local variables - "R0915," # bake_action] Too many statements (68/50) + "R0915," # Too many statements " " "--include-ids=y " "--output-format=parseable " |