diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-11-27 15:48:35 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-11-27 15:48:35 +0300 |
commit | a04603d2a0ffed1b3030167449687b893711da32 (patch) | |
tree | 95a529f8fb0914add4ea596962b11d6be2f31573 /source | |
parent | 5c26fd6c4cd3e05c70b5473cc045127b615a592d (diff) | |
parent | 02cc80691d71ea305780655d3b0d4cd4530db9c7 (diff) |
Merged changes in the trunk up to revision 33348.
Diffstat (limited to 'source')
367 files changed, 3898 insertions, 3320 deletions
diff --git a/source/blender/avi/AVI_avi.h b/source/blender/avi/AVI_avi.h index 2e71bd98309..90fa7705598 100644 --- a/source/blender/avi/AVI_avi.h +++ b/source/blender/avi/AVI_avi.h @@ -232,7 +232,7 @@ typedef enum { /** * Test whether this is an avi-format. */ -int AVI_is_avi (char *name); +int AVI_is_avi (const char *name); /** @@ -277,7 +277,7 @@ int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num); /** * Open a movie stream from file. */ -AviError AVI_open_movie (char *name, AviMovie *movie); +AviError AVI_open_movie (const char *name, AviMovie *movie); /** * Read a frame from a movie stream. diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 53be1b4467a..a30f51da499 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -211,17 +211,15 @@ int AVI_is_avi (char *name) { } */ -int AVI_is_avi (char *name) { +int AVI_is_avi (const char *name) { int temp, fcca, j; - AviMovie movie; + AviMovie movie= {0}; AviMainHeader header; AviBitmapInfoHeader bheader; int movie_tracks = 0; DEBUG_PRINT("opening movie\n"); - memset(&movie, 0, sizeof(AviMovie)); - movie.type = AVI_MOVIE_READ; movie.fp = fopen (name, "rb"); movie.offset_table = NULL; @@ -404,7 +402,7 @@ int AVI_is_avi (char *name) { } -AviError AVI_open_movie (char *name, AviMovie *movie) { +AviError AVI_open_movie (const char *name, AviMovie *movie) { int temp, fcca, size, j; DEBUG_PRINT("opening movie\n"); diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 02834d3c905..d32922f2429 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -34,6 +34,8 @@ struct rctf; int BLF_init(int points, int dpi); void BLF_exit(void); +void BLF_cache_clear(void); + int BLF_load(const char *name); int BLF_load_mem(const char *name, unsigned char *mem, int mem_size); @@ -179,4 +181,8 @@ void BLF_dir_free(char **dirs, int count); #define BLF_SHADOW (1<<2) #define BLF_KERNING_DEFAULT (1<<3) +// XXX, bad design +extern int blf_mono_font; +extern int blf_mono_font_render; // dont mess drawing with render threads. + #endif /* BLF_API_H */ diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index f6afa31a28d..131ff861a5c 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -47,9 +47,9 @@ IF(WITH_INTERNATIONAL) ADD_DEFINITIONS(-DINTERNATIONAL) ENDIF(WITH_INTERNATIONAL) -IF(WIN32) - ADD_DEFINITIONS(-D_WIN32 -DUSE_GETTEXT_DLL) -ENDIF(WIN32) +IF(WIN32 AND NOT UNIX) + ADD_DEFINITIONS(-DUSE_GETTEXT_DLL) +ENDIF(WIN32 AND NOT UNIX) BLENDERLIB(bf_blenfont "${SRC}" "${INC}") diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 360c79ed06a..febd3d9d6f7 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -66,6 +66,10 @@ int global_font_default= -1; int global_font_points= 11; int global_font_dpi= 72; +// XXX, should these be made into global_font_'s too? +int blf_mono_font= -1; +int blf_mono_font_render= -1; + static FontBLF *BLF_get(int fontid) { if (fontid >= 0 && fontid < BLF_MAX_FONT) @@ -99,6 +103,18 @@ void BLF_exit(void) blf_font_exit(); } +void BLF_cache_clear(void) +{ + FontBLF *font; + int i; + + for (i= 0; i < global_font_num; i++) { + font= global_font[i]; + if (font) + blf_glyph_cache_clear(font); + } +} + static int blf_search(const char *name) { FontBLF *font; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 2c0b833297e..c36496fb542 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -41,6 +41,7 @@ #include "MEM_guardedalloc.h" #include "DNA_vec_types.h" +#include "DNA_userdef_types.h" #include "BLI_blenlib.h" @@ -115,6 +116,23 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) return(gc); } +void blf_glyph_cache_clear(FontBLF *font) +{ + GlyphCacheBLF *gc; + GlyphBLF *g; + int i; + + for(gc=font->cache.first; gc; gc=gc->next) { + for (i= 0; i < 257; i++) { + while (gc->bucket[i].first) { + g= gc->bucket[i].first; + BLI_remlink(&(gc->bucket[i]), g); + blf_glyph_free(g); + } + } + } +} + void blf_glyph_cache_free(GlyphCacheBLF *gc) { GlyphBLF *g; @@ -193,12 +211,10 @@ GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) GlyphBLF *g; FT_Error err; FT_Bitmap bitmap, tempbitmap; - int sharp; + int sharp = (U.text_render & USER_TEXT_DISABLE_AA); FT_BBox bbox; unsigned int key; - sharp = 0; /* TODO make the value be configurable somehow */ - g= blf_glyph_search(font->glyph_cache, c); if (g) return(g); diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index bded1feb9bb..afe40973269 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -56,6 +56,7 @@ void blf_font_free(FontBLF *font); GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi); GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font); +void blf_glyph_cache_clear(FontBLF *font); void blf_glyph_cache_free(GlyphCacheBLF *gc); GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c); diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index eacb61d122c..f074f7e7e74 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -73,7 +73,7 @@ typedef struct PoseTree extern "C" { #endif -struct bArmature *add_armature(char *name); +struct bArmature *add_armature(const char *name); struct bArmature *get_armature(struct Object *ob); void free_bonelist (struct ListBase *lb); void free_armature(struct bArmature *arm); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 8f6d3451de2..01a26329f29 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -50,7 +50,7 @@ struct Main; #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 -int BKE_read_file(struct bContext *C, char *dir, struct ReportList *reports); +int BKE_read_file(struct bContext *C, const char *filepath, struct ReportList *reports); int BKE_read_file_from_memory(struct bContext *C, char* filebuf, int filelength, struct ReportList *reports); int BKE_read_file_from_memfile(struct bContext *C, struct MemFile *memfile, struct ReportList *reports); @@ -65,7 +65,7 @@ void set_blender_test_break_cb(void (*func)(void) ); int blender_test_break(void); /* global undo */ -extern void BKE_write_undo(struct bContext *C, char *name); +extern void BKE_write_undo(struct bContext *C, const char *name); extern void BKE_undo_step(struct bContext *C, int step); extern void BKE_undo_name(struct bContext *C, const char *name); extern void BKE_reset_undo(void); diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 5a1db432589..975e64929c2 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -65,6 +65,7 @@ typedef struct BVHTreeFromMesh /* Private data */ int cached; + void *em_evil; /* var only for snapping */ } BVHTreeFromMesh; diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 7cbaf6bdad2..742c5049ed8 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -114,7 +114,7 @@ bContext *CTX_copy(const bContext *C); /* Stored Context */ -bContextStore *CTX_store_add(ListBase *contexts, char *name, PointerRNA *ptr); +bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr); void CTX_store_set(bContext *C, bContextStore *store); bContextStore *CTX_store_copy(bContextStore *store); void CTX_store_free(bContextStore *store); diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index f60f8f8e28f..8c652a11794 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -54,7 +54,7 @@ struct BevList; void unlink_curve( struct Curve *cu); void free_curve( struct Curve *cu); void BKE_free_editfont(struct Curve *cu); -struct Curve *add_curve(char *name, int type); +struct Curve *add_curve(const char *name, int type); struct Curve *copy_curve( struct Curve *cu); void make_local_curve( struct Curve *cu); short curve_type( struct Curve *cu); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 5d306e75db9..3c04d6ec643 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -121,7 +121,7 @@ int CustomData_number_of_layers(const struct CustomData *data, int type); * returns the layer data */ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type); void *CustomData_duplicate_referenced_layer_named(struct CustomData *data, - int type, char *name); + int type, const char *name); /* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is * zero for the layer type, so only layer types specified by the mask @@ -195,10 +195,10 @@ void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int typ void *CustomData_get_layer(const struct CustomData *data, int type); void *CustomData_get_layer_n(const struct CustomData *data, int type, int n); void *CustomData_get_layer_named(const struct CustomData *data, int type, - char *name); + const char *name); int CustomData_get_layer_index(const struct CustomData *data, int type); -int CustomData_get_named_layer_index(const struct CustomData *data, int type, char *name); +int CustomData_get_named_layer_index(const struct CustomData *data, int type, const char *name); int CustomData_get_active_layer_index(const struct CustomData *data, int type); int CustomData_get_render_layer_index(const struct CustomData *data, int type); int CustomData_get_clone_layer_index(const struct CustomData *data, int type); diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h index 740a94b6169..553e62ba578 100644 --- a/source/blender/blenkernel/BKE_exotic.h +++ b/source/blender/blenkernel/BKE_exotic.h @@ -40,7 +40,7 @@ struct Scene; * @retval 1 The file was read succesfully. * @attention Used in filesel.c */ -int BKE_read_exotic(struct Scene *scene, char *name); +int BKE_read_exotic(struct Scene *scene, const char *name); void write_dxf(struct Scene *scene, char *str); void write_stl(struct Scene *scene, char *str); diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 8dbfb4f2c73..46392c2c8ea 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -214,6 +214,14 @@ void calc_fcurve_range(struct FCurve *fcu, float *min, float *max); /* get the bounding-box extents for F-Curve */ void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax); +/* .............. */ + +/* Are keyframes on F-Curve of any use (to final result, and to show in editors)? */ +short fcurve_are_keyframes_usable(struct FCurve *fcu); + +/* Can keyframes be added to F-Curve? */ +short fcurve_is_keyframable(struct FCurve *fcu); + /* -------- Curve Sanity -------- */ void calchandles_fcurve(struct FCurve *fcu); diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 10811c0776d..c47a0b21855 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -75,7 +75,7 @@ void BKE_font_register_builtin(void *mem, int size); void free_vfont(struct VFont *sc); void free_ttfont(void); struct VFont *get_builtin_font(void); -struct VFont *load_vfont(char *name); +struct VFont *load_vfont(const char *name); struct TmpFont *vfont_find_tmpfont(struct VFont *vfont); struct chartrans *BKE_text_to_curve(struct Scene *scene, struct Object *ob, int mode); diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index e63e3c93f1e..767e3c97fef 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -40,7 +40,7 @@ struct Scene; void free_group_objects(struct Group *group); void unlink_group(struct Group *group); -struct Group *add_group(char *name); +struct Group *add_group(const char *name); struct Group *copy_group(struct Group *group); int add_to_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base); int rem_from_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base); diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index eb33479cdb4..701cffc7743 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -72,8 +72,8 @@ void IDP_UnlinkArray(struct IDProperty *prop); /* ---------- String Type ------------ */ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen);/* maxlen excludes '\0' */ -void IDP_AssignString(struct IDProperty *prop, char *st, int maxlen); /* maxlen excludes '\0' */ -void IDP_ConcatStringC(struct IDProperty *prop, char *st); +void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen); /* maxlen excludes '\0' */ +void IDP_ConcatStringC(struct IDProperty *prop, const char *st); void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append); void IDP_FreeString(struct IDProperty *prop); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index ab636899925..7a801c0ef0a 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -46,7 +46,7 @@ void free_image(struct Image *me); void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels); -int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality); +int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); void BKE_makepicstring(char *string, const char *base, 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); @@ -115,7 +115,7 @@ void BKE_image_release_ibuf(struct Image *ima, void *lock); struct Image *BKE_add_image_file(const char *name); /* adds image, adds ibuf, generates color or pattern */ -struct Image *BKE_add_image_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); +struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); /* adds image from imbuf, owns imbuf */ struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf); diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 31e920406c0..4ed06c30a9c 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -59,7 +59,7 @@ void key_curve_normal_weights(float t, float *data, int type); float *do_ob_key(struct Scene *scene, struct Object *ob); struct Key *ob_get_key(struct Object *ob); -struct KeyBlock *add_keyblock(struct Key *key, char *name); +struct KeyBlock *add_keyblock(struct Key *key, const char *name); struct KeyBlock *ob_get_keyblock(struct Object *ob); struct KeyBlock *ob_get_reference_keyblock(struct Object *ob); struct KeyBlock *key_get_keyblock(struct Key *key, int index); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 880f3f7e724..4f405e71662 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -39,7 +39,7 @@ struct BPoint; struct MDeformVert; void resizelattice(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); -struct Lattice *add_lattice(char *name); +struct Lattice *add_lattice(const char *name); struct Lattice *copy_lattice(struct Lattice *lt); void free_lattice(struct Lattice *lt); void make_local_lattice(struct Lattice *lt); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 4f0238854ef..d7cc6590f94 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -72,7 +72,7 @@ void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); void all_local(struct Library *lib, int untagged_only); -struct ID *find_id(char *type, char *name); +struct ID *find_id(char *type, const char *name); void clear_id_newpoins(void); void IDnames_to_pupstring(char **str, char *title, char *extraops, struct ListBase *lb,struct ID* link, short *nr); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 40d98394a8e..5687fcb4c01 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -46,7 +46,7 @@ void init_def_material(void); void free_material(struct Material *sc); void test_object_materials(struct ID *id); void init_material(struct Material *ma); -struct Material *add_material(char *name); +struct Material *add_material(const char *name); struct Material *copy_material(struct Material *ma); struct Material *give_node_material(struct Material *ma); /* returns node material or self */ void make_local_material(struct Material *ma); diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 7fa4fc1a05e..e5b5118deb0 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -159,7 +159,7 @@ float init_meta(struct Scene *scene, struct Object *ob); void unlink_mball(struct MetaBall *mb); void free_mball(struct MetaBall *mb); -struct MetaBall *add_mball(char *name); +struct MetaBall *add_mball(const char *name); struct MetaBall *copy_mball(struct MetaBall *mb); void make_local_mball(struct MetaBall *mb); struct MetaElem *add_metaball_element(struct MetaBall *mb, const int type); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 7e1ab138acc..398e1d8a7f5 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -57,7 +57,7 @@ void BKE_mesh_end_editmesh(struct Mesh *me, struct EditMesh *em); void unlink_mesh(struct Mesh *me); void free_mesh(struct Mesh *me); -struct Mesh *add_mesh(char *name); +struct Mesh *add_mesh(const char *name); struct Mesh *copy_mesh(struct Mesh *me); void mesh_update_customdata_pointers(struct Mesh *me); void make_local_tface(struct Mesh *me); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 8999d7285c2..45bdb83e090 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -73,18 +73,18 @@ void object_copy_proxy_drivers(struct Object *ob, struct Object *target); void unlink_object(struct Object *ob); int exist_object(struct Object *obtest); -void *add_camera(char *name); +void *add_camera(const char *name); struct Camera *copy_camera(struct Camera *cam); void make_local_camera(struct Camera *cam); float dof_camera(struct Object *ob); -void *add_lamp(char *name); +void *add_lamp(const char *name); struct Lamp *copy_lamp(struct Lamp *la); void make_local_lamp(struct Lamp *la); void free_camera(struct Camera *ca); void free_lamp(struct Lamp *la); -struct Object *add_only_object(int type, char *name); +struct Object *add_only_object(int type, const char *name); struct Object *add_object(struct Scene *scene, int type); struct Object *copy_object(struct Object *ob); @@ -130,7 +130,7 @@ int give_obdata_texspace(struct Object *ob, short **texflag, float **loc, float int object_insert_ptcache(struct Object *ob); // void object_delete_ptcache(struct Object *ob, int index); -struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, char *name, int from_mix); +struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix); void object_camera_matrix( struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second, diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index ca03708edef..c3ab392fd85 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -42,7 +42,7 @@ struct ReportList; struct VFont; /* pack */ -struct PackedFile *newPackedFile(struct ReportList *reports, char *filename); +struct PackedFile *newPackedFile(struct ReportList *reports, const char *filename); struct PackedFile *newPackedFileMemory(void *mem, int memlen); void packAll(struct Main *bmain, struct ReportList *reports); @@ -54,14 +54,14 @@ int unpackSound(struct Main *bmain, struct ReportList *reports, struct bSound *s int unpackImage(struct ReportList *reports, struct Image *ima, int how); void unpackAll(struct Main *bmain, struct ReportList *reports, int how); -int writePackedFile(struct ReportList *reports, char *filename, struct PackedFile *pf, int guimode); +int writePackedFile(struct ReportList *reports, const char *filename, struct PackedFile *pf, int guimode); /* free */ void freePackedFile(struct PackedFile *pf); /* info */ int countPackedFiles(struct Main *bmain); -int checkPackedFile(char *filename, struct PackedFile *pf); +int checkPackedFile(const char *filename, struct PackedFile *pf); /* read */ int seekPackedFile(struct PackedFile *pf, int offset, int whence); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 5bcd69865fc..f072a942216 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -63,6 +63,7 @@ struct BVHTreeRayHit; #define LOOP_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) #define LOOP_EXISTING_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) if(!(pa->flag & PARS_UNEXIST)) #define LOOP_SHOWN_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) if(!(pa->flag & (PARS_UNEXIST|PARS_NO_DISP))) +#define LOOP_DYNAMIC_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) if(pa->state.time > 0.f) #define PSYS_FRAND_COUNT 1024 #define PSYS_FRAND(seed) psys->frand[(seed) % PSYS_FRAND_COUNT] @@ -226,9 +227,9 @@ void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int tim void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor); struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys); -struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, char *name); +struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name); void object_remove_particle_system(struct Scene *scene, struct Object *ob); -struct ParticleSettings *psys_new_settings(char *name, struct Main *main); +struct ParticleSettings *psys_new_settings(const char *name, struct Main *main); struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part); void make_local_particlesettings(struct ParticleSettings *part); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 8a49e432ebd..4b3d3723ab5 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -58,7 +58,7 @@ void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); void free_scene(struct Scene *sce); -struct Scene *add_scene(char *name); +struct Scene *add_scene(const char *name); struct Base *object_in_scene(struct Object *ob, struct Scene *sce); void set_scene_bg(struct Main *bmain, struct Scene *sce); @@ -76,6 +76,7 @@ char *scene_find_marker_name(struct Scene *scene, int frame); char *scene_find_last_marker_name(struct Scene *scene, int frame); int scene_marker_tfm_translate(struct Scene *scene, int delta, int flag); int scene_marker_tfm_extend(struct Scene *scene, int delta, int flag, int frame, char side); +int scene_marker_tfm_scale(struct Scene *scene, float value, int flag); struct Base *scene_add_base(struct Scene *sce, struct Object *ob); void scene_deselect_all(struct Scene *sce); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index eef56e5503b..1a9fb2d7404 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -83,6 +83,22 @@ void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int us seq_end(&iter); \ } +typedef struct SeqRenderData { + struct Main *bmain; + struct Scene *scene; + int rectx; + int recty; + int preview_render_size; + int motion_blur_samples; + float motion_blur_shutter; +} SeqRenderData; + +SeqRenderData seq_new_render_data( + struct Main * bmain, struct Scene * scene, + int rectx, int recty, int preview_render_size); + +int seq_cmp_render_data(SeqRenderData * a, SeqRenderData * b); +unsigned int seq_hash_render_data(SeqRenderData * a); /* Wipe effect */ enum {DO_SINGLE_WIPE, DO_DOUBLE_WIPE, DO_BOX_WIPE, DO_CROSS_WIPE, @@ -129,35 +145,39 @@ struct SeqEffectHandle { (mixed cases are handled one layer up...) */ struct ImBuf* (*execute)( - struct Main *bmain, - struct Scene *scene, struct Sequence *seq, float cfra, + SeqRenderData context, + struct Sequence *seq, float cfra, float facf0, float facf1, - int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3); }; /* ********************* prototypes *************** */ -/* sequence.c */ -void printf_strip(struct Sequence *seq); +/* ********************************************************************** + * sequence.c + + * sequencer render functions + ********************************************************************** */ + +struct ImBuf *give_ibuf_seq(SeqRenderData context, float cfra, int chanshown); +struct ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown); +struct ImBuf *give_ibuf_seq_direct(SeqRenderData context, float cfra, struct Sequence *seq); +struct ImBuf *give_ibuf_seqbase(SeqRenderData context, float cfra, int chan_shown, struct ListBase *seqbasep); +void give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chan_shown); /* apply functions recursively */ int seqbase_recursive_apply(struct ListBase *seqbase, int (*apply_func)(struct Sequence *seq, void *), void *arg); int seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence *, void *), void *arg); -// extern +/* maintainance functions, mostly for RNA */ +// extern void seq_free_sequence(struct Scene *scene, struct Sequence *seq); void seq_free_strip(struct Strip *strip); void seq_free_editing(struct Scene *scene); void seq_free_clipboard(void); struct Editing *seq_give_editing(struct Scene *scene, int alloc); char *give_seqname(struct Sequence *seq); -struct ImBuf *give_ibuf_seq(struct Main *bmain, struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size); -struct ImBuf *give_ibuf_seq_threaded(struct Main *bmain, struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size); -struct ImBuf *give_ibuf_seq_direct(struct Main *bmain, struct Scene *scene, int rectx, int recty, int cfra, int preview_render_size, struct Sequence *seq); -struct ImBuf *give_ibuf_seqbase(struct Main *bmain, struct Scene *scene, int rectx, int recty, int cfra, int chan_shown, int preview_render_size, struct ListBase *seqbasep); -void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size); void calc_sequence(struct Scene *scene, struct Sequence *seq); void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); void new_tstripdata(struct Sequence *seq); @@ -168,14 +188,18 @@ void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar, int *to int evaluate_seq_frame(struct Scene *scene, int cfra); struct StripElem *give_stripelem(struct Sequence *seq, int cfra); -// intern? +// intern +void printf_strip(struct Sequence *seq); // debugging function (unused) void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_seq, int len_change, int ibuf_change); int input_have_to_preprocess( - struct Scene *scene, struct Sequence * seq, - float cfra, int seqrectx, int seqrecty); + SeqRenderData context, struct Sequence * seq, float cfra); + +/* ********************************************************************** + seqcache.c -/* seqcache.c */ + Sequencer memory cache management functions + ********************************************************************** */ typedef enum { SEQ_STRIPELEM_IBUF, @@ -190,22 +214,33 @@ void seq_stripelem_cache_destruct(); void seq_stripelem_cache_cleanup(); struct ImBuf * seq_stripelem_cache_get( - struct Sequence * seq, int rectx, int recty, + SeqRenderData context, struct Sequence * seq, float cfra, seq_stripelem_ibuf_t type); void seq_stripelem_cache_put( - struct Sequence * seq, int rectx, int recty, + SeqRenderData context, struct Sequence * seq, float cfra, seq_stripelem_ibuf_t type, struct ImBuf * nval); +/* ********************************************************************** + seqeffects.c -/* seqeffects.c */ -// intern? + Sequencer effect strip managment functions + ********************************************************************** +*/ + +/* intern */ struct SeqEffectHandle get_sequence_blend(struct Sequence *seq); void sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, int force); -// extern +/* extern */ struct SeqEffectHandle get_sequence_effect(struct Sequence *seq); int get_sequence_effect_num_inputs(int seq_type); + +/* ********************************************************************** + Sequencer editing functions + ********************************************************************** +*/ + /* for transform but also could use elsewhere */ int seq_tx_get_start(struct Sequence *seq); int seq_tx_get_end(struct Sequence *seq); diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 190b0400aff..fb1a3c43006 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -47,7 +47,7 @@ void sound_exit(); void sound_force_device(int device); int sound_define_from_str(char *str); -struct bSound* sound_new_file(struct Main *main, char* filename); +struct bSound* sound_new_file(struct Main *main, const char *filename); // XXX unused currently #if 0 diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index bcda86fdae4..f98d5842eb5 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -43,13 +43,13 @@ struct SpaceText; void free_text (struct Text *text); void txt_set_undostate (int u); int txt_get_undostate (void); -struct Text* add_empty_text (char *name); +struct Text* add_empty_text (const char *name); int reopen_text (struct Text *text); -struct Text* add_text (char *file, const char *relpath); +struct Text* add_text (const char *file, const char *relpath); struct Text* copy_text (struct Text *ta); void unlink_text (struct Main *bmain, struct Text *text); void clear_text(struct Text *text); -void write_text(struct Text *text, char *str); +void write_text(struct Text *text, const char *str); char* txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h index 7461d43e721..f8ffd1cd188 100644 --- a/source/blender/blenkernel/BKE_unit.h +++ b/source/blender/blenkernel/BKE_unit.h @@ -51,10 +51,11 @@ int bUnit_IsValid(int system, int type); /* loop over scales, coudl add names later */ //double bUnit_Iter(void **unit, char **name, int system, int type); -void bUnit_GetSystem(void **usys_pt, int *len, int system, int type); -char* bUnit_GetName(void *usys_pt, int index); -char* bUnit_GetNameDisplay(void *usys_pt, int index); -double bUnit_GetScaler(void *usys_pt, int index); +void bUnit_GetSystem(void **usys_pt, int *len, int system, int type); +int bUnit_GetBaseUnit(void *usys_pt); +const char* bUnit_GetName(void *usys_pt, int index); +const char* bUnit_GetNameDisplay(void *usys_pt, int index); +double bUnit_GetScaler(void *usys_pt, int index); /* aligned with PropertyUnit */ #define B_UNIT_NONE 0 diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h index 9d763e8f003..8c6da40fcea 100644 --- a/source/blender/blenkernel/BKE_world.h +++ b/source/blender/blenkernel/BKE_world.h @@ -34,7 +34,7 @@ struct World; void free_world(struct World *sc); -struct World *add_world(char *name); +struct World *add_world(const char *name); struct World *copy_world(struct World *wrld); void make_local_world(struct World *wrld); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 45475502831..7722b3bc6f9 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -215,9 +215,8 @@ IF(WITH_LZMA) ADD_DEFINITIONS(-DWITH_LZMA) ENDIF(WITH_LZMA) -IF(WIN32) +IF(MSVC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) +ENDIF(MSVC) BLENDERLIB(bf_blenkernel "${SRC}" "${INC}") diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 6bbcecce2f7..b58bd8c7f3e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1441,7 +1441,7 @@ static Object *find_family_object(Object **obar, char *family, char ch) static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated) { - Object *ob, *obar[256]; + Object *ob, *obar[256]= {0}; Curve *cu; struct chartrans *ct, *chartransdata; float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof; @@ -1456,9 +1456,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i chartransdata= BKE_text_to_curve(scene, par, FO_DUPLI); if(chartransdata==0) return; - - memset(obar, 0, 256*sizeof(void *)); - + cu= par->data; slen= strlen(cu->str); fsize= cu->fsize; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index edda8a2547d..205d23ea829 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -39,9 +39,10 @@ #include "BKE_library.h" #include "BLI_dynstr.h" - #include "DNA_anim_types.h" +#include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "DNA_texture_types.h" #include "BKE_animsys.h" #include "BKE_action.h" @@ -1614,9 +1615,6 @@ void nladata_flush_channels (ListBase *channels) */ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) { - ListBase dummy_trackslist = {NULL, NULL}; - NlaStrip dummy_strip; - NlaTrack *nlt; short track_index=0; short has_strips = 0; @@ -1659,7 +1657,9 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* if there are strips, evaluate action as per NLA rules */ if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ - memset(&dummy_strip, 0, sizeof(NlaStrip)); + NlaStrip dummy_strip= {0}; + ListBase dummy_trackslist; + dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { @@ -1844,7 +1844,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) if (G.f & G_DEBUG) printf("Evaluate all animation - %f \n", ctime); - /* macro for less typing + /* macros for less typing * - only evaluate animation data for id if it has users (and not just fake ones) * - whether animdata exists is checked for by the evaluation function, though taking * this outside of the function may make things slightly faster? @@ -1856,6 +1856,24 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \ } \ } + /* another macro for the "embedded" nodetree cases + * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees" + * (i.e. scene/material/texture->nodetree) which we need a special exception + * for, otherwise they'd get skipped + * - ntp = "node tree parent" = datablock where node tree stuff resides + */ +#define EVAL_ANIM_NODETREE_IDS(first, NtId_Type, aflag) \ + for (id= first; id; id= id->next) { \ + if (ID_REAL_USERS(id) > 0) { \ + AnimData *adt= BKE_animdata_from_id(id); \ + NtId_Type *ntp= (NtId_Type *)id; \ + if (ntp->nodetree) { \ + AnimData *adt2= BKE_animdata_from_id((ID *)ntp->nodetree); \ + BKE_animsys_evaluate_animdata((ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \ + } \ + BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \ + } \ + } /* optimisation: * when there are no actions, don't go over database and loop over heaps of datablocks, @@ -1876,13 +1894,13 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) EVAL_ANIM_IDS(main->nodetree.first, ADT_RECALC_ANIM); /* textures */ - EVAL_ANIM_IDS(main->tex.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM); /* lamps */ EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM); /* materials */ - EVAL_ANIM_IDS(main->mat.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM); /* cameras */ EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM); @@ -1920,19 +1938,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM); /* scenes */ - for (id= main->scene.first; id; id= id->next) { - AnimData *adt= BKE_animdata_from_id(id); - Scene *scene= (Scene *)id; - - /* do compositing nodes first (since these aren't included in main tree) */ - if (scene->nodetree) { - AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); - BKE_animsys_evaluate_animdata((ID *)scene->nodetree, adt2, ctime, ADT_RECALC_ANIM); - } - - /* now execute scene animation data as per normal */ - BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); - } + EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM); } /* ***************************************** */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index ea01421a0ea..d2861a8942c 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -69,7 +69,7 @@ /* **************** Generic Functions, data level *************** */ -bArmature *add_armature(char *name) +bArmature *add_armature(const char *name) { bArmature *arm; @@ -813,9 +813,9 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, bDeformGroup *dg; DualQuat *dualquats= NULL; float obinv[4][4], premat[4][4], postmat[4][4]; - int use_envelope = deformflag & ARM_DEF_ENVELOPE; - int use_quaternion = deformflag & ARM_DEF_QUATERNION; - int invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP; + const short use_envelope = deformflag & ARM_DEF_ENVELOPE; + const short use_quaternion = deformflag & ARM_DEF_QUATERNION; + const short invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP; int numGroups = 0; /* safety for vertexgroup index overflow */ int i, target_totvert = 0; /* safety for vertexgroup overflow */ int use_dverts = 0; @@ -1456,10 +1456,6 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected if(error) return; - /* exception, armature local layer should be proxied too */ - if (pose->proxy_layer) - ((bArmature *)ob->data)->layer= pose->proxy_layer; - /* clear all transformation values from library */ rest_pose(frompose); @@ -1734,28 +1730,25 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos ikData->numpoints= ikData->chainlen+1; ikData->points= MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding"); + /* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */ + ikData->points[0] = 1.0f; + /* perform binding of the joints to parametric positions along the curve based * proportion of the total length that each bone occupies */ for (i = 0; i < segcount; i++) { - if (i != 0) { - /* 'head' joints - * - 2 methods; the one chosen depends on whether we've got usable lengths - */ - if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) { - /* 1) equi-spaced joints */ - ikData->points[i]= ikData->points[i-1] - segmentLen; - } - else { - /* 2) to find this point on the curve, we take a step from the previous joint - * a distance given by the proportion that this bone takes - */ - ikData->points[i]= ikData->points[i-1] - (boneLengths[i] / totLength); - } + /* 'head' joints, travelling towards the root of the chain + * - 2 methods; the one chosen depends on whether we've got usable lengths + */ + if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) { + /* 1) equi-spaced joints */ + ikData->points[i+1]= ikData->points[i] - segmentLen; } else { - /* 'tip' of chain, special exception for the first joint */ - ikData->points[0]= 1.0f; + /* 2) to find this point on the curve, we take a step from the previous joint + * a distance given by the proportion that this bone takes + */ + ikData->points[i+1]= ikData->points[i] - (boneLengths[i] / totLength); } } @@ -2410,7 +2403,7 @@ void where_is_pose (Scene *scene, Object *ob) if(ELEM(NULL, arm, scene)) return; if((ob->pose==NULL) || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, arm); + armature_rebuild_pose(ob, arm); ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0); /* not accurate... */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d2b437d9833..6911e7fd581 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -197,7 +197,7 @@ static void clean_paths(Main *main) /* context matching */ /* handle no-ui case */ -static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) +static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename) { bScreen *curscreen= NULL; Scene *curscene= NULL; @@ -237,6 +237,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) } /* free G.main Main database */ +// CTX_wm_manager_set(C, NULL); clear_global(); G.main= bfd->main; @@ -261,7 +262,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) G.winpos= bfd->winpos; G.displaymode= bfd->displaymode; G.fileflags= bfd->fileflags; - + CTX_wm_manager_set(C, bfd->main->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscreen->scene); CTX_wm_area_set(C, NULL); @@ -364,7 +365,7 @@ void BKE_userdef_free(void) 2: OK, and with new user settings */ -int BKE_read_file(bContext *C, char *dir, ReportList *reports) +int BKE_read_file(bContext *C, const char *dir, ReportList *reports) { BlendFileData *bfd; int retval= 1; @@ -486,7 +487,7 @@ static int read_undosave(bContext *C, UndoElem *uel) } /* name can be a dynamic string */ -void BKE_write_undo(bContext *C, char *name) +void BKE_write_undo(bContext *C, const char *name) { uintptr_t maxmem, totmem, memused; int nr, success; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 671bcb36680..882295b931c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -36,6 +36,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_utildefines.h" +#include "BLI_editVert.h" #include "BLI_math.h" #include "MEM_guardedalloc.h" @@ -577,16 +578,34 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if(tree != NULL) { - for(i = 0; i < numFaces; i++) - { - float co[4][3]; - VECCOPY(co[0], vert[ face[i].v1 ].co); - VECCOPY(co[1], vert[ face[i].v2 ].co); - VECCOPY(co[2], vert[ face[i].v3 ].co); - if(face[i].v4) - VECCOPY(co[3], vert[ face[i].v4 ].co); - - BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */ + EditMesh *em= data->em_evil; + if(em) { + EditFace *efa= em->faces.first; + for(i = 0; i < numFaces; i++, efa= efa->next) { + if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); + + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } + } + } + else { + for(i = 0; i < numFaces; i++) { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); + + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } } BLI_bvhtree_balance(tree); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 5dff21d8af4..076dae41e6a 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3814,7 +3814,6 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t /* pivot correction */ float axis[3], angle; - float dvec[3]; /* firstly, check if pivoting should take place based on the current rotation */ if (data->rotAxis != PIVOTCON_AXIS_NONE) { @@ -3861,14 +3860,16 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t /* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */ mat3_to_axis_angle(axis, &angle, rotMat); - sub_v3_v3v3(vec, pivot, cob->matrix[3]); - project_v3_v3v3(dvec, vec, axis); - sub_v3_v3(pivot, dvec); - + if(angle) { + float dvec[3]; + sub_v3_v3v3(vec, pivot, cob->matrix[3]); + project_v3_v3v3(dvec, vec, axis); + sub_v3_v3(pivot, dvec); + } /* perform the pivoting... */ /* 1. take the vector from owner to the pivot */ - sub_v3_v3v3(vec, pivot, cob->matrix[3]); + sub_v3_v3v3(vec, cob->matrix[3], pivot); /* 2. rotate this vector by the rotation of the object... */ mul_m3_v3(rotMat, vec); /* 3. make the rotation in terms of the pivot now */ diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 899ae6031d6..fe010d812b1 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -108,7 +108,7 @@ void CTX_free(bContext *C) /* store */ -bContextStore *CTX_store_add(ListBase *contexts, char *name, PointerRNA *ptr) +bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr) { bContextStoreEntry *entry; bContextStore *ctx, *lastctx; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 79e0393cdca..42d1c13c9ac 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -130,7 +130,7 @@ void free_curve(Curve *cu) if(cu->tb) MEM_freeN(cu->tb); } -Curve *add_curve(char *name, int type) +Curve *add_curve(const char *name, int type) { Curve *cu; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index beb6c085d64..1ef1cefa120 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -984,7 +984,7 @@ int CustomData_get_layer_index(const CustomData *data, int type) return -1; } -int CustomData_get_named_layer_index(const CustomData *data, int type, char *name) +int CustomData_get_named_layer_index(const CustomData *data, int type, const char *name) { int i; @@ -1371,7 +1371,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type) } void *CustomData_duplicate_referenced_layer_named(struct CustomData *data, - int type, char *name) + int type, const char *name) { CustomDataLayer *layer; int layer_index; @@ -1603,7 +1603,7 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n) } void *CustomData_get_layer_named(const struct CustomData *data, int type, - char *name) + const char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if(layer_index < 0) return NULL; diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index a1af728c562..c16d566c7c5 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -85,11 +85,11 @@ #include "zlib.h" -static int is_dxf(char *str); -static void dxf_read(Scene *scene, char *filename); -static int is_stl(char *str); +static int is_dxf(const char *str); +static void dxf_read(Scene *scene, const char *filename); +static int is_stl(const char *str); -static int is_stl_ascii(char *str) +static int is_stl_ascii(const char *str) { FILE *fpSTL; char buffer[1000]; @@ -114,7 +114,7 @@ static int is_stl_ascii(char *str) return 1; } -static int is_stl(char *str) +static int is_stl(const char *str) { int i; i = strlen(str) - 3; @@ -190,7 +190,7 @@ static void mesh_add_normals_flags(Mesh *me) } } -static void read_stl_mesh_binary(Scene *scene, char *str) +static void read_stl_mesh_binary(Scene *scene, const char *str) { FILE *fpSTL; Object *ob; @@ -314,7 +314,7 @@ static void read_stl_mesh_binary(Scene *scene, char *str) STLBAILOUT("Bad vertex!"); \ ++totvert; \ } -static void read_stl_mesh_ascii(Scene *scene, char *str) +static void read_stl_mesh_ascii(Scene *scene, const char *str) { FILE *fpSTL; char buffer[2048], *cp; @@ -454,7 +454,7 @@ static void read_stl_mesh_ascii(Scene *scene, char *str) /* ************************************************************ */ -int BKE_read_exotic(Scene *scene, char *name) +int BKE_read_exotic(Scene *scene, const char *name) { int len; gzFile gzfile; @@ -1069,7 +1069,7 @@ static char val[256]; static short error_exit=0; static short hasbumped=0; -static int is_dxf(char *str) +static int is_dxf(const char *str) { dxf_line=0; @@ -2207,7 +2207,7 @@ static void dxf_read_3dface(Scene *scene, int noob) hasbumped=1; } -static void dxf_read(Scene *scene, char *filename) +static void dxf_read(Scene *scene, const char *filename) { Mesh *lastMe = G.main->mesh.last; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 75029af4b10..888eae3ed78 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -163,7 +163,7 @@ void copy_fcurves (ListBase *dst, ListBase *src) } } -/* --------------------- Finding -------------------------- */ +/* ----------------- Finding F-Curves -------------------------- */ /* high level function to get an fcurve from C without having the rna */ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index) @@ -298,36 +298,36 @@ int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix return matches; } -FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) +FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) { FCurve *fcu= NULL; *driven= 0; /* there must be some RNA-pointer + property combon */ - if(prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { + if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { AnimData *adt= BKE_animdata_from_id(ptr->id.data); char *path; - if(adt) { - if((adt->action && adt->action->curves.first) || (adt->drivers.first)) { + if (adt) { + if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) { /* XXX this function call can become a performance bottleneck */ path= RNA_path_from_ID_to_property(ptr, prop); - if(path) { + if (path) { /* animation takes priority over drivers */ - if(adt->action && adt->action->curves.first) + if (adt->action && adt->action->curves.first) fcu= list_find_fcurve(&adt->action->curves, path, rnaindex); /* if not animated, check if driven */ - if(!fcu && (adt->drivers.first)) { + if (!fcu && (adt->drivers.first)) { fcu= list_find_fcurve(&adt->drivers, path, rnaindex); - if(fcu) + if (fcu) *driven= 1; } - if(fcu && action) + if (fcu && action) *action= adt->action; MEM_freeN(path); @@ -339,6 +339,8 @@ FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction return fcu; } +/* ----------------- Finding Keyframes/Extents -------------------------- */ + /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */ #define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ @@ -520,6 +522,87 @@ void calc_fcurve_range (FCurve *fcu, float *start, float *end) } } +/* ----------------- Status Checks -------------------------- */ + +/* Are keyframes on F-Curve of any use? + * Usability of keyframes refers to whether they should be displayed, + * and also whether they will have any influence on the final result. + */ +short fcurve_are_keyframes_usable (FCurve *fcu) +{ + /* F-Curve must exist */ + if (fcu == NULL) + return 0; + + /* F-Curve must not have samples - samples are mutually exclusive of keyframes */ + if (fcu->fpt) + return 0; + + /* if it has modifiers, none of these should "drastically" alter the curve */ + if (fcu->modifiers.first) { + FModifier *fcm; + + /* check modifiers from last to first, as last will be more influential */ + // TODO: optionally, only check modifier if it is the active one... + for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { + /* ignore if muted/disabled */ + if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) + continue; + + /* type checks */ + switch (fcm->type) { + /* clearly harmless - do nothing */ + case FMODIFIER_TYPE_CYCLES: + case FMODIFIER_TYPE_STEPPED: + case FMODIFIER_TYPE_NOISE: + break; + + /* sometimes harmful - depending on whether they're "additive" or not */ + case FMODIFIER_TYPE_GENERATOR: + { + FMod_Generator *data = (FMod_Generator *)fcm->data; + + if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) + return 0; + } + break; + case FMODIFIER_TYPE_FN_GENERATOR: + { + FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; + + if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) + return 0; + } + break; + + /* always harmful - cannot allow */ + default: + return 0; + } + } + } + + /* keyframes are usable */ + return 1; +} + +/* Can keyframes be added to F-Curve? + * Keyframes can only be added if they are already visible + */ +short fcurve_is_keyframable (FCurve *fcu) +{ + /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */ + if (fcurve_are_keyframes_usable(fcu) == 0) + return 0; + + /* F-Curve must currently be editable too */ + if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) + return 0; + + /* F-Curve is keyframable */ + return 1; +} + /* ***************************** Keyframe Column Tools ********************************* */ /* add a BezTriple to a column */ @@ -851,31 +934,44 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) /* get property to read from, and get value as appropriate */ if (RNA_path_resolve_full(&id_ptr, dtar->rna_path, &ptr, &prop, &index)) { - switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - if (RNA_property_array_length(&ptr, prop)) + if(RNA_property_array_check(&ptr, prop)) { + /* array */ + if (index < RNA_property_array_length(&ptr, prop)) { + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: value= (float)RNA_property_boolean_get_index(&ptr, prop, index); - else - value= (float)RNA_property_boolean_get(&ptr, prop); + break; + case PROP_INT: + value= (float)RNA_property_int_get_index(&ptr, prop, index); + break; + case PROP_FLOAT: + value= RNA_property_float_get_index(&ptr, prop, index); + break; + default: + break; + } + } + } + else { + /* not an array */ + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: + value= (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(&ptr, prop)) - value= (float)RNA_property_int_get_index(&ptr, prop, index); - else - value= (float)RNA_property_int_get(&ptr, prop); + value= (float)RNA_property_int_get(&ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(&ptr, prop)) - value= RNA_property_float_get_index(&ptr, prop, index); - else - value= RNA_property_float_get(&ptr, prop); + value= RNA_property_float_get(&ptr, prop); break; case PROP_ENUM: value= (float)RNA_property_enum_get(&ptr, prop); break; default: break; + } } + } else { if (G.f & G_DEBUG) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5fdb9549179..500ccf0781b 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -124,31 +124,27 @@ wcsleninu8(wchar_t *src) } static int -utf8slen(char *src) +utf8slen(const char *strc) { - int size = 0, index = 0; - unsigned char c; - - c = src[index++]; - while(c) - { - if((c & 0x80) == 0) - { - index += 0; - } - else if((c & 0xe0) == 0xe0) - { - index += 2; - } - else - { - index += 1; + int len=0; + + while(*strc) { + if ((*strc & 0xe0) == 0xc0) { + if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00) + strc++; + } else if ((*strc & 0xf0) == 0xe0) { + if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00) + strc += 2; + } else if ((*strc & 0xf8) == 0xf0) { + if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00) + strc += 3; } - size += 1; - c = src[index++]; + + strc++; + len++; } - - return size; + + return len; } @@ -358,7 +354,7 @@ static VFontData *vfont_get_data(VFont *vfont) return vfont->data; } -VFont *load_vfont(char *name) +VFont *load_vfont(const char *name) { char filename[FILE_MAXFILE]; VFont *vfont= NULL; diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 5a031d62fcb..e125f3d4bd7 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -128,7 +128,7 @@ void unlink_group(Group *group) group->id.us= 0; } -Group *add_group(char *name) +Group *add_group(const char *name) { Group *group; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 639e2062f83..c837f02279b 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -341,7 +341,7 @@ IDProperty *IDP_CopyString(IDProperty *prop) } -void IDP_AssignString(IDProperty *prop, char *st, int maxlen) +void IDP_AssignString(IDProperty *prop, const char *st, int maxlen) { int stlen; @@ -356,7 +356,7 @@ void IDP_AssignString(IDProperty *prop, char *st, int maxlen) BLI_strncpy(prop->data.pointer, st, stlen); } -void IDP_ConcatStringC(IDProperty *prop, char *st) +void IDP_ConcatStringC(IDProperty *prop, const char *st) { int newlen; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a2435801ac6..b624feeaf9d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -382,7 +382,7 @@ Image *BKE_add_image_file(const char *name) return ima; } -static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; unsigned char *rect= NULL; @@ -415,7 +415,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); @@ -985,29 +985,13 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } } -// XXX - Bad level call. -extern int datatoc_bmonofont_ttf_size; -extern char datatoc_bmonofont_ttf[]; - -// XXX - copied from text_font_begin ! Change all the BLF_* here -static int mono= -1; - -int stamp_font_begin(int size) -{ - if (mono == -1) - mono= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - - BLF_aspect(mono, 1.0); - BLF_size(mono, size, 72); - return(mono); // XXX This is for image_gen.c!! -} - void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) { struct StampData stamp_data; float w, h, pad; int x, y; float h_fixed; + const int mono= blf_mono_font_render; // XXX if (!rect && !rectf) return; @@ -1018,8 +1002,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i if(scene->r.stamp_font_id < 8) scene->r.stamp_font_id= 12; - stamp_font_begin(scene->r.stamp_font_id); - + /* set before return */ + BLF_aspect(mono, 1.0); + BLF_size(mono, scene->r.stamp_font_id, 72); + BLF_buffer(mono, rectf, rect, width, height, channels); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad= BLF_width(mono, "--"); @@ -1202,7 +1188,7 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } -int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) +int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) { int ok; (void)subimtype; /* quies unused warnings */ @@ -2169,6 +2155,7 @@ void BKE_image_release_ibuf(Image *ima, void *lock) } } +/* warning, this can allocate generated images */ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) { return BKE_image_acquire_ibuf(ima, iuser, NULL); diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 9248ce69280..b765cf29a3d 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -298,16 +298,17 @@ static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int } /* defined in image.c */ -extern int stamp_font_begin(int size); static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline) { - int x, y, mono; + int x, y; int pen_x, pen_y; char text[3]= {'A', '1', '\0'}; + const int mono= blf_mono_font; + + BLF_aspect(mono, 1.0); + BLF_size(mono, 54, 72); /* hard coded size! */ - /* hard coded size! */ - mono= stamp_font_begin(54); BLF_buffer(mono, rect_float, rect, width, height, 4); for(y= 0; y < height; y+=step) diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index aa9d0b4f57c..c18085b2d73 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1441,7 +1441,7 @@ Key *ob_get_key(Object *ob) return NULL; } -KeyBlock *add_keyblock(Key *key, char *name) +KeyBlock *add_keyblock(Key *key, const char *name) { KeyBlock *kb; float curpos= -0.1; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 638cab58229..73d77e850fd 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -181,7 +181,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) MEM_freeN(vertexCos); } -Lattice *add_lattice(char *name) +Lattice *add_lattice(const char *name) { Lattice *lt; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8d869563a77..ed9a02918f1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -866,7 +866,7 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */ +ID *find_id(char *type, const char *name) /* type: "OB" or "MA" etc */ { ListBase *lb= which_libbase(G.main, GS(type)); return BLI_findstring(lb, name, offsetof(ID, name) + 2); @@ -1026,7 +1026,7 @@ static void sort_alpha_id(ListBase *lb, ID *id) * Check to see if there is an ID with the same name as 'name'. * Returns the ID if so, if not, returns NULL */ -static ID *is_dupid(ListBase *lb, ID *id, char *name) +static ID *is_dupid(ListBase *lb, ID *id, const char *name) { ID *idtest=NULL; @@ -1388,7 +1388,7 @@ void rename_id(ID *id, char *name) void name_uiprefix_id(char *name, ID *id) { name[0] = id->lib ? 'L':' '; - name[1] = id->flag & LIB_FAKEUSER ? 'F':' '; + name[1] = id->flag & LIB_FAKEUSER ? 'F': (id->us==0)?'0':' '; name[2] = ' '; strcpy(name+3, id->name+2); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3e7223e5e50..e31e2df4698 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -186,7 +186,7 @@ void init_material(Material *ma) ma->preview = NULL; } -Material *add_material(char *name) +Material *add_material(const char *name) { Material *ma; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index dc343e0d6c2..94ffaaea947 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -93,7 +93,7 @@ void free_mball(MetaBall *mb) if(mb->disp.first) freedisplist(&mb->disp); } -MetaBall *add_mball(char *name) +MetaBall *add_mball(const char *name) { MetaBall *mb; @@ -309,6 +309,19 @@ float *make_orco_mball(Object *ob, ListBase *dispbase) return orcodata; } + +/* Note on mball basis stuff 2.5x (this is a can of worms) + * This really needs a rewrite/refactorm its totally broken in anything other then basic cases + * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename + * and linking into scenes or removal of basis mball. so take care when changing this code. + * + * Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test. + * + * Not only that but the depsgraph and ther areas depend on this behavior!, so making small fixes here isnt worth it. + * - campbell + */ + + /** \brief Test, if Object *ob is basic MetaBall. * * It test last character of Object ID name. If last character @@ -385,6 +398,8 @@ void copy_mball_properties(Scene *scene, Object *active_object) * its name. All MetaBalls with same base of name can be * blended. MetaBalls with different basic name can't be * blended. + * + * warning!, is_basis_mball() can fail on returned object, see long note above. */ Object *find_basis_mball(Scene *scene, Object *basis) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f5a563faa6f..eb413187544 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -184,7 +184,7 @@ void free_dverts(MDeformVert *dvert, int totvert) MEM_freeN (dvert); } -Mesh *add_mesh(char *name) +Mesh *add_mesh(const char *name) { Mesh *me; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5e3c147a99f..7f7433f8965 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1325,6 +1325,52 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) multires_mvert_to_ss(dm, vdst); } +/* Copy the first-level vcol data to the mesh, if it exists */ +/* Warning: higher-level vcol data will be lost */ +static void multires_load_old_vcols(Mesh *me) +{ + MultiresLevel *lvl; + MultiresColFace *colface; + MCol *mcol; + int i, j; + + if(!(lvl = me->mr->levels.first)) + return; + + if(!(colface = lvl->colfaces)) + return; + + /* older multires format never supported multiple vcol layers, + so we can assume the active vcol layer is the correct one */ + if(!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL))) + return; + + for(i = 0; i < me->totface; ++i) { + for(j = 0; j < 4; ++j) { + mcol[i*4 + j].a = colface[i].col[j].a; + mcol[i*4 + j].r = colface[i].col[j].r; + mcol[i*4 + j].g = colface[i].col[j].g; + mcol[i*4 + j].b = colface[i].col[j].b; + } + } +} + +/* Copy the first-level face-flag data to the mesh */ +static void multires_load_old_face_flags(Mesh *me) +{ + MultiresLevel *lvl; + MultiresFace *faces; + int i; + + if(!(lvl = me->mr->levels.first)) + return; + + if(!(faces = lvl->faces)) + return; + + for(i = 0; i < me->totface; ++i) + me->mface[i].flag = faces[i].flag; +} void multires_load_old(Object *ob, Mesh *me) { @@ -1386,6 +1432,9 @@ void multires_load_old(Object *ob, Mesh *me) memset(&me->mr->vdata, 0, sizeof(CustomData)); memset(&me->mr->fdata, 0, sizeof(CustomData)); + multires_load_old_vcols(me); + multires_load_old_face_flags(me); + /* Remove the old multires */ multires_free(me->mr); me->mr= NULL; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a10901d15d6..fe557dfefa0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -693,7 +693,7 @@ int exist_object(Object *obtest) return 0; } -void *add_camera(char *name) +void *add_camera(const char *name) { Camera *cam; @@ -794,7 +794,7 @@ float dof_camera(Object *ob) return cam->YF_dofdist; } -void *add_lamp(char *name) +void *add_lamp(const char *name) { Lamp *la; @@ -989,7 +989,7 @@ static char *get_obdata_defname(int type) } /* more general add: creates minimum required data, but without vertices etc. */ -Object *add_only_object(int type, char *name) +Object *add_only_object(int type, const char *name) { Object *ob; @@ -2534,48 +2534,53 @@ void object_handle_update(Scene *scene, Object *ob) if (G.f & G_DEBUG) printf("recalcdata %s\n", ob->id.name+2); - - /* includes all keys and modifiers */ - if(ob->type==OB_MESH) { - EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; - - /* evaluate drivers */ - // XXX: should we push this to derivedmesh instead? - BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); - - // here was vieweditdatamask? XXX - if(em) { - makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); - BKE_mesh_end_editmesh(ob->data, em); - } else - makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH); - } - else if(ob->type==OB_MBALL) { - makeDispListMBall(scene, ob); - } - else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - makeDispListCurveTypes(scene, ob, 0); - } - else if(ELEM(ob->type, OB_CAMERA, OB_LAMP)) { + + if(adt) { /* evaluate drivers */ + // XXX: for mesh types, should we push this to derivedmesh instead? BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); } - else if(ob->type==OB_LATTICE) { - lattice_calc_modifiers(scene, ob); - } - else if(ob->type==OB_ARMATURE) { - /* evaluate drivers */ - BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); - + + /* includes all keys and modifiers */ + switch(ob->type) { + case OB_MESH: + { + EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + // here was vieweditdatamask? XXX + if(em) { + makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); + BKE_mesh_end_editmesh(ob->data, em); + } else + makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH); + } + break; + + case OB_ARMATURE: if(ob->id.lib && ob->proxy_from) { - copy_pose_result(ob->pose, ob->proxy_from->pose); // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); + copy_pose_result(ob->pose, ob->proxy_from->pose); } else { where_is_pose(scene, ob); } + break; + + case OB_MBALL: + makeDispListMBall(scene, ob); + break; + + case OB_CURVE: + case OB_SURF: + case OB_FONT: + makeDispListCurveTypes(scene, ob, 0); + break; + + case OB_LATTICE: + lattice_calc_modifiers(scene, ob); + break; } + if(ob->particlesystem.first) { ParticleSystem *tpsys, *psys; DerivedMesh *dm; @@ -2899,7 +2904,7 @@ void object_delete_ptcache(Object *ob, int index) /* shape key utility function */ /************************* Mesh ************************/ -static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_mix) +static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int from_mix) { Mesh *me= ob->data; Key *key= me->key; @@ -2930,7 +2935,7 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_m return kb; } /************************* Lattice ************************/ -static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_mix) +static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int from_mix) { Lattice *lt= ob->data; Key *key= lt->key; @@ -2962,7 +2967,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_m return kb; } /************************* Curve ************************/ -static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_mix) +static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int from_mix) { Curve *cu= ob->data; Key *key= cu->key; @@ -2998,7 +3003,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_ return kb; } -KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, char *name, int from_mix) +KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix) { if(ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix); else if ELEM(ob->type, OB_CURVE, OB_SURF)return insert_curvekey(scene, ob, name, from_mix); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 7d7f73222fa..c278bf3b3d2 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -162,7 +162,7 @@ PackedFile *newPackedFileMemory(void *mem, int memlen) return pf; } -PackedFile *newPackedFile(ReportList *reports, char *filename) +PackedFile *newPackedFile(ReportList *reports, const char *filename) { PackedFile *pf = NULL; int file, filelen; @@ -263,7 +263,7 @@ static char *find_new_name(char *name) */ -int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int guimode) +int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, int guimode) { int file, number, remove_tmp = FALSE; int ret_value = RET_OK; @@ -331,7 +331,7 @@ PF_NOFILE - the original file doens't exist */ -int checkPackedFile(char *filename, PackedFile *pf) +int checkPackedFile(const char *filename, PackedFile *pf) { struct stat st; int ret_val, i, len, file; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0dc0b67b377..2eff81b96a6 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3386,7 +3386,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa /************************************************/ /* ParticleSettings handling */ /************************************************/ -ModifierData *object_add_particle_system(Scene *scene, Object *ob, char *name) +ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *name) { ParticleSystem *psys; ModifierData *md; @@ -3543,7 +3543,7 @@ static void default_particle_settings(ParticleSettings *part) } -ParticleSettings *psys_new_settings(char *name, Main *main) +ParticleSettings *psys_new_settings(const char *name, Main *main) { ParticleSettings *part; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f58ab63ff81..63f2d692c6d 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2291,132 +2291,121 @@ static void psys_update_effectors(ParticleSimulationData *sim) precalc_guides(sim, sim->psys->effectors); } -/************************************************* +/********************************************************************************************************* SPH fluid physics - In theory, there could be unlimited implementation - of SPH simulators -**************************************************/ -void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float UNUSED(cfra), float mass){ -/**************************************************************************************************************** -* This code uses in some parts adapted algorithms from the pseduo code as outlined in the Research paper -* Titled: Particle-based Viscoelastic Fluid Simulation. -* Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin -* -* Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/ -* Presented at Siggraph, (2005) -* -*****************************************************************************************************************/ - KDTree *tree = psys->tree; + In theory, there could be unlimited implementation of SPH simulators + + This code uses in some parts adapted algorithms from the pseudo code as outlined in the Research paper: + + Titled: Particle-based Viscoelastic Fluid Simulation. + Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin + Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/ + + Presented at Siggraph, (2005) + +***********************************************************************************************************/ +static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *pa, float dtime, float mass, float *gravity) +{ + SPHFluidSettings *fluid = psys->part->fluid; KDTreeNearest *ptn = NULL; - - SPHFluidSettings *fluid = part->fluid; - ParticleData *second_particle; + ParticleData *npa; - float start[3], end[3], v[3]; float temp[3]; - float q, radius, D; - float p, pnear, pressure_near, pressure; - float dtime = dfra * psys_get_timestep(sim); + float q, q1, u, I, D; + float pressure_near, pressure; + float p=0, pnear=0; + + float radius = fluid->radius; float omega = fluid->viscosity_omega; - float beta = fluid->viscosity_omega; + float beta = fluid->viscosity_beta; float massfactor = 1.0f/mass; - int n, neighbours; - - - radius = fluid->radius; + float spring_k = fluid->spring_k; + float L = fluid->rest_length; - VECCOPY(start, pa->prev_state.co); - VECCOPY(end, pa->state.co); + int n, neighbours = BLI_kdtree_range_search(psys->tree, radius, pa->prev_state.co, NULL, &ptn); + int index = own_psys ? pa - psys->particles : -1; - VECCOPY(v, pa->state.vel); - - neighbours = BLI_kdtree_range_search(tree, radius, start, NULL, &ptn); - - /* use ptn[n].co to store relative direction */ - for(n=1; n<neighbours; n++) { - sub_v3_v3(ptn[n].co, start); - normalize_v3(ptn[n].co); - } - - /* Viscosity - Algorithm 5 */ - if (omega > 0.f || beta > 0.f) { - float u, I; - - for(n=1; n<neighbours; n++) { - second_particle = psys->particles + ptn[n].index; - q = ptn[n].dist/radius; - - sub_v3_v3v3(temp, v, second_particle->prev_state.vel); - - u = dot_v3v3(ptn[n].co, temp); + /* pressure and near pressure */ + for(n=own_psys?1:0; n<neighbours; n++) { + sub_v3_v3(ptn[n].co, pa->prev_state.co); + mul_v3_fl(ptn[n].co, 1.f/ptn[n].dist); + q = ptn[n].dist/radius; - if (u > 0){ - I = dtime * ((1-q) * (omega * u + beta * u*u)) * 0.5f; - madd_v3_v3fl(v, ptn[n].co, -I * massfactor); - } - } - } + if(q < 1.f) { + q1 = 1.f - q; - /* Hooke's spring force */ - if (fluid->spring_k > 0.f) { - float D, L = fluid->rest_length; - for(n=1; n<neighbours; n++) { - /* L is a factor of radius */ - D = dtime * 10.f * fluid->spring_k * (1.f - L) * (L - ptn[n].dist/radius); - madd_v3_v3fl(v, ptn[n].co, -D * massfactor); + p += q1*q1; + pnear += q1*q1*q1; } } - /* Update particle position */ - VECADDFAC(end, start, v, dtime); - /* Double Density Relaxation - Algorithm 2 */ - p = 0; - pnear = 0; - for(n=1; n<neighbours; n++) { - q = ptn[n].dist/radius; - p += ((1-q)*(1-q)); - pnear += ((1-q)*(1-q)*(1-q)); - } - p *= part->mass; - pnear *= part->mass; + p *= mass; + pnear *= mass; pressure = fluid->stiffness_k * (p - fluid->rest_density); pressure_near = fluid->stiffness_knear * pnear; - for(n=1; n<neighbours; n++) { + /* main calculations */ + for(n=own_psys?1:0; n<neighbours; n++) { + npa = psys->particles + ptn[n].index; + q = ptn[n].dist/radius; + q1 = 1.f-q; + + /* Double Density Relaxation - Algorithm 2 (can't be thread safe!)*/ + D = dtime * dtime * (pressure + pressure_near*q1)*q1 * 0.5f; + madd_v3_v3fl(pa->state.co, ptn[n].co, -D * massfactor); + if(own_psys) + madd_v3_v3fl(npa->state.co, ptn[n].co, D * massfactor); + + if(index < ptn[n].index) { + /* Viscosity - Algorithm 5 */ + if(omega > 0.f || beta > 0.f) { + sub_v3_v3v3(temp, pa->state.vel, npa->state.vel); + u = dot_v3v3(ptn[n].co, temp); + + if (u > 0){ + I = dtime * (q1 * (omega * u + beta * u*u)) * 0.5f; + madd_v3_v3fl(pa->state.vel, ptn[n].co, -I * massfactor); + + if(own_psys) + madd_v3_v3fl(npa->state.vel, ptn[n].co, I * massfactor); + } + } - D = dtime * dtime * (pressure*(1-q) + pressure_near*(1-q)*(1-q))* 0.5f; - madd_v3_v3fl(end, ptn[n].co, -D * massfactor); - } + /* Hooke's spring force */ + if(spring_k > 0.f) { + /* L is a factor of radius */ + D = 0.5 * dtime * dtime * 10.f * fluid->spring_k * (1.f - L) * (L - q); + + madd_v3_v3fl(pa->state.co, ptn[n].co, -D * massfactor); + if(own_psys) + madd_v3_v3fl(npa->state.co, ptn[n].co, D * massfactor); + } + } + } /* Artificial buoyancy force in negative gravity direction */ - if (fluid->buoyancy >= 0.f && psys_uses_gravity(sim)) { + if (fluid->buoyancy >= 0.f && gravity) { float B = -dtime * dtime * fluid->buoyancy * (p - fluid->rest_density) * 0.5f; - madd_v3_v3fl(end, sim->scene->physics_settings.gravity, -B * massfactor); + madd_v3_v3fl(pa->state.co, gravity, -B * massfactor); } - /* apply final result and recalculate velocity */ - VECCOPY(pa->state.co, end); - sub_v3_v3v3(pa->state.vel, end, start); - mul_v3_fl(pa->state.vel, 1.f/dtime); - - if(ptn){ MEM_freeN(ptn); ptn=NULL;} + if(ptn) + MEM_freeN(ptn); } -static void apply_particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float cfra){ +static void apply_particle_fluidsim(Object *ob, ParticleSystem *psys, ParticleData *pa, float dtime, float *gravity){ ParticleTarget *pt; -// float dtime = dfra*psys_get_timestep(sim); - float particle_mass = part->mass; - particle_fluidsim(psys, pa, part, sim, dfra, cfra, particle_mass); + particle_fluidsim(psys, 1, pa, dtime, psys->part->mass, gravity); /*----check other SPH systems (Multifluids) , each fluid has its own parameters---*/ - for(pt=sim->psys->targets.first; pt; pt=pt->next) { - ParticleSystem *epsys = psys_get_target_system(sim->ob, pt); + for(pt=psys->targets.first; pt; pt=pt->next) { + ParticleSystem *epsys = psys_get_target_system(ob, pt); if(epsys) - particle_fluidsim(epsys, pa, epsys->part, sim, dfra, cfra, particle_mass); + particle_fluidsim(epsys, 0, pa, dtime, psys->part->mass, gravity); } /*----------------------------------------------------------------*/ } @@ -3372,17 +3361,15 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* current time */ float ctime; /* frame & time changes */ - float dfra, dtime, pa_dtime, pa_dfra=0.0; + float dfra, dtime; float birthtime, dietime; - - int invalidParticles=0; /* where have we gone in time since last time */ dfra= cfra - psys->cfra; timestep = psys_get_timestep(sim); - dtime= dfra*timestep; ctime= cfra*timestep; + dtime= dfra*timestep; if(dfra<0.0){ LOOP_EXISTING_PARTICLES { @@ -3402,33 +3389,40 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) if(part->type != PART_HAIR) sim->colliders = get_collider_cache(sim->scene, NULL, NULL); - if(part->phystype==PART_PHYS_BOIDS){ - ParticleTarget *pt = psys->targets.first; - bbd.sim = sim; - bbd.part = part; - bbd.cfra = cfra; - bbd.dfra = dfra; - bbd.timestep = timestep; + /* initialize physics type specific stuff */ + switch(part->phystype) { + case PART_PHYS_BOIDS: + { + ParticleTarget *pt = psys->targets.first; + bbd.sim = sim; + bbd.part = part; + bbd.cfra = cfra; + bbd.dfra = dfra; + bbd.timestep = timestep; - psys_update_particle_tree(psys, cfra); + psys_update_particle_tree(psys, cfra); - boids_precalc_rules(part, cfra); + boids_precalc_rules(part, cfra); - for(; pt; pt=pt->next) { - if(pt->ob) - psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + for(; pt; pt=pt->next) { + if(pt->ob) + psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + } + break; } - } - else if(part->phystype==PART_PHYS_FLUID){ - ParticleTarget *pt = psys->targets.first; - psys_update_particle_tree(psys, cfra); - - for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */ - if(pt->ob) psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + case PART_PHYS_FLUID: + { + ParticleTarget *pt = psys->targets.first; + psys_update_particle_tree(psys, cfra); + + for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */ + if(pt->ob) + psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + } + break; } } - - /* main loop: calculate physics for all particles */ + /* initialize all particles for dynamics */ LOOP_SHOWN_PARTICLES { copy_particle_key(&pa->prev_state,&pa->state,1); @@ -3436,29 +3430,22 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); - ///* reactions can change birth time so they need to be checked first */ - //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0) - // react_to_events(psys,p); - birthtime = pa->time; dietime = birthtime + pa->lifetime; - pa_dfra = dfra; - pa_dtime = dtime; - + /* store this, so we can do multiple loops over particles */ + pa->state.time = dfra; if(dietime <= cfra && psys->cfra < dietime){ /* particle dies some time between this and last step */ - pa_dfra = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); - pa_dtime = pa_dfra * timestep; + pa->state.time = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); pa->alive = PARS_DYING; } else if(birthtime <= cfra && birthtime >= psys->cfra){ /* particle is born some time between this and last step*/ - reset_particle(sim, pa, dtime, cfra); + reset_particle(sim, pa, dfra*timestep, cfra); pa->alive = PARS_ALIVE; - pa_dfra = cfra - birthtime; - pa_dtime = pa_dfra*timestep; + pa->state.time = cfra - birthtime; } else if(dietime < cfra){ /* nothing to be done when particle is dead */ @@ -3471,62 +3458,89 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) else if(part->phystype == PART_PHYS_NO) reset_particle(sim, pa, dtime, cfra); - if(pa_dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ - switch(part->phystype){ - case PART_PHYS_NEWTON: - /* do global forces & effectors */ - apply_particle_forces(sim, p, pa_dfra, cfra); - + if(ELEM(pa->alive, PARS_ALIVE, PARS_DYING)==0 || (pa->flag & (PARS_UNEXIST|PARS_NO_DISP))) + pa->state.time = -1.f; + } + + switch(part->phystype) { + case PART_PHYS_NEWTON: + { + LOOP_DYNAMIC_PARTICLES { + /* do global forces & effectors */ + apply_particle_forces(sim, p, pa->state.time, cfra); + + /* deflection */ + if(sim->colliders) + deflect_particle(sim, p, pa->state.time, cfra); + + /* rotations */ + rotate_particle(part, pa, pa->state.time, timestep); + } + break; + } + case PART_PHYS_BOIDS: + { + LOOP_DYNAMIC_PARTICLES { + bbd.goal_ob = NULL; + + boid_brain(&bbd, p, pa); + + if(pa->alive != PARS_DYING) { + boid_body(&bbd, pa); + /* deflection */ if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - - /* rotations */ - rotate_particle(part, pa, pa_dfra, timestep); - break; - case PART_PHYS_BOIDS: - { - bbd.goal_ob = NULL; - boid_brain(&bbd, p, pa); - if(pa->alive != PARS_DYING) { - boid_body(&bbd, pa); - - /* deflection */ - if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - } - break; + deflect_particle(sim, p, pa->state.time, cfra); } - case PART_PHYS_FLUID: - { - /* do global forces & effectors */ - apply_particle_forces(sim, p, pa_dfra, cfra); + } + break; + } + case PART_PHYS_FLUID: + { + float *gravity = NULL; - /* do fluid sim */ - apply_particle_fluidsim(psys, pa, part, sim, pa_dfra, cfra); + if(psys_uses_gravity(sim)) + gravity = sim->scene->physics_settings.gravity; - /* deflection */ - if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - - /* rotations, SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */ - rotate_particle(part, pa, pa_dfra, timestep); - break; - } + /* do global forces & effectors */ + LOOP_DYNAMIC_PARTICLES { + apply_particle_forces(sim, p, pa->state.time, cfra); + /* in fluids forces only effect velocity */ + copy_v3_v3(pa->state.co, pa->prev_state.co); } - if(pa->alive == PARS_DYING){ - //push_reaction(ob,psys,p,PART_EVENT_DEATH,&pa->state); + /* actual fluids calculations (not threadsafe!) */ + LOOP_DYNAMIC_PARTICLES { + apply_particle_fluidsim(sim->ob, psys, pa, pa->state.time*timestep, gravity); + } + + /* apply velocity, collisions and rotation */ + LOOP_DYNAMIC_PARTICLES { + /* velocity holds forces and viscosity, so apply them before collisions */ + madd_v3_v3fl(pa->state.co, pa->state.vel, pa->state.time*timestep); + + /* calculate new velocity based on new-old location */ + sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); + mul_v3_fl(pa->state.vel, 1.f/(pa->state.time*timestep)); - pa->alive=PARS_DEAD; - pa->state.time=pa->dietime; + if(sim->colliders) + deflect_particle(sim, p, pa->state.time, cfra); + + /* SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */ + rotate_particle(part, pa, pa->state.time, timestep); } - else - pa->state.time=cfra; + break; + } + } - //push_reaction(ob,psys,p,PART_EVENT_NEAR,&pa->state); + /* finalize particle state and time after dynamics */ + LOOP_DYNAMIC_PARTICLES { + if(pa->alive == PARS_DYING){ + pa->alive=PARS_DEAD; + pa->state.time=pa->dietime; } - if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++;} + else + pa->state.time=cfra; } free_collider_cache(&sim->colliders); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index bceff487543..4d22b22ae31 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1230,7 +1230,7 @@ static int ptcache_file_read_data(PTCacheFile *pf) int i; for(i=0; i<BPHYS_TOT_DATA; i++) { - if(pf->data_types & (1<<i) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i])) + if((pf->data_types & (1<<i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i])) return 0; } @@ -1241,7 +1241,7 @@ static int ptcache_file_write_data(PTCacheFile *pf) int i; for(i=0; i<BPHYS_TOT_DATA; i++) { - if(pf->data_types & (1<<i) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i])) + if((pf->data_types & (1<<i)) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i])) return 0; } @@ -1295,14 +1295,14 @@ static void ptcache_file_init_pointers(PTCacheFile *pf) { int data_types = pf->data_types; - pf->cur[BPHYS_DATA_INDEX] = data_types & (1<<BPHYS_DATA_INDEX) ? &pf->data.index : NULL; - pf->cur[BPHYS_DATA_LOCATION] = data_types & (1<<BPHYS_DATA_LOCATION) ? &pf->data.loc : NULL; - pf->cur[BPHYS_DATA_VELOCITY] = data_types & (1<<BPHYS_DATA_VELOCITY) ? &pf->data.vel : NULL; - pf->cur[BPHYS_DATA_ROTATION] = data_types & (1<<BPHYS_DATA_ROTATION) ? &pf->data.rot : NULL; - pf->cur[BPHYS_DATA_AVELOCITY] = data_types & (1<<BPHYS_DATA_AVELOCITY) ? &pf->data.ave : NULL; - pf->cur[BPHYS_DATA_SIZE] = data_types & (1<<BPHYS_DATA_SIZE) ? &pf->data.size : NULL; - pf->cur[BPHYS_DATA_TIMES] = data_types & (1<<BPHYS_DATA_TIMES) ? &pf->data.times : NULL; - pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<<BPHYS_DATA_BOIDS) ? &pf->data.boids : NULL; + pf->cur[BPHYS_DATA_INDEX] = (data_types & (1<<BPHYS_DATA_INDEX)) ? &pf->data.index : NULL; + pf->cur[BPHYS_DATA_LOCATION] = (data_types & (1<<BPHYS_DATA_LOCATION)) ? &pf->data.loc : NULL; + pf->cur[BPHYS_DATA_VELOCITY] = (data_types & (1<<BPHYS_DATA_VELOCITY)) ? &pf->data.vel : NULL; + pf->cur[BPHYS_DATA_ROTATION] = (data_types & (1<<BPHYS_DATA_ROTATION)) ? &pf->data.rot : NULL; + pf->cur[BPHYS_DATA_AVELOCITY] = (data_types & (1<<BPHYS_DATA_AVELOCITY))? &pf->data.ave : NULL; + pf->cur[BPHYS_DATA_SIZE] = (data_types & (1<<BPHYS_DATA_SIZE)) ? &pf->data.size : NULL; + pf->cur[BPHYS_DATA_TIMES] = (data_types & (1<<BPHYS_DATA_TIMES)) ? &pf->data.times : NULL; + pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<<BPHYS_DATA_BOIDS)) ? &pf->data.boids : NULL; } static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) @@ -1329,7 +1329,7 @@ static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) } else { for(i=0; i<BPHYS_TOT_DATA; i++) - size += pf->data_types & (1<<i) ? ptcache_data_size[i] : 0; + size += (pf->data_types & (1<<i)) ? ptcache_data_size[i] : 0; /* size of default header + data up to index */ fseek(pf->fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); @@ -1343,7 +1343,7 @@ void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) int i; for(i=0; i<BPHYS_TOT_DATA; i++) - pm->cur[i] = data_types & (1<<i) ? pm->data[i] : NULL; + pm->cur[i] = ((data_types & (1<<i)) ? pm->data[i] : NULL); } void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) @@ -1528,12 +1528,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(pm) { BKE_ptcache_mem_init_pointers(pm); totpoint = pm->totpoint; - index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i; + index = ((pm->data_types & (1<<BPHYS_DATA_INDEX)) ? pm->cur[BPHYS_DATA_INDEX] : &i); } if(pm2) { BKE_ptcache_mem_init_pointers(pm2); totpoint2 = pm2->totpoint; - index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i; + index2 = ((pm2->data_types & (1<<BPHYS_DATA_INDEX)) ? pm2->cur[BPHYS_DATA_INDEX] : &i); } if(pf) { if(ptcache_file_read_header_begin(pf)) { @@ -1545,7 +1545,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf)) { ptcache_file_init_pointers(pf); totpoint = pf->totpoint; - index = pf->data_types & (1<<BPHYS_DATA_INDEX) ? &pf->data.index : &i; + index = ((pf->data_types & (1<<BPHYS_DATA_INDEX)) ? &pf->data.index : &i); } } else { @@ -1564,7 +1564,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf2)) { ptcache_file_init_pointers(pf2); totpoint2 = pf2->totpoint; - index2 = pf2->data_types & (1<<BPHYS_DATA_INDEX) ? &pf2->data.index : &i; + index2 = ((pf2->data_types & (1<<BPHYS_DATA_INDEX)) ? &pf2->data.index : &i); } } else { @@ -1608,14 +1608,14 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } else { if(pid->read_elem && (pm || ptcache_file_read_data(pf))) - pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL); + pid->read_elem(*index, pid->calldata, (pm ? pm->cur : pf->cur), frs_sec, (cfra1 ? (float)cfra1 : (float)cfrai), NULL); else if(pid->read_elem) { error = 1; break; } } if(pm) { BKE_ptcache_mem_incr_pointers(pm); - index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i; + index = ((pm->data_types & (1<<BPHYS_DATA_INDEX)) ? pm->cur[BPHYS_DATA_INDEX] : &i); } } } @@ -1667,13 +1667,13 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(pm2) { BKE_ptcache_mem_incr_pointers(pm2); - index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i; + index2 = ((pm2->data_types & (1<<BPHYS_DATA_INDEX)) ? pm2->cur[BPHYS_DATA_INDEX] : &i); } } } if(pm || pf) - ret = (pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT; + ret = ((pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT); else if(pm2 || pf2) { ret = PTCACHE_READ_OLD; pid->cache->simframe = old_frame; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 4da948fd3cb..8947d91988d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -324,7 +324,7 @@ void free_scene(Scene *sce) sound_destroy_scene(sce); } -Scene *add_scene(char *name) +Scene *add_scene(const char *name) { Main *bmain= G.main; Scene *sce; @@ -345,26 +345,41 @@ Scene *add_scene(char *name) sce->r.yasp= 1; sce->r.xparts= 8; sce->r.yparts= 8; - sce->r.size= 25; + 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.displaymode= R_OUTPUT_AREA; sce->r.framapto= 100; sce->r.images= 100; sce->r.framelen= 1.0; - sce->r.frs_sec= 25; + sce->r.blurfac= 0.5; + sce->r.frs_sec= 24; sce->r.frs_sec_base= 1; + sce->r.edgeint= 10; sce->r.ocres = 128; sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; + sce->r.gauss= 1.0; + + /* deprecated but keep for upwards compat */ + sce->r.postgamma= 1.0; + sce->r.posthue= 0.0; + sce->r.postsat= 1.0; sce->r.bake_mode= 1; /* prevent to include render stuff here */ - sce->r.bake_filter= 8; + sce->r.bake_filter= 2; sce->r.bake_osa= 5; sce->r.bake_flag= R_BAKE_CLEAR; sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT; - sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; - sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_SCENE|R_STAMP_CAMERA|R_STAMP_RENDERTIME; + sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_FILENAME|R_STAMP_RENDERTIME; sce->r.stamp_font_id= 12; + sce->r.fg_stamp[0]= sce->r.fg_stamp[1]= sce->r.fg_stamp[2]= 0.8f; + sce->r.fg_stamp[3]= 1.0f; + sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f; + sce->r.bg_stamp[3]= 0.25f; sce->r.seq_prev_type= OB_SOLID; sce->r.seq_rend_type= OB_SOLID; @@ -452,6 +467,9 @@ Scene *add_scene(char *name) pset->brush[PE_BRUSH_CUT].strength= 100; sce->r.ffcodecdata.audio_mixrate = 44100; + sce->r.ffcodecdata.audio_volume = 1.0f; + + BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); sce->audio.distance_model = 2.0; sce->audio.doppler_factor = 1.0; @@ -477,8 +495,8 @@ Scene *add_scene(char *name) sce->gm.dome.resbuf = 1.0f; sce->gm.dome.tilt = 0; - sce->gm.xplay= 800; - sce->gm.yplay= 600; + sce->gm.xplay= 640; + sce->gm.yplay= 480; sce->gm.freqplay= 60; sce->gm.depth= 32; @@ -848,6 +866,21 @@ int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char s return tot; } +int scene_marker_tfm_scale(struct Scene *scene, float value, int flag) +{ + TimeMarker *marker; + int tot= 0; + + for (marker= scene->markers.first; marker; marker= marker->next) { + if ((marker->flag & flag) == flag) { + marker->frame= CFRA + (int)floorf(((float)(marker->frame - CFRA) * value) + 0.5f); + tot++; + } + } + + return tot; +} + Base *scene_add_base(Scene *sce, Object *ob) { Base *b= MEM_callocN(sizeof(*b), "scene_add_base"); diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 487ec78b2bd..73351edbdd5 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -42,8 +42,7 @@ typedef struct seqCacheKey { struct Sequence * seq; - int rectx; - int recty; + SeqRenderData context; float cfra; seq_stripelem_ibuf_t type; } seqCacheKey; @@ -64,7 +63,7 @@ static int ibufs_rem = 0; static unsigned int HashHash(void *key_) { seqCacheKey * key = (seqCacheKey*) key_; - unsigned int rval = key->rectx + key->recty; + unsigned int rval = seq_hash_render_data(&key->context); rval ^= *(unsigned int*) &key->cfra; rval += key->type; @@ -99,21 +98,7 @@ static int HashCmp(void *a_, void *b_) return 1; } - if (a->rectx < b->rectx) { - return -1; - } - if (a->rectx > b->rectx) { - return 1; - } - - if (a->recty < b->recty) { - return -1; - } - if (a->recty > b->recty) { - return 1; - } - - return 0; + return seq_cmp_render_data(&a->context, &b->context); } static void HashKeyFree(void *key) @@ -192,7 +177,7 @@ void seq_stripelem_cache_cleanup() } struct ImBuf * seq_stripelem_cache_get( - struct Sequence * seq, int rectx, int recty, + SeqRenderData context, struct Sequence * seq, float cfra, seq_stripelem_ibuf_t type) { seqCacheKey key; @@ -207,8 +192,7 @@ struct ImBuf * seq_stripelem_cache_get( } key.seq = seq; - key.rectx = rectx; - key.recty = recty; + key.context = context; key.cfra = cfra - seq->start; key.type = type; @@ -224,7 +208,7 @@ struct ImBuf * seq_stripelem_cache_get( } void seq_stripelem_cache_put( - struct Sequence * seq, int rectx, int recty, + SeqRenderData context, struct Sequence * seq, float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i) { seqCacheKey * key; @@ -243,8 +227,7 @@ void seq_stripelem_cache_put( key = (seqCacheKey*) BLI_mempool_alloc(keypool); key->seq = seq; - key->rectx = rectx; - key->recty = recty; + key->context = context; key->cfra = cfra - seq->start; key->type = type; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index f5dc04ca569..2efef52ed3e 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -69,11 +69,13 @@ enum { }; static struct ImBuf * prepare_effect_imbufs( - int x, int y, + SeqRenderData context, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { struct ImBuf * out; + int x = context.rectx; + int y = context.recty; if (!ibuf1 && !ibuf2 && !ibuf3) { /* hmmm, global float option ? */ @@ -273,9 +275,8 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) } static struct ImBuf * do_plugin_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float cfra, - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float cfra, + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -285,7 +286,9 @@ static struct ImBuf * do_plugin_effect( old plugins) do very bad stuff with imbuf-internals */ - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + int x = context.rectx; + int y = context.recty; if(seq->plugin && seq->plugin->doit) { @@ -524,22 +527,21 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_alphaover_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaover_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_alphaover_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -696,22 +698,22 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf* do_alphaunder_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaunder_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_alphaunder_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -821,22 +823,22 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y, /* carefull: also used by speed effect! */ static struct ImBuf* do_cross_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_cross_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_cross_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -1088,24 +1090,24 @@ static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), } static struct ImBuf * do_gammacross_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); build_gammatabs(); if (out->rect_float) { do_gammacross_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_gammacross_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } @@ -1206,22 +1208,22 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_add_effect(Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), +static struct ImBuf * do_add_effect(SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_add_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_add_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } @@ -1323,22 +1325,21 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_sub_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_sub_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_sub_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -1537,22 +1538,21 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_mul_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_mul_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_mul_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } @@ -1993,24 +1993,23 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) } static struct ImBuf * do_wipe_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_wipe_effect_float(seq, - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_wipe_effect_byte(seq, - facf0, facf1, x, y, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, + (unsigned char*) out->rect); } return out; @@ -2062,8 +2061,8 @@ static void copy_transform_effect(Sequence *dst, Sequence *src) } static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out, - float scale_x, float scale_y, float translate_x, float translate_y, - float rotate, int interpolation) + float scale_x, float scale_y, float translate_x, float translate_y, + float rotate, int interpolation) { int xo, yo, xi, yi; float xt, yt, xr, yr; @@ -2144,15 +2143,15 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x static struct ImBuf * do_transform_effect( - Main *UNUSED(bmain), Scene *scene, Sequence *seq,float UNUSED(cfra), - float facf0, float UNUSED(facf1), int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq,float UNUSED(cfra), + float facf0, float UNUSED(facf1), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); - do_transform(scene, seq, facf0, x, y, ibuf1, out); + do_transform(context.scene, seq, facf0, + context.rectx, context.recty, ibuf1, out); return out; } @@ -2660,26 +2659,27 @@ static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, fl } static struct ImBuf * do_glow_effect( - Main *UNUSED(bmain), Scene * scene, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); - int render_size = 100*x/scene->r.xsch; + int render_size = 100*context.rectx/context.scene->r.xsch; if (out->rect_float) { do_glow_effect_float(seq, render_size, - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, + context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_glow_effect_byte(seq, render_size, - facf0, facf1, x, y, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, + context.rectx, context.recty, + (char*) ibuf1->rect, (char*) ibuf2->rect, + (char*) out->rect); } return out; @@ -2723,18 +2723,19 @@ static int early_out_color(struct Sequence *UNUSED(seq), } static struct ImBuf * do_solid_color( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); SolidColorVars *cv = (SolidColorVars *)seq->effectdata; unsigned char *rect; float *rect_float; + int x = context.rectx; + int y = context.recty; if (out->rect) { unsigned char col0[3]; @@ -2819,9 +2820,8 @@ static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0), } static struct ImBuf * do_multicam( - Main *bmain, Scene *scene, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), int x, int y, - int preview_render_size, + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), struct ImBuf *UNUSED(ibuf3)) { @@ -2834,7 +2834,7 @@ static struct ImBuf * do_multicam( return 0; } - ed = scene->ed; + ed = context.scene->ed; if (!ed) { return 0; } @@ -2843,13 +2843,12 @@ static struct ImBuf * do_multicam( return 0; } - i = give_ibuf_seqbase(bmain, scene, x, y, cfra, seq->multicam_source, - preview_render_size, seqbasep); + i = give_ibuf_seqbase(context, cfra, seq->multicam_source, seqbasep); if (!i) { return 0; } - if (input_have_to_preprocess(scene, seq, cfra, x, y)) { + if (input_have_to_preprocess(context, seq, cfra)) { out = IMB_dupImBuf(i); IMB_freeImBuf(i); } else { @@ -2940,6 +2939,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) float fallback_fac = 1.0f; SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; FCurve *fcu= NULL; + int flags = v->flags; /* if not already done, load / initialize data */ get_sequence_effect(seq); @@ -2965,12 +2965,25 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) v->frameMap = MEM_callocN(sizeof(float) * v->length, "speedcontrol frameMap"); } - - /* if there is no fcurve, use value as simple multiplier */ - if (!fcu) - fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ - if (v->flags & SEQ_SPEED_INTEGRATE) { + fallback_fac = 1.0; + + if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { + if (seq->seq1->enddisp != seq->seq1->start + && seq->seq1->len != 0) { + fallback_fac = (float) seq->seq1->len / + (float) (seq->seq1->enddisp - seq->seq1->start); + flags = SEQ_SPEED_INTEGRATE; + fcu = NULL; + } + } else { + /* if there is no fcurve, use value as simple multiplier */ + if (!fcu) { + fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ + } + } + + if (flags & SEQ_SPEED_INTEGRATE) { float cursor = 0; float facf; @@ -3006,7 +3019,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) facf = fallback_fac; } - if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { + if (flags & SEQ_SPEED_COMPRESS_IPO_Y) { facf *= seq->seq1->len; } facf *= v->globalSpeed; @@ -3021,19 +3034,6 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) } } -/* - simply reuse do_cross_effect for blending... - -static void do_speed_effect(Sequence * seq,int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) -{ - -} -*/ - - /* ********************************************************************** sequence effect factory ********************************************************************** */ @@ -3111,15 +3111,17 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf * do_overdrop_effect(Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), +static struct ImBuf * do_overdrop_effect(SeqRenderData context, + Sequence *UNUSED(seq), + float UNUSED(cfra), float facf0, float facf1, - int x, int y, - int UNUSED(preview_render_size), struct ImBuf * ibuf1, struct ImBuf * ibuf2, struct ImBuf * ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + int x = context.rectx; + int y = context.recty; if (out->rect_float) { do_drop_effect_float( diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4272e317cc7..b98976729c4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -242,6 +242,94 @@ void seq_free_editing(Scene *scene) MEM_freeN(ed); } +/* ********************************************************************** + * sequencer pipeline functions + ********************************************************************** */ + +SeqRenderData seq_new_render_data( + struct Main * bmain, struct Scene * scene, + int rectx, int recty, int preview_render_size) +{ + SeqRenderData rval; + + rval.bmain = bmain; + rval.scene = scene; + rval.rectx = rectx; + rval.recty = recty; + rval.preview_render_size = preview_render_size; + rval.motion_blur_samples = 0; + rval.motion_blur_shutter = 0; + + return rval; +} + +int seq_cmp_render_data(SeqRenderData * a, SeqRenderData * b) +{ + if (a->preview_render_size < b->preview_render_size) { + return -1; + } + if (a->preview_render_size > b->preview_render_size) { + return 1; + } + + if (a->rectx < b->rectx) { + return -1; + } + if (a->rectx > b->rectx) { + return 1; + } + + if (a->recty < b->recty) { + return -1; + } + if (a->recty > b->recty) { + return 1; + } + + if (a->bmain < b->bmain) { + return -1; + } + if (a->bmain > b->bmain) { + return 1; + } + + if (a->scene < b->scene) { + return -1; + } + if (a->scene > b->scene) { + return 1; + } + + if (a->motion_blur_shutter < b->motion_blur_shutter) { + return -1; + } + if (a->motion_blur_shutter > b->motion_blur_shutter) { + return 1; + } + + if (a->motion_blur_samples < b->motion_blur_samples) { + return -1; + } + if (a->motion_blur_samples > b->motion_blur_samples) { + return 1; + } + + return 0; +} + +unsigned int seq_hash_render_data(SeqRenderData * a) +{ + unsigned int rval = a->rectx + a->recty; + + rval ^= a->preview_render_size; + rval ^= ((intptr_t) a->bmain) << 6; + rval ^= ((intptr_t) a->scene) << 6; + rval ^= (int) (a->motion_blur_shutter * 100.0) << 10; + rval ^= a->motion_blur_samples << 24; + + return rval; +} + /* ************************* itterator ************************** */ /* *************** (replaces old WHILE_SEQ) ********************* */ /* **************** use now SEQ_BEGIN() SEQ_END ***************** */ @@ -1024,7 +1112,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE) -static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, char * name, int preview_render_size) +static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, char * name) { int frameno; char dir[FILE_MAXDIR]; @@ -1055,17 +1143,19 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c switch(seq->type) { case SEQ_IMAGE: snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir, - preview_render_size, give_stripelem(seq, cfra)->name); + context.preview_render_size, + give_stripelem(seq, cfra)->name); frameno = 1; break; case SEQ_MOVIE: frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir, - seq->strip->stripdata->name, preview_render_size); + seq->strip->stripdata->name, context.preview_render_size); break; default: frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; - snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, preview_render_size); + snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, + context.preview_render_size); } BLI_path_abs(name, G.main->name); @@ -1076,7 +1166,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c return TRUE; } -static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, int preview_render_size) +static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int cfra) { char name[PROXY_MAXFILE]; @@ -1085,14 +1175,14 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } /* rendering at 100% ? No real sense in proxy-ing, right? */ - if (preview_render_size == 100) { + if (context.preview_render_size == 100) { return 0; } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; if (seq->strip->proxy->anim == NULL) { - if (seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)==0) { + if (seq_proxy_get_fname(context, seq, cfra, name)==0) { return 0; } @@ -1105,7 +1195,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in return IMB_anim_absolute(seq->strip->proxy->anim, frameno); } - if (seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)==0) { + if (seq_proxy_get_fname(context, seq, cfra, name) == 0) { return 0; } @@ -1437,12 +1527,12 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) */ int input_have_to_preprocess( - Scene *UNUSED(scene), Sequence * seq, float UNUSED(cfra), int UNUSED(seqrectx), int UNUSED(seqrecty)) + SeqRenderData UNUSED(context), Sequence * seq, float UNUSED(cfra)) { float mul; if (seq->flag & (SEQ_FILTERY|SEQ_USE_CROP|SEQ_USE_TRANSFORM|SEQ_FLIPX| - SEQ_FLIPY|SEQ_USE_COLOR_BALANCE|SEQ_MAKE_PREMUL)) { + SEQ_FLIPY|SEQ_USE_COLOR_BALANCE|SEQ_MAKE_PREMUL)) { return TRUE; } @@ -1464,7 +1554,7 @@ int input_have_to_preprocess( } static ImBuf * input_preprocess( - Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty, ImBuf * ibuf) + SeqRenderData context, Sequence *seq, float UNUSED(cfra), ImBuf * ibuf) { float mul; @@ -1493,8 +1583,8 @@ static ImBuf * input_preprocess( dy = sy; if (seq->flag & SEQ_USE_TRANSFORM) { - dx = scene->r.xsch; - dy = scene->r.ysch; + dx = context.scene->r.xsch; + dy = context.scene->r.ysch; } if (c.top + c.bottom >= ibuf->y || c.left + c.right >= ibuf->x || @@ -1576,30 +1666,30 @@ static ImBuf * input_preprocess( } - if(ibuf->x != seqrectx || ibuf->y != seqrecty ) { - if(scene->r.mode & R_OSA) { - IMB_scaleImBuf(ibuf, (short)seqrectx, (short)seqrecty); + if(ibuf->x != context.rectx || ibuf->y != context.recty ) { + if(context.scene->r.mode & R_OSA) { + IMB_scaleImBuf(ibuf, (short)context.rectx, (short)context.recty); } else { - IMB_scalefastImBuf(ibuf, (short)seqrectx, (short)seqrecty); + IMB_scalefastImBuf(ibuf, (short)context.rectx, (short)context.recty); } } return ibuf; } -static ImBuf * copy_from_ibuf_still(Sequence * seq, float nr, - int seqrectx, int seqrecty) +static ImBuf * copy_from_ibuf_still(SeqRenderData context, Sequence * seq, + float nr) { ImBuf * rval = 0; ImBuf * ibuf = 0; if (nr == 0) { ibuf = seq_stripelem_cache_get( - seq, seqrectx, seqrecty, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL); } if (nr == seq->len - 1) { ibuf = seq_stripelem_cache_get( - seq, seqrectx, seqrecty, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL); } @@ -1611,17 +1701,17 @@ static ImBuf * copy_from_ibuf_still(Sequence * seq, float nr, return rval; } -static void copy_to_ibuf_still(Sequence * seq, float nr, +static void copy_to_ibuf_still(SeqRenderData context, Sequence * seq, float nr, ImBuf * ibuf) { if (nr == 0) { seq_stripelem_cache_put( - seq, 0, 0, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); } if (nr == seq->len - 1) { seq_stripelem_cache_put( - seq, 0, 0, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf); } } @@ -1630,15 +1720,15 @@ static void copy_to_ibuf_still(Sequence * seq, float nr, strip rendering functions ********************************************************************** */ -static ImBuf* seq_render_strip_stack( Main *bmain, Scene *scene, ListBase *seqbasep, - float cfra, int chanshown, int preview_render_size, int seqrectx, int seqrecty); +static ImBuf* seq_render_strip_stack( + SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown); -static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int preview_render_size, int seqrectx, int seqrecty); +static ImBuf * seq_render_strip( + SeqRenderData context, Sequence * seq, float cfra); -static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra, - Sequence *seq, int preview_render_size, int seqrectx, int seqrecty) +static ImBuf* seq_render_effect_strip_impl( + SeqRenderData context, Sequence *seq, float cfra) { float fac, facf; int early_out; @@ -1654,21 +1744,22 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra input[0] = seq->seq1; input[1] = seq->seq2; input[2] = seq->seq3; if (!sh.execute) { /* effect not supported in this version... */ - out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + out = IMB_allocImBuf((short)context.rectx, + (short)context.recty, 32, IB_rect); return out; } if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { sh.get_default_fac(seq, cfra, &fac, &facf); - if ((scene->r.mode & R_FIELDS)==0) + if ((context.scene->r.mode & R_FIELDS)==0) facf= fac; } else { - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "effect_fader", 0); + fcu = id_data_find_fcurve(&context.scene->id, seq, &RNA_Sequence, "effect_fader", 0); if (fcu) { fac = facf = evaluate_fcurve(fcu, cfra); - if( scene->r.mode & R_FIELDS ) { + if( context.scene->r.mode & R_FIELDS ) { facf = evaluate_fcurve(fcu, cfra + 0.5); } } else { @@ -1680,27 +1771,26 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra switch (early_out) { case EARLY_NO_INPUT: - out = sh.execute(bmain, scene, seq, cfra, fac, facf, - seqrectx, seqrecty, preview_render_size, NULL, NULL, NULL); + out = sh.execute(context, seq, cfra, fac, facf, + NULL, NULL, NULL); case EARLY_DO_EFFECT: for(i=0; i<3; i++) { if(input[i]) - ibuf[i] = seq_render_strip(bmain, scene, input[i], cfra, - preview_render_size, seqrectx, seqrecty); + ibuf[i] = seq_render_strip( + context, input[i], cfra); } if (ibuf[0] && ibuf[1]) { - out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, - preview_render_size, ibuf[0], ibuf[1], ibuf[2]); + out = sh.execute(context, seq, cfra, fac, facf, + ibuf[0], ibuf[1], ibuf[2]); } break; case EARLY_USE_INPUT_1: if (input[0]) { - ibuf[0] = seq_render_strip(bmain, scene, input[0], cfra, - preview_render_size, seqrectx, seqrecty); + ibuf[0] = seq_render_strip(context, input[0], cfra); } if (ibuf[0]) { - if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { + if (input_have_to_preprocess(context, seq, cfra)) { out = IMB_dupImBuf(ibuf[0]); } else { out = ibuf[0]; @@ -1710,11 +1800,10 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra break; case EARLY_USE_INPUT_2: if (input[1]) { - ibuf[1] = seq_render_strip(bmain, scene, input[1], cfra, - preview_render_size, seqrectx, seqrecty); + ibuf[1] = seq_render_strip(context, input[1], cfra); } if (ibuf[1]) { - if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { + if (input_have_to_preprocess(context, seq, cfra)) { out = IMB_dupImBuf(ibuf[1]); } else { out = ibuf[1]; @@ -1729,7 +1818,7 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra } if (out == NULL) { - out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + out = IMB_allocImBuf((short)context.rectx, (short)context.recty, 32, IB_rect); } return out; @@ -1737,7 +1826,7 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra static ImBuf * seq_render_scene_strip_impl( - Main *bmain, Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty) + SeqRenderData context, Sequence * seq, float nr) { ImBuf * ibuf = 0; float frame= seq->sfra + nr + seq->anim_startofs; @@ -1795,8 +1884,8 @@ static ImBuf * seq_render_scene_strip_impl( oldcamera= seq->scene->camera; /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; + doseq= context.scene->r.scemode & R_DOSEQ; + context.scene->r.scemode &= ~R_DOSEQ; seq->scene->r.cfra= frame; if(seq->scene_camera) @@ -1810,25 +1899,25 @@ static ImBuf * seq_render_scene_strip_impl( seq->scene->markers.first= seq->scene->markers.last= NULL; #endif - if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { + if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == context.scene || have_seq==0) && seq->scene->camera) { /* for old scened this can be uninitialized, should probably be added to do_versions at some point if the functionality stays */ - if(scene->r.seq_prev_type==0) - scene->r.seq_prev_type = 3 /* ==OB_SOLID */; + if(context.scene->r.seq_prev_type==0) + context.scene->r.seq_prev_type = 3 /* ==OB_SOLID */; /* opengl offscreen render */ - scene_update_for_newframe(bmain, seq->scene, seq->scene->lay); - ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect, scene->r.seq_prev_type); + scene_update_for_newframe(context.bmain, seq->scene, seq->scene->lay); + ibuf= sequencer_view3d_cb(seq->scene, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type); } else { Render *re = RE_GetRender(sce->id.name); RenderResult rres; /* XXX: this if can be removed when sequence preview rendering uses the job system */ - if(rendering || scene != sce) { + if(rendering || context.scene != sce) { if(re==NULL) re= RE_NewRender(sce->id.name); - RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame, FALSE); + RE_BlenderFrame(re, context.bmain, sce, NULL, sce->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ G.rendering = rendering; @@ -1859,7 +1948,7 @@ static ImBuf * seq_render_scene_strip_impl( } /* restore */ - scene->r.scemode |= doseq; + context.scene->r.scemode |= doseq; seq->scene->r.cfra = oldcfra; seq->scene->camera= oldcamera; @@ -1872,27 +1961,26 @@ static ImBuf * seq_render_scene_strip_impl( return ibuf; } -static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int preview_render_size, int seqrectx, int seqrecty) +static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfra) { ImBuf * ibuf = NULL; char name[FILE_MAXDIR+FILE_MAXFILE]; - int use_preprocess = input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty); + 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 */ int type = (seq->type & SEQ_EFFECT && seq->type != SEQ_SPEED) ? SEQ_EFFECT : seq->type; - ibuf = seq_stripelem_cache_get(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF); + ibuf = seq_stripelem_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF); if (ibuf == NULL) - ibuf = copy_from_ibuf_still(seq,nr,seqrectx,seqrecty); + ibuf = copy_from_ibuf_still(context, seq, nr); /* currently, we cache preprocessed images */ if (ibuf) use_preprocess = FALSE; if (ibuf == NULL) - ibuf = seq_proxy_fetch(scene, seq, cfra, preview_render_size); + ibuf = seq_proxy_fetch(context, seq, cfra); if(ibuf == NULL) switch(type) { case SEQ_META: @@ -1900,8 +1988,9 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float ImBuf * meta_ibuf = NULL; if(seq->seqbase.first) - meta_ibuf = seq_render_strip_stack(bmain, scene, &seq->seqbase, - seq->start + nr, 0, preview_render_size, seqrectx, seqrecty); + meta_ibuf = seq_render_strip_stack( + context, &seq->seqbase, + seq->start + nr, 0); if(meta_ibuf) { ibuf = meta_ibuf; @@ -1922,13 +2011,12 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float float f_cfra; SpeedControlVars * s = (SpeedControlVars *)seq->effectdata; - sequence_effect_speed_rebuild_map(scene, seq, 0); + sequence_effect_speed_rebuild_map(context.scene,seq, 0); /* weeek! */ f_cfra = seq->start + s->frameMap[(int) nr]; - child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, preview_render_size, - seqrectx, seqrecty); + child_ibuf = seq_render_strip(context,seq->seq1,f_cfra); if (child_ibuf) { ibuf = child_ibuf; @@ -1944,8 +2032,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float } case SEQ_EFFECT: { - ibuf = seq_render_effect_strip_impl(bmain, scene, cfra, seq, preview_render_size, - seqrectx, seqrecty); + ibuf = seq_render_effect_strip_impl(context, seq, cfra); break; } case SEQ_IMAGE: @@ -1966,7 +2053,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float if(ibuf->profile == IB_PROFILE_LINEAR_RGB) IMB_convert_profile(ibuf, IB_PROFILE_NONE); - copy_to_ibuf_still(seq, nr, ibuf); + copy_to_ibuf_still(context, seq, nr, ibuf); } break; } @@ -1977,7 +2064,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float BLI_path_abs(name, G.main->name); seq->anim = openanim(name, IB_rect | - ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0)); + ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0)); } if(seq->anim) { @@ -1988,28 +2075,28 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float imb_freerectImBuf(ibuf); } - copy_to_ibuf_still(seq, nr, ibuf); + copy_to_ibuf_still(context, seq, nr, ibuf); break; } case SEQ_SCENE: { // scene can be NULL after deletions - ibuf = seq_render_scene_strip_impl(bmain, scene, seq, nr, seqrectx, seqrecty); + ibuf = seq_render_scene_strip_impl(context, seq, nr); - copy_to_ibuf_still(seq, nr, ibuf); + copy_to_ibuf_still(context, seq, nr, ibuf); break; } } if (ibuf == NULL) - ibuf = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + ibuf = IMB_allocImBuf((short)context.rectx, (short)context.recty, 32, IB_rect); - if (ibuf->x != seqrectx || ibuf->y != seqrecty) + if (ibuf->x != context.rectx || ibuf->y != context.recty) use_preprocess = TRUE; if (use_preprocess) - ibuf = input_preprocess(scene, seq, cfra, seqrectx, seqrecty, ibuf); + ibuf = input_preprocess(context, seq, cfra, ibuf); - seq_stripelem_cache_put(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF, ibuf); + seq_stripelem_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf); return ibuf; } @@ -2053,8 +2140,7 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) } static ImBuf* seq_render_strip_stack( - Main *bmain, Scene *scene, ListBase *seqbasep, float cfra, int chanshown, - int preview_render_size, int seqrectx, int seqrecty) + SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown) { Sequence* seq_arr[MAXSEQ+1]; int count; @@ -2075,15 +2161,17 @@ static ImBuf* seq_render_strip_stack( } #endif - out = seq_stripelem_cache_get(seq_arr[count - 1], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); + out = seq_stripelem_cache_get(context, seq_arr[count - 1], + cfra, SEQ_STRIPELEM_IBUF_COMP); if (out) { return out; } if(count == 1) { - out = seq_render_strip(bmain, scene, seq_arr[0], cfra, preview_render_size, seqrectx, seqrecty); - seq_stripelem_cache_put(seq_arr[0], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP, out); + out = seq_render_strip(context, seq_arr[0], cfra); + seq_stripelem_cache_put(context, seq_arr[0], cfra, + SEQ_STRIPELEM_IBUF_COMP, out); return out; } @@ -2093,13 +2181,14 @@ static ImBuf* seq_render_strip_stack( int early_out; Sequence *seq = seq_arr[i]; - out = seq_stripelem_cache_get(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); + out = seq_stripelem_cache_get( + context, seq, cfra, SEQ_STRIPELEM_IBUF_COMP); if (out) { break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); + out = seq_render_strip(context, seq, cfra); break; } @@ -2108,16 +2197,16 @@ static ImBuf* seq_render_strip_stack( switch (early_out) { case EARLY_NO_INPUT: case EARLY_USE_INPUT_2: - out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); + out = seq_render_strip(context, seq, cfra); break; case EARLY_USE_INPUT_1: if (i == 0) { - out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + out = IMB_allocImBuf((short)context.rectx, (short)context.recty, 32, IB_rect); } break; case EARLY_DO_EFFECT: if (i == 0) { - out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); + out = seq_render_strip(context, seq, cfra); } break; @@ -2127,7 +2216,8 @@ static ImBuf* seq_render_strip_stack( } } - seq_stripelem_cache_put(seq_arr[i], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP, out); + seq_stripelem_cache_put(context, seq_arr[i], cfra, + SEQ_STRIPELEM_IBUF_COMP, out); i++; @@ -2138,29 +2228,27 @@ static ImBuf* seq_render_strip_stack( if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) { struct SeqEffectHandle sh = get_sequence_blend(seq); ImBuf * ibuf1 = out; - ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, - seqrectx, seqrecty); + ImBuf * ibuf2 = seq_render_strip(context, seq, cfra); float facf = seq->blend_opacity / 100.0; int swap_input = seq_must_swap_input_in_blend_mode(seq); - int x= seqrectx; - int y= seqrecty; - if (swap_input) { - out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, - preview_render_size, ibuf2, ibuf1, 0); + out = sh.execute(context, seq, cfra, + facf, facf, + ibuf2, ibuf1, 0); } else { - out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, - preview_render_size, ibuf1, ibuf2, 0); + out = sh.execute(context, seq, cfra, + facf, facf, + ibuf1, ibuf2, 0); } IMB_freeImBuf(ibuf1); IMB_freeImBuf(ibuf2); } - seq_stripelem_cache_put(seq_arr[i], seqrectx, seqrecty, cfra, - SEQ_STRIPELEM_IBUF_COMP, out); + seq_stripelem_cache_put(context, seq_arr[i], cfra, + SEQ_STRIPELEM_IBUF_COMP, out); } return out; @@ -2171,9 +2259,9 @@ static ImBuf* seq_render_strip_stack( * you have to free after usage! */ -ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size) +ImBuf *give_ibuf_seq(SeqRenderData context, float cfra, int chanshown) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed= seq_give_editing(context.scene, FALSE); int count; ListBase *seqbasep; @@ -2187,19 +2275,18 @@ ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, seqbasep= ed->seqbasep; } - return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, - preview_render_size, rectx, recty); + return seq_render_strip_stack(context, seqbasep, cfra, chanshown); } -ImBuf *give_ibuf_seqbase(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size, ListBase *seqbasep) +ImBuf *give_ibuf_seqbase(SeqRenderData context, float cfra, int chanshown, ListBase *seqbasep) { - return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, preview_render_size, rectx, recty); + return seq_render_strip_stack(context, seqbasep, cfra, chanshown); } -ImBuf *give_ibuf_seq_direct(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int preview_render_size, Sequence *seq) +ImBuf *give_ibuf_seq_direct(SeqRenderData context, float cfra, Sequence *seq) { - return seq_render_strip(bmain, scene, seq, cfra, preview_render_size, rectx, recty); + return seq_render_strip(context, seq, cfra); } #if 0 @@ -2249,7 +2336,7 @@ typedef struct PrefetchQueueElem { int rectx; int recty; - int cfra; + float cfra; int chanshown; int preview_render_size; @@ -2409,7 +2496,7 @@ static void seq_stop_threads() } #endif -void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int preview_render_size) +void give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chanshown) { PrefetchQueueElem *e; if (seq_thread_shutdown) { @@ -2417,11 +2504,11 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, i } e = MEM_callocN(sizeof(PrefetchQueueElem), "prefetch_queue_elem"); - e->rectx = rectx; - e->recty = recty; + e->rectx = context.rectx; + e->recty = context.recty; e->cfra = cfra; e->chanshown = chanshown; - e->preview_render_size = preview_render_size; + e->preview_render_size = context.preview_render_size; e->monoton_cfra = monoton_cfra++; pthread_mutex_lock(&queue_lock); @@ -2464,13 +2551,13 @@ static void seq_wait_for_prefetch_ready() } #endif -ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size) +ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown) { PrefetchQueueElem *e = NULL; int found_something = FALSE; if (seq_thread_shutdown) { - return give_ibuf_seq(bmain, scene, rectx, recty, cfra, chanshown, preview_render_size); + return give_ibuf_seq(context, cfra, chanshown); } while (!e) { @@ -2480,9 +2567,9 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i for (e = prefetch_done.first; e; e = e->next) { if (cfra == e->cfra && chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - preview_render_size == e->preview_render_size) { + context.rectx == e->rectx && + context.recty == e->recty && + context.preview_render_size == e->preview_render_size) { success = TRUE; found_something = TRUE; break; @@ -2493,9 +2580,9 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i for (e = prefetch_wait.first; e; e = e->next) { if (cfra == e->cfra && chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - preview_render_size == e->preview_render_size) { + context.rectx == e->rectx && + context.recty == e->recty && + context.preview_render_size == e->preview_render_size) { found_something = TRUE; break; } @@ -2510,9 +2597,9 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i if (tslot->current && cfra == tslot->current->cfra && chanshown == tslot->current->chanshown && - rectx == tslot->current->rectx && - recty == tslot->current->recty && - preview_render_size== tslot->current->preview_render_size){ + context.rectx == tslot->current->rectx && + context.recty == tslot->current->recty && + context.preview_render_size== tslot->current->preview_render_size){ found_something = TRUE; break; } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index c1090326fd9..8822d0cb4c9 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -177,7 +177,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive if(size[0] > size[1]) { - if(size[0] > size[1]) + if(size[0] > size[2]) { scale = res / size[0]; smd->domain->dx = size[0] / res; @@ -187,11 +187,11 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive } else { - scale = res / size[1]; - smd->domain->dx = size[1] / res; - smd->domain->res[1] = res; + scale = res / size[2]; + smd->domain->dx = size[2] / res; + smd->domain->res[2] = res; smd->domain->res[0] = (int)(size[0] * scale + 0.5); - smd->domain->res[2] = (int)(size[2] * scale + 0.5); + smd->domain->res[1] = (int)(size[1] * scale + 0.5); } } else @@ -824,9 +824,109 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) GroupObject *go = NULL; Base *base = NULL; + // do collisions, needs to be done before emission, so that smoke isn't emitted inside collision cells + if(1) + { + Object *otherobj = NULL; + ModifierData *md = NULL; + + if(sds->coll_group) // we use groups since we have 2 domains + go = sds->coll_group->gobject.first; + else + base = scene->base.first; + + while(base || go) + { + otherobj = NULL; + if(sds->coll_group) + { + if(go->ob) + otherobj = go->ob; + } + else + otherobj = base->object; + if(!otherobj) + { + if(sds->coll_group) + go = go->next; + else + base= base->next; + continue; + } + md = modifiers_findByType(otherobj, eModifierType_Smoke); + + // check for active smoke modifier + if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) + { + SmokeModifierData *smd2 = (SmokeModifierData *)md; + + if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points) + { + // we got nice collision object + SmokeCollSettings *scs = smd2->coll; + size_t i, j; + unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); + + for(i = 0; i < scs->numpoints; i++) + { + int badcell = 0; + size_t index = 0; + int cell[3]; + + // 1. get corresponding cell + get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, &scs->points[3 * i], cell, 0); + + // check if cell is valid (in the domain boundary) + for(j = 0; j < 3; j++) + if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) + { + badcell = 1; + break; + } + + if(badcell) + continue; + // 2. set cell values (heat, density and velocity) + index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); + + // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); + // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); + obstacles[index] = 1; + // for moving gobstacles + /* + const LbmFloat maxVelVal = 0.1666; + const LbmFloat maxusqr = maxVelVal*maxVelVal*3. *1.5; + + LbmVec objvel = vec2L((mMOIVertices[n]-mMOIVerticesOld[n]) /dvec); + { + const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5; + USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz); + if(usqr>maxusqr) { + // cutoff at maxVelVal + for(int jj=0; jj<3; jj++) { + if(objvel[jj]>0.) objvel[jj] = maxVelVal; + if(objvel[jj]<0.) objvel[jj] = -maxVelVal; + } + } + } + const LbmFloat dp=dot(objvel, vec2L((*pNormals)[n]) ); + const LbmVec oldov=objvel; // debug + objvel = vec2L((*pNormals)[n]) *dp; + */ + } + } + } + + if(sds->coll_group) + go = go->next; + else + base= base->next; + } + } + // do flows and fluids if(1) - { + { Object *otherobj = NULL; ModifierData *md = NULL; if(sds->fluid_group) // we use groups since we have 2 domains @@ -928,7 +1028,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) continue; // 2. set cell values (heat, density and velocity) index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index] & 2)) // this is inflow + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index])) // this is inflow { // heat[index] += sfs->temp * 0.1; // density[index] += sfs->density * 0.1; @@ -1167,105 +1267,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) pdEndEffectors(&effectors); } - // do collisions - if(1) - { - Object *otherobj = NULL; - ModifierData *md = NULL; - - if(sds->coll_group) // we use groups since we have 2 domains - go = sds->coll_group->gobject.first; - else - base = scene->base.first; - - while(base || go) - { - otherobj = NULL; - if(sds->coll_group) - { - if(go->ob) - otherobj = go->ob; - } - else - otherobj = base->object; - if(!otherobj) - { - if(sds->coll_group) - go = go->next; - else - base= base->next; - continue; - } - md = modifiers_findByType(otherobj, eModifierType_Smoke); - - // check for active smoke modifier - if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { - SmokeModifierData *smd2 = (SmokeModifierData *)md; - - if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points) - { - // we got nice collision object - SmokeCollSettings *scs = smd2->coll; - size_t i, j; - unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); - - for(i = 0; i < scs->numpoints; i++) - { - int badcell = 0; - size_t index = 0; - int cell[3]; - - // 1. get corresponding cell - get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, &scs->points[3 * i], cell, 0); - - // check if cell is valid (in the domain boundary) - for(j = 0; j < 3; j++) - if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) - { - badcell = 1; - break; - } - - if(badcell) - continue; - // 2. set cell values (heat, density and velocity) - index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - - // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); - // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); - obstacles[index] = 1; - // for moving gobstacles - /* - const LbmFloat maxVelVal = 0.1666; - const LbmFloat maxusqr = maxVelVal*maxVelVal*3. *1.5; - - LbmVec objvel = vec2L((mMOIVertices[n]-mMOIVerticesOld[n]) /dvec); - { - const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5; - USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz); - if(usqr>maxusqr) { - // cutoff at maxVelVal - for(int jj=0; jj<3; jj++) { - if(objvel[jj]>0.) objvel[jj] = maxVelVal; - if(objvel[jj]<0.) objvel[jj] = -maxVelVal; - } - } - } - const LbmFloat dp=dot(objvel, vec2L((*pNormals)[n]) ); - const LbmVec oldov=objvel; // debug - objvel = vec2L((*pNormals)[n]) *dp; - */ - } - } - } - - if(sds->coll_group) - go = go->next; - else - base= base->next; - } - } } void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) { @@ -1353,9 +1354,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } } - if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0) + if(!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD)==0 && (cache->flag & PTCACHE_BAKED)==0) return; + smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD; + if(framenr < startframe) framenr = startframe; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 4a9a5fa881b..443ed1f7987 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -120,7 +120,7 @@ void sound_exit() AUD_exit(); } -struct bSound* sound_new_file(struct Main *bmain, char* filename) +struct bSound* sound_new_file(struct Main *bmain, const char *filename) { bSound* sound = NULL; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 09910481bf9..bdb8d11945c 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -172,7 +172,7 @@ void free_text(Text *text) #endif } -Text *add_empty_text(char *name) +Text *add_empty_text(const char *name) { Main *bmain= G.main; Text *ta; @@ -325,7 +325,7 @@ int reopen_text(Text *text) return 1; } -Text *add_text(char *file, const char *relpath) +Text *add_text(const char *file, const char *relpath) { Main *bmain= G.main; FILE *fp; @@ -559,7 +559,7 @@ void clear_text(Text *text) /* called directly from rna */ txt_make_dirty(text); } -void write_text(Text *text, char *str) /* called directly from rna */ +void write_text(Text *text, const char *str) /* called directly from rna */ { int oldstate; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 1240b85393b..69a43ac60f0 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -69,13 +69,13 @@ /* define a single unit */ typedef struct bUnitDef { - char *name; - char *name_plural; /* abused a bit for the display name */ - char *name_short; /* this is used for display*/ - char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */ + const char *name; + const char *name_plural; /* abused a bit for the display name */ + const char *name_short; /* this is used for display*/ + const char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */ /* if name_short has non-ASCII chars, name_alt should be present */ - char *name_display; /* can be NULL */ + const char *name_display; /* can be NULL */ double scalar; double bias; /* not used yet, needed for converting temperature */ @@ -255,6 +255,8 @@ static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, static struct bUnitDef buNaturalRotDef[] = { {"degree", "degrees", "°", NULL, "Degrees", M_PI/180.0, 0.0, B_UNIT_DEF_NONE}, +// {"radian", "radians", "r", NULL, "Radians", 1.0, 0.0, B_UNIT_DEF_NONE}, +// {"turn", "turns", "t", NULL, "Turns", 1.0/(M_PI*2.0), 0.0,B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; @@ -419,7 +421,7 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, } -static char *unit_find_str(char *str, char *substr) +static char *unit_find_str(char *str, const char *substr) { char *str_found; @@ -474,7 +476,7 @@ static int ch_is_op(char op) } } -static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str) +static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, const char *replace_str) { char *str_found; @@ -753,11 +755,16 @@ void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) *len= usys->length; } -char *bUnit_GetName(void *usys_pt, int index) +int bUnit_GetBaseUnit(void *usys_pt) +{ + return ((bUnitCollection *)usys_pt)->base_unit; +} + +const char *bUnit_GetName(void *usys_pt, int index) { return ((bUnitCollection *)usys_pt)->units[index].name; } -char *bUnit_GetNameDisplay(void *usys_pt, int index) +const char *bUnit_GetNameDisplay(void *usys_pt, int index) { return ((bUnitCollection *)usys_pt)->units[index].name_display; } diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 42df92443f3..a86b039e918 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -63,7 +63,7 @@ void free_world(World *wrld) } -World *add_world(char *name) +World *add_world(const char *name) { Main *bmain= G.main; World *wrld; diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index ecf981c1640..95d890f133f 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -40,19 +40,19 @@ extern "C" { #endif -void BLI_recurdir_fileops(char *dirname); -int BLI_link(char *file, char *to); -int BLI_is_writable(char *filename); +void BLI_recurdir_fileops(const char *dirname); +int BLI_link(const char *file, const char *to); +int BLI_is_writable(const char *filename); /** * @attention Do not confuse with BLI_exist */ int BLI_exists(const char *file); -int BLI_copy_fileops(char *file, char *to); -int BLI_rename(char *from, char *to); -int BLI_gzip(char *from, char *to); -int BLI_delete(char *file, int dir, int recursive); -int BLI_move(char *file, char *to); +int BLI_copy_fileops(const char *file, const char *to); +int BLI_rename(const char *from, const char *to); +int BLI_gzip(const char *from, const char *to); +int BLI_delete(const char *file, int dir, int recursive); +int BLI_move(const char *file, const char *to); int BLI_touch(const char *file); /* only for the sane unix world: direct calls to system functions :( */ diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 2144107a6cd..7b21c5f6df7 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -144,6 +144,8 @@ void mat4_to_size(float r[3], float M[4][4]); void translate_m4(float mat[4][4], float tx, float ty, float tz); void rotate_m4(float mat[4][4], const char axis, const float angle); + +void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[][3]); void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[][4]); void loc_eul_size_to_mat4(float R[4][4], @@ -155,8 +157,8 @@ void loc_quat_size_to_mat4(float R[4][4], void loc_axisangle_size_to_mat4(float R[4][4], const float loc[3], const float axis[4], const float angle, const float size[3]); -void blend_m3_m3m3(float R[3][3], float A[3][3], float B[3][3], float t); -void blend_m4_m4m4(float R[4][4], float A[4][4], float B[4][4], float t); +void blend_m3_m3m3(float R[3][3], float A[3][3], float B[3][3], const float t); +void blend_m4_m4m4(float R[4][4], float A[4][4], float B[4][4], const float t); int is_negative_m3(float mat[3][3]); int is_negative_m4(float mat[4][4]); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 2e596951fef..ec62954149c 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -121,15 +121,15 @@ void mid_v3_v3v3(float r[3], const float a[3], const float b[3]); /********************************* Comparison ********************************/ -MINLINE int is_zero_v3(float a[3]); -MINLINE int is_one_v3(float a[3]); +MINLINE int is_zero_v3(const float a[3]); +MINLINE int is_one_v3(const float a[3]); -MINLINE int equals_v3v3(float a[3], float b[3]); -MINLINE int compare_v3v3(float a[3], float b[3], float limit); -MINLINE int compare_len_v3v3(float a[3], float b[3], float limit); +MINLINE int equals_v3v3(const float a[3], const float b[3]); +MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit); +MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit); -MINLINE int compare_v4v4(float a[4], float b[4], float limit); -MINLINE int equals_v4v4(float a[4], float b[4]); +MINLINE int compare_v4v4(const float a[4], const float b[4], const float limit); +MINLINE int equals_v4v4(const float a[4], const float b[4]); MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]); diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 0131d45a00c..d6c0b48263a 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -87,10 +87,6 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") LIST(APPEND INC "${BINRELOC_INC}") ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_OPENMP) ADD_DEFINITIONS(-DPARALLEL=1) ENDIF(WITH_OPENMP) diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 931dd6119a2..795938b4957 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -58,7 +58,7 @@ return -1 if zlib fails, -2 if the originating file does not exist note: will remove the "from" file */ -int BLI_gzip(char *from, char *to) { +int BLI_gzip(const char *from, const char *to) { char buffer[10240]; int file; int readsize = 0; @@ -98,7 +98,7 @@ int BLI_gzip(char *from, char *to) { } /* return 1 when file can be written */ -int BLI_is_writable(char *filename) +int BLI_is_writable(const char *filename) { int file; @@ -151,7 +151,7 @@ int BLI_exists(const char *file) { static char str[MAXPATHLEN+12]; -int BLI_delete(char *file, int dir, int recursive) { +int BLI_delete(const char *file, int dir, int recursive) { int err; if (recursive) { @@ -168,7 +168,7 @@ int BLI_delete(char *file, int dir, int recursive) { return err; } -int BLI_move(char *file, char *to) { +int BLI_move(const char *file, const char *to) { int err; // windows doesn't support moveing to a directory @@ -193,7 +193,7 @@ int BLI_move(char *file, char *to) { } -int BLI_copy_fileops(char *file, char *to) { +int BLI_copy_fileops(const char *file, const char *to) { int err; // windows doesn't support copying to a directory @@ -218,13 +218,13 @@ int BLI_copy_fileops(char *file, char *to) { return err; } -int BLI_link(char *file, char *to) { +int BLI_link(const char *UNUSED(file), const char *UNUSED(to)) { callLocalErrorCallBack("Linking files is unsupported on Windows"); return 1; } -void BLI_recurdir_fileops(char *dirname) { +void BLI_recurdir_fileops(const char *dirname) { char *lslash; char tmp[MAXPATHLEN]; @@ -254,7 +254,7 @@ void BLI_recurdir_fileops(char *dirname) { callLocalErrorCallBack("Unable to create directory\n"); } -int BLI_rename(char *from, char *to) { +int BLI_rename(const char *from, const char *to) { if (!BLI_exists(from)) return 0; /* make sure the filenames are different (case insensitive) before removing */ @@ -273,7 +273,7 @@ int BLI_rename(char *from, char *to) { * */ static char str[MAXPATHLEN+12]; -int BLI_delete(char *file, int dir, int recursive) +int BLI_delete(const char *file, int dir, int recursive) { if(strchr(file, '"')) { printf("Error: not deleted file %s because of quote!\n", file); @@ -294,25 +294,25 @@ int BLI_delete(char *file, int dir, int recursive) return -1; } -int BLI_move(char *file, char *to) { +int BLI_move(const char *file, const char *to) { sprintf(str, "/bin/mv -f \"%s\" \"%s\"", file, to); return system(str); } -int BLI_copy_fileops(char *file, char *to) { +int BLI_copy_fileops(const char *file, const char *to) { sprintf(str, "/bin/cp -rf \"%s\" \"%s\"", file, to); return system(str); } -int BLI_link(char *file, char *to) { +int BLI_link(const char *file, const char *to) { sprintf(str, "/bin/ln -f \"%s\" \"%s\"", file, to); return system(str); } -void BLI_recurdir_fileops(char *dirname) { +void BLI_recurdir_fileops(const char *dirname) { char *lslash; char tmp[MAXPATHLEN]; @@ -330,7 +330,7 @@ void BLI_recurdir_fileops(char *dirname) { mkdir(dirname, 0777); } -int BLI_rename(char *from, char *to) { +int BLI_rename(const char *from, const char *to) { if (!BLI_exists(from)) return 0; if (BLI_exists(to)) if(BLI_delete(to, 0, 0)) return 1; diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index d2bd7a0a2b1..154eb746e5c 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -976,17 +976,15 @@ float mat4_to_scale(float mat[][4]) return mat3_to_scale(tmat); } -void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[][4]) + +void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]) { - float mat3[3][3]; /* wmat -> 3x3 */ - float mat3_n[3][3]; /* wmat -> normalized, 3x3 */ - float imat3_n[3][3]; /* wmat -> normalized & inverted, 3x3 */ - /* location */ - copy_v3_v3(loc, wmat[3]); + float mat3_n[3][3]; /* mat3 -> normalized, 3x3 */ + float imat3_n[3][3]; /* mat3 -> normalized & inverted, 3x3 */ /* rotation & scale are linked, we need to create the mat's * for these together since they are related. */ - copy_m3_m4(mat3, wmat); + /* so scale doesnt interfear with rotation [#24291] */ /* note: this is a workaround for negative matrix not working for rotation conversion, FIXME */ normalize_m3_m3(mat3_n, mat3); @@ -1010,6 +1008,17 @@ void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wm size[2]= mat3[2][2]; } +void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[][4]) +{ + float mat3[3][3]; /* wmat -> 3x3 */ + + copy_m3_m4(mat3, wmat); + mat3_to_rot_size(rot, size, mat3); + + /* location */ + copy_v3_v3(loc, wmat[3]); +} + void scale_m3_fl(float m[][3], float scale) { m[0][0]= m[1][1]= m[2][2]= scale; @@ -1075,18 +1084,19 @@ void rotate_m4(float mat[][4], const char axis, const float angle) } } -void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweight) +void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], const float srcweight) { + float srot[3][3], drot[3][3]; float squat[4], dquat[4], fquat[4]; float ssize[3], dsize[3], fsize[3]; float rmat[3][3], smat[3][3]; - mat3_to_quat(dquat,dst); - mat3_to_size(dsize,dst); + mat3_to_rot_size(drot, dsize, dst); + mat3_to_rot_size(srot, ssize, src); + + mat3_to_quat(dquat, drot); + mat3_to_quat(squat, srot); - mat3_to_quat(squat,src); - mat3_to_size(ssize,src); - /* do blending */ interp_qt_qtqt(fquat, dquat, squat, srcweight); interp_v3_v3v3(fsize, dsize, ssize, srcweight); @@ -1097,20 +1107,19 @@ void blend_m3_m3m3(float out[][3], float dst[][3], float src[][3], float srcweig mul_m3_m3m3(out, rmat, smat); } -void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], float srcweight) +void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], const float srcweight) { + float sloc[3], dloc[3], floc[3]; + float srot[3][3], drot[3][3]; float squat[4], dquat[4], fquat[4]; float ssize[3], dsize[3], fsize[3]; - float sloc[3], dloc[3], floc[3]; - - mat4_to_quat(dquat,dst); - mat4_to_size(dsize,dst); - copy_v3_v3(dloc, dst[3]); - mat4_to_quat(squat,src); - mat4_to_size(ssize,src); - copy_v3_v3(sloc, src[3]); - + mat4_to_loc_rot_size(dloc, drot, dsize, dst); + mat4_to_loc_rot_size(sloc, srot, ssize, src); + + mat3_to_quat(dquat, drot); + mat3_to_quat(squat, srot); + /* do blending */ interp_v3_v3v3(floc, dloc, sloc, srcweight); interp_qt_qtqt(fquat, dquat, squat, srcweight); diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 6bccb0045fa..9718b37ee8a 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -419,27 +419,27 @@ MINLINE void normal_float_to_short_v3(short *out, const float *in) /********************************* Comparison ********************************/ -MINLINE int is_zero_v3(float *v) +MINLINE int is_zero_v3(const float *v) { return (v[0] == 0 && v[1] == 0 && v[2] == 0); } -MINLINE int is_one_v3(float *v) +MINLINE int is_one_v3(const float *v) { return (v[0] == 1 && v[1] == 1 && v[2] == 1); } -MINLINE int equals_v3v3(float *v1, float *v2) +MINLINE int equals_v3v3(const float *v1, const float *v2) { return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2])); } -MINLINE int equals_v4v4(float *v1, float *v2) +MINLINE int equals_v4v4(const float *v1, const float *v2) { return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2]) && (v1[3]==v2[3])); } -MINLINE int compare_v3v3(float *v1, float *v2, float limit) +MINLINE int compare_v3v3(const float *v1, const float *v2, const float limit) { if(fabs(v1[0]-v2[0])<limit) if(fabs(v1[1]-v2[1])<limit) @@ -449,7 +449,7 @@ MINLINE int compare_v3v3(float *v1, float *v2, float limit) return 0; } -MINLINE int compare_len_v3v3(float *v1, float *v2, float limit) +MINLINE int compare_len_v3v3(const float *v1, const float *v2, const float limit) { float x,y,z; @@ -460,7 +460,7 @@ MINLINE int compare_len_v3v3(float *v1, float *v2, float limit) return ((x*x + y*y + z*z) < (limit*limit)); } -MINLINE int compare_v4v4(float *v1, float *v2, float limit) +MINLINE int compare_v4v4(const float *v1, const float *v2, const float limit) { if(fabs(v1[0]-v2[0])<limit) if(fabs(v1[1]-v2[1])<limit) diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 719a3c065ae..798892d452a 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -80,7 +80,7 @@ typedef struct BlendFileData { * indicating the cause of the failure. * @return The data of the file. */ -BlendFileData* BLO_read_from_file (char *file, struct ReportList *reports); +BlendFileData* BLO_read_from_file(const char *file, struct ReportList *reports); /** * Open a blender file from memory. The function diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index c892e8457ca..87ff98eef1d 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -242,7 +242,7 @@ void BLO_blendhandle_close(BlendHandle *bh) { /**********/ -BlendFileData *BLO_read_from_file(char *file, ReportList *reports) +BlendFileData *BLO_read_from_file(const char *file, ReportList *reports) { BlendFileData *bfd = NULL; FileData *fd; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 319022e2d1a..af36e33fb26 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -921,13 +921,13 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports) if (fd->flags & FD_FLAGS_FILE_OK) { if (!read_file_dna(fd)) { - BKE_report(reports, RPT_ERROR, "File incomplete"); + BKE_reportf(reports, RPT_ERROR, "Failed to read blend file: \"%s\", incomplete", fd->relabase); blo_freefiledata(fd); fd= NULL; } } else { - BKE_report(reports, RPT_ERROR, "File is not a Blender file"); + BKE_reportf(reports, RPT_ERROR, "Failed to read blend file: \"%s\", not a blend file", fd->relabase); blo_freefiledata(fd); fd= NULL; } @@ -937,7 +937,7 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports) /* cannot be called with relative paths anymore! */ /* on each new library added, it now checks for the current FileData and expands relativeness */ -FileData *blo_openblenderfile(char *name, ReportList *reports) +FileData *blo_openblenderfile(const char *name, ReportList *reports) { gzFile gzfile; errno= 0; @@ -2214,13 +2214,21 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose) if (!pose || !arm) return; + /* always rebuild to match proxy or lib changes */ rebuild= ob->proxy || (ob->id.lib==NULL && arm->id.lib); - if (ob->proxy && pose->proxy_act_bone[0]) { - Bone *bone = get_named_bone(arm, pose->proxy_act_bone); - if (bone) - arm->act_bone = bone; + if(ob->proxy) { + /* sync proxy layer */ + if(pose->proxy_layer) + arm->layer = pose->proxy_layer; + + /* sync proxy active bone */ + if(pose->proxy_act_bone[0]) { + Bone *bone = get_named_bone(arm, pose->proxy_act_bone); + if (bone) + arm->act_bone = bone; + } } for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) { @@ -3645,6 +3653,8 @@ static void lib_link_object(FileData *fd, Main *main) smd->domain->fluid_group = newlibadr_us(fd, ob->id.lib, smd->domain->fluid_group); smd->domain->effector_weights->group = newlibadr(fd, ob->id.lib, smd->domain->effector_weights->group); + + smd->domain->flags |= MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */ } } @@ -5262,14 +5272,14 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) if(newmain->curlib) { if(strcmp(newmain->curlib->filepath, lib->filepath)==0) { printf("Fixed error in file; multiple instances of lib:\n %s\n", lib->filepath); - + BKE_reportf(fd->reports, RPT_WARNING, "Library '%s', '%s' had multiple instances, save and reload!", lib->name, lib->filepath); + change_idid_adr(&fd->mainlist, fd, lib, newmain->curlib); // change_idid_adr_fd(fd, lib, newmain->curlib); BLI_remlink(&main->library, lib); MEM_freeN(lib); - - BKE_report(fd->reports, RPT_WARNING, "Library had multiple instances, save and reload!"); + return; } @@ -6257,7 +6267,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) case SPACE_NODE: ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; + ar->regiontype= RGN_TYPE_UI; ar->alignment= RGN_ALIGN_LEFT; ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; @@ -6506,6 +6516,9 @@ static void do_versions_windowmanager_2_50(bScreen *screen) sl->spacetype= SPACE_INFO; /* spacedata then matches */ } + /* it seems to be possible in 2.5 to have this saved, filewindow probably */ + sa->butspacetype= sa->spacetype; + /* pushed back spaces also need regions! */ if(sa->spacedata.first) { sl= sa->spacedata.first; diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index ed89e93d66a..c6526f2c7af 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -110,7 +110,7 @@ void blo_split_main(ListBase *mainlist, struct Main *main); BlendFileData *blo_read_file_internal(FileData *fd, const char *filename); -FileData *blo_openblenderfile(char *name, struct ReportList *reports); +FileData *blo_openblenderfile(const char *name, struct ReportList *reports); FileData *blo_openblendermemory(void *buffer, int buffersize, struct ReportList *reports); FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports); diff --git a/source/blender/blenpluginapi/CMakeLists.txt b/source/blender/blenpluginapi/CMakeLists.txt index 41ec5864382..737fb3caf4b 100644 --- a/source/blender/blenpluginapi/CMakeLists.txt +++ b/source/blender/blenpluginapi/CMakeLists.txt @@ -37,10 +37,6 @@ SET(SRC intern/pluginapi.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_QUICKTIME) LIST(APPEND INC ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 3194b2269ea..240125ddd68 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -84,7 +84,7 @@ void ImagesExporter::operator()(Material *ma, Object *ob) } if (find(mImages.begin(), mImages.end(), name) == mImages.end()) { - COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(rel)), name); + COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(rel)), name, name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ img.add(mSW); mImages.push_back(name); diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 09083e77fe1..2c181cf84dc 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2995,6 +2995,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi ID *id= (ID *)id_poin; FCurve *fcu= (FCurve *)fcu_poin; + ReportList *reports = CTX_wm_reports(C); Scene *scene= CTX_data_scene(C); PointerRNA id_ptr, ptr; PropertyRNA *prop; @@ -3018,7 +3019,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi flag |= INSERTKEY_REPLACE; /* insert a keyframe for this F-Curve */ - done= insert_keyframe_direct(ptr, prop, fcu, cfra, flag); + done= insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); if (done) WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); @@ -3032,6 +3033,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi KeyBlock *kb= (KeyBlock *)kb_poin; char *rna_path= key_get_curValue_rnaPath(key, kb); + ReportList *reports = CTX_wm_reports(C); Scene *scene= CTX_data_scene(C); PointerRNA id_ptr, ptr; PropertyRNA *prop; @@ -3060,7 +3062,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi flag |= INSERTKEY_REPLACE; /* insert a keyframe for this F-Curve */ - done= insert_keyframe_direct(ptr, prop, fcu, cfra, flag); + done= insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); if (done) WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 7cfe180a7bf..dd27de883b3 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -392,7 +392,7 @@ float ANIM_unit_mapping_get_factor (Scene *scene, ID *id, FCurve *fcu, short res if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) { /* if the radians flag is not set, default to using degrees which need conversions */ - if ((scene) && (scene->unit.flag & USER_UNIT_ROT_RADIANS) == 0) { + if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) { if (restore) return M_PI / 180.0f; /* degrees to radians */ else diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 7f99a5e3b47..1216894e973 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -287,13 +287,12 @@ int insert_bezt_fcurve (FCurve *fcu, BezTriple *bezt, short flag) */ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag) { - BezTriple beztr; + BezTriple beztr= {{{0}}}; int a; /* set all three points, for nicer start position * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok... */ - memset(&beztr, 0, sizeof(BezTriple)); beztr.vec[0][0]= x-1.0f; beztr.vec[0][1]= y; beztr.vec[1][0]= x; @@ -697,25 +696,26 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, * and extra keyframe filtering. */ -short insert_keyframe_direct (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, short flag) +short insert_keyframe_direct (ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, short flag) { float curval= 0.0f; /* no F-Curve to add keyframe to? */ if (fcu == NULL) { - printf("ERROR: no F-Curve to add keyframes to \n"); + BKE_report(reports, RPT_ERROR, "No F-Curve to add keyframes to"); return 0; } /* F-Curve not editable? */ - if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { - if (G.f & G_DEBUG) - printf("WARNING: not inserting keyframe for locked F-Curve \n"); + if (fcurve_is_keyframable(fcu) == 0) { + BKE_reportf(reports, RPT_ERROR, + "F-Curve with path = '%s' [%d] cannot be keyframed. Ensure that it is not locked or sampled. Also, try removing F-Modifiers.", + fcu->rna_path, fcu->array_index); return 0; } /* if no property given yet, try to validate from F-Curve info */ if ((ptr.id.data == NULL) && (ptr.data==NULL)) { - printf("ERROR: no RNA-pointer available to retrieve values for keyframing from\n"); + BKE_report(reports, RPT_ERROR, "No RNA-pointer available to retrieve values for keyframing from"); return 0; } if (prop == NULL) { @@ -726,7 +726,9 @@ short insert_keyframe_direct (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, fl /* property not found... */ char *idname= (ptr.id.data) ? ((ID *)ptr.id.data)->name : "<No ID-Pointer>"; - printf("Insert Key: Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)\n", idname, fcu->rna_path); + BKE_reportf(reports, RPT_ERROR, + "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + idname, fcu->rna_path); return 0; } else { @@ -815,7 +817,7 @@ short insert_keyframe_direct (PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, fl * * index of -1 keys all array indices */ -short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) +short insert_keyframe (ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) { PointerRNA id_ptr, ptr; PropertyRNA *prop = NULL; @@ -825,13 +827,14 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_ /* validate pointer first - exit if failure */ if (id == NULL) { - printf("Insert Key: no ID-block to insert keyframe in (Path = %s) \n", rna_path); + BKE_reportf(reports, RPT_ERROR, "No ID-block to insert keyframe in (Path = %s)", rna_path); return 0; } RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { - printf("Insert Key: Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)\n", + BKE_reportf(reports, RPT_ERROR, + "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", (id)? id->name : "<Missing ID-Block>", rna_path); return 0; } @@ -844,7 +847,9 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_ act= verify_adt_action(id, 1); if (act == NULL) { - printf("Insert Key: Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)\n", id->name, rna_path); + BKE_reportf(reports, RPT_ERROR, + "Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)", + id->name, rna_path); return 0; } @@ -900,7 +905,7 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_ } /* insert keyframe */ - ret += insert_keyframe_direct(ptr, prop, fcu, cfra, flag); + ret += insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); } } @@ -917,7 +922,7 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_ * The flag argument is used for special settings that alter the behaviour of * the keyframe deletion. These include the quick refresh options. */ -short delete_keyframe (ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short UNUSED(flag)) +short delete_keyframe (ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short UNUSED(flag)) { AnimData *adt= BKE_animdata_from_id(id); PointerRNA id_ptr, ptr; @@ -927,14 +932,14 @@ short delete_keyframe (ID *id, bAction *act, const char group[], const char rna_ /* sanity checks */ if ELEM(NULL, id, adt) { - printf("ERROR: no ID-block and/or AnimData to delete keyframe from \n"); + BKE_report(reports, RPT_ERROR, "No ID-Block and/Or AnimData to delete keyframe from"); return 0; } /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { - printf("Delete Key: Could not delete keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)\n", id->name, rna_path); + BKE_reportf(reports, RPT_ERROR, "Could not delete keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", id->name, rna_path); return 0; } @@ -953,7 +958,7 @@ short delete_keyframe (ID *id, bAction *act, const char group[], const char rna_ cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } else { - printf("ERROR: no Action to delete keyframes from for ID = %s \n", id->name); + BKE_reportf(reports, RPT_ERROR, "No Action to delete keyframes from for ID = %s \n", id->name); return 0; } } @@ -997,7 +1002,7 @@ short delete_keyframe (ID *id, bAction *act, const char group[], const char rna_ if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { if (G.f & G_DEBUG) - printf("WARNING: not inserting keyframe for locked F-Curve \n"); + printf("WARNING: not deleting keyframe for locked F-Curve \n"); continue; } @@ -1308,7 +1313,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op) for (fcu= act->curves.first; fcu; fcu= fcn) { fcn= fcu->next; - success+= delete_keyframe(id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); + success+= delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); } } @@ -1349,7 +1354,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - PointerRNA ptr; + PointerRNA ptr= {{0}}; PropertyRNA *prop= NULL; char *path; float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap @@ -1361,7 +1366,6 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) flag = ANIM_get_keyframing_flags(scene, 1); /* try to insert keyframe using property retrieved from UI */ - memset(&ptr, 0, sizeof(PointerRNA)); uiContextActiveProperty(C, &ptr, &prop, &index); if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { @@ -1378,7 +1382,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) length= 1; for (a=0; a<length; a++) - success+= insert_keyframe(ptr.id.data, NULL, NULL, path, index+a, cfra, flag); + success+= insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index+a, cfra, flag); MEM_freeN(path); } @@ -1387,7 +1391,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) NlaStrip *strip= (NlaStrip *)ptr.data; FCurve *fcu= list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), flag); - success+= insert_keyframe_direct(ptr, prop, fcu, cfra, 0); + success+= insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0); } else { if (G.f & G_DEBUG) @@ -1456,14 +1460,14 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (all) { length= RNA_property_array_length(&ptr, prop); - if(length) index= 0; + if (length) index= 0; else length= 1; } else length= 1; for (a=0; a<length; a++) - success+= delete_keyframe(ptr.id.data, NULL, NULL, path, index+a, cfra, 0); + success+= delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index+a, cfra, 0); MEM_freeN(path); } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index aec35df5dd5..5d96c015caa 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -692,7 +692,7 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK /* Menu of All Keying Sets ----------------------------- */ /* Create (and show) a menu containing all the Keying Sets which can be used in the current context */ -void ANIM_keying_sets_menu_setup (bContext *C, char title[], char op_name[]) +void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op_name[]) { Scene *scene= CTX_data_scene(C); KeyingSet *ks; @@ -818,6 +818,7 @@ void ANIM_relative_keyingset_add_source (ListBase *dsources, ID *id, StructRNA * int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { Scene *scene= CTX_data_scene(C); + ReportList *reports = CTX_wm_reports(C); KS_Path *ksp; int kflag=0, success= 0; char *groupname= NULL; @@ -913,9 +914,9 @@ int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingS for (; i < arraylen; i++) { /* action to take depends on mode */ if (mode == MODIFYKEY_MODE_INSERT) - success += insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2); + success += insert_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2); else if (mode == MODIFYKEY_MODE_DELETE) - success += delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2); + success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2); } /* set recalc-flags */ diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index 62b76655010..b79c77d6e97 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -44,8 +44,4 @@ SET(SRC reeb.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_armature "${SRC}" "${INC}") diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 8b5b99c2870..fc9324d1742 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -31,6 +31,7 @@ #include <string.h> #include <math.h> #include <float.h> +#include <assert.h> #include "DNA_anim_types.h" @@ -2066,136 +2067,126 @@ void ED_armature_to_edit(Object *ob) /* adjust bone roll to align Z axis with vector * vec is in local space and is normalized */ -float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]) + +float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short axis_only) { - float mat[3][3], nor[3], up_axis[3], vec[3]; - float roll; + float mat[3][3], nor[3]; sub_v3_v3v3(nor, bone->tail, bone->head); - - vec_roll_to_mat3(nor, 0, mat); - copy_v3_v3(up_axis, mat[2]); - - roll = angle_normalized_v3v3(new_up_axis, up_axis); - - cross_v3_v3v3(vec, up_axis, new_up_axis); - - if (dot_v3v3(vec, nor) < 0) - { - roll = -roll; - } - - return roll; -} + vec_roll_to_mat3(nor, 0.0f, mat); + /* check the bone isnt aligned with the axis */ + if(!is_zero_v3(align_axis) && angle_v3v3(align_axis, mat[2]) > FLT_EPSILON) { + float vec[3], align_axis_proj[3], roll; -/* Set roll value for given bone -> Z-Axis Point up (original method) */ -static void auto_align_ebone_zaxisup(Scene *UNUSED(scene), View3D *UNUSED(v3d), EditBone *ebone) -{ - float delta[3], curmat[3][3]; - float xaxis[3]={1.0f, 0.0f, 0.0f}, yaxis[3], zaxis[3]={0.0f, 0.0f, 1.0f}; - float targetmat[3][3], imat[3][3], diffmat[3][3]; - - /* Find the current bone matrix */ - sub_v3_v3v3(delta, ebone->tail, ebone->head); - vec_roll_to_mat3(delta, 0.0f, curmat); - - /* Make new matrix based on y axis & z-up */ - copy_v3_v3(yaxis, curmat[1]); - - unit_m3(targetmat); - copy_v3_v3(targetmat[0], xaxis); - copy_v3_v3(targetmat[1], yaxis); - copy_v3_v3(targetmat[2], zaxis); - normalize_m3(targetmat); - - /* Find the difference between the two matrices */ - invert_m3_m3(imat, targetmat); - mul_m3_m3m3(diffmat, imat, curmat); - - // old-method... let's see if using mat3_to_vec_roll is more accurate - //ebone->roll = atan2(diffmat[2][0], diffmat[2][2]); - mat3_to_vec_roll(diffmat, delta, &ebone->roll); -} - -void auto_align_ebone_topoint(EditBone *ebone, float *cursor) -{ - float delta[3], curmat[3][3]; - float mat[4][4], tmat[4][4], imat[4][4]; - float rmat[4][4], rot[3]; - float vec[3]; - - /* find the current bone matrix as a 4x4 matrix (in Armature Space) */ - sub_v3_v3v3(delta, ebone->tail, ebone->head); - vec_roll_to_mat3(delta, ebone->roll, curmat); - copy_m4_m3(mat, curmat); - copy_v3_v3(mat[3], ebone->head); - - /* multiply bone-matrix by object matrix (so that bone-matrix is in WorldSpace) */ - invert_m4_m4(imat, mat); - - /* find position of cursor relative to bone */ - mul_v3_m4v3(vec, imat, cursor); - - /* check that cursor is in usable position */ - if ((IS_EQ(vec[0], 0)==0) && (IS_EQ(vec[2], 0)==0)) { - /* Compute a rotation matrix around y */ - rot[1] = (float)atan2(vec[0], vec[2]); - rot[0] = rot[2] = 0.0f; - eul_to_mat4( rmat,rot); + /* project the new_up_axis along the normal */ + project_v3_v3v3(vec, align_axis, nor); + sub_v3_v3v3(align_axis_proj, align_axis, vec); - /* Multiply the bone matrix by rotation matrix. This should be new bone-matrix */ - mul_m4_m4m4(tmat, rmat, mat); - copy_m3_m4(curmat, tmat); + if(axis_only) { + if(angle_v3v3(align_axis_proj, mat[2]) > M_PI/2) { + negate_v3(align_axis_proj); + } + } - /* Now convert from new bone-matrix, back to a roll value (in radians) */ - mat3_to_vec_roll(curmat, delta, &ebone->roll); - } -} + roll = angle_v3v3(align_axis_proj, mat[2]); + + cross_v3_v3v3(vec, mat[2], align_axis_proj); + + if (dot_v3v3(vec, nor) < 0) { + roll = -roll; + } -static void auto_align_ebone_tocursor(Scene *scene, View3D *v3d, EditBone *ebone) -{ - float cursor_local[3]; - float *cursor= give_cursor(scene, v3d); - float imat[3][3]; + return roll; + } - copy_m3_m4(imat, scene->obedit->obmat); - invert_m3(imat); - copy_v3_v3(cursor_local, cursor); - mul_m3_v3(imat, cursor_local); - auto_align_ebone_topoint(ebone, cursor_local); + return 0.0f; } + static EnumPropertyItem prop_calc_roll_types[] = { - {0, "GLOBALUP", 0, "Z-Axis Up", ""}, - {1, "CURSOR", 0, "Z-Axis to Cursor", ""}, + {0, "X", 0, "X Axis", ""}, + {1, "Y", 0, "Y Axis", ""}, + {2, "Z", 0, "Z Axis", ""}, + {5, "ACTIVE", 0, "Active Bone", ""}, + {6, "VIEW", 0, "View Axis", ""}, + {7, "CURSOR", 0, "Cursor", ""}, {0, NULL, 0, NULL, NULL} }; + static int armature_calc_roll_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); Object *ob= CTX_data_edit_object(C); - void (*roll_func)(Scene *, View3D *, EditBone *) = NULL; + const short type= RNA_enum_get(op->ptr, "type"); + const short axis_only= RNA_boolean_get(op->ptr, "axis_only"); + const short axis_flip= RNA_boolean_get(op->ptr, "axis_flip"); + + float imat[3][3]; + + copy_m3_m4(imat, ob->obmat); + invert_m3(imat); + + if(type==7) { /* Cursor */ + Scene *scene= CTX_data_scene(C); + View3D *v3d= CTX_wm_view3d(C); /* can be NULL */ + float cursor_local[3]; + float *cursor= give_cursor(scene, v3d); - /* specific method used to calculate roll depends on mode */ - switch (RNA_enum_get(op->ptr, "type")) { - case 1: /* Z-Axis point towards cursor */ - roll_func= auto_align_ebone_tocursor; - break; - default: /* Z-Axis Point Up */ - roll_func= auto_align_ebone_zaxisup; - break; + + copy_v3_v3(cursor_local, cursor); + mul_m3_v3(imat, cursor_local); + + /* cursor */ + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { + float cursor_rel[3]; + sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); + if(axis_flip) negate_v3(cursor_rel); + ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only); + } + CTX_DATA_END; } - - /* recalculate roll on selected bones */ - CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { - /* roll func is a callback which assumes that all is well */ - roll_func(scene, v3d, ebone); + else { + float vec[3]= {0.0f, 0.0f, 0.0f}; + if(type==6) { /* View */ + RegionView3D *rv3d= CTX_wm_region_view3d(C); + if(rv3d==NULL) { + BKE_report(op->reports, RPT_ERROR, "No region view3d available"); + return OPERATOR_CANCELLED; + } + + copy_v3_v3(vec, rv3d->viewinv[2]); + mul_m3_v3(imat, vec); + } + else if (type==5) { + bArmature *arm= ob->data; + EditBone *ebone= (EditBone *)arm->act_edbone; + float mat[3][3], nor[3]; + + if(ebone==NULL) { + BKE_report(op->reports, RPT_ERROR, "No active bone set"); + return OPERATOR_CANCELLED; + } + + sub_v3_v3v3(nor, ebone->tail, ebone->head); + vec_roll_to_mat3(nor, ebone->roll, mat); + copy_v3_v3(vec, mat[2]); + } + else { /* Axis */ + assert(type >= 0 && type <= 5); + if(type<3) vec[type]= 1.0f; + else vec[type-2]= -1.0f; + mul_m3_v3(imat, vec); + } + + if(axis_flip) negate_v3(vec); + + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { + /* roll func is a callback which assumes that all is well */ + ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only); + } + CTX_DATA_END; } - CTX_DATA_END; - /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); @@ -2216,9 +2207,11 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + /* properties */ ot->prop= RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", ""); + RNA_def_boolean(ot->srna, "axis_flip", 0, "Flip Axis", "Negate the alignment axis."); + RNA_def_boolean(ot->srna, "axis_only", 0, "Shortest Rotation", "Ignore the axis direction, use the shortest rotation to align."); } /* **************** undo for armatures ************** */ @@ -2308,7 +2301,7 @@ static void *get_armature_edit(bContext *C) } /* and this is all the undo system needs to know */ -void undo_push_armature(bContext *C, char *name) +void undo_push_armature(bContext *C, const char *name) { // XXX solve getdata() undo_editmode_push(C, name, get_armature_edit, free_undoBones, undoBones_to_editBones, editBones_to_undoBones, NULL); @@ -2320,7 +2313,7 @@ void undo_push_armature(bContext *C, char *name) /* *************** Adding stuff in editmode *************** */ /* default bone add, returns it selected, but without tail set */ -EditBone *ED_armature_edit_bone_add(bArmature *arm, char *name) +EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) { EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone"); diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 6eda622ead8..6abdd85bf71 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -50,18 +50,12 @@ void setBoneRollFromNormal(EditBone *bone, float *no, float UNUSED(invmat[][4]), { if (no != NULL && !is_zero_v3(no)) { - float tangent[3], vec[3], normal[3]; + float normal[3]; - VECCOPY(normal, no); + copy_v3_v3(normal, no); mul_m3_v3(tmat, normal); - - sub_v3_v3v3(tangent, bone->tail, bone->head); - project_v3_v3v3(vec, tangent, normal); - sub_v3_v3(normal, vec); - - normalize_v3(normal); - bone->roll = ED_rollBoneToVector(bone, normal); + bone->roll = ED_rollBoneToVector(bone, normal, FALSE); } } diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index d50f2d00ebb..4ddc73df469 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -185,12 +185,12 @@ float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) { rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ - return ED_rollBoneToVector(bone, x_axis); + return ED_rollBoneToVector(bone, x_axis, FALSE); } else { rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */ - return ED_rollBoneToVector(bone, z_axis); + return ED_rollBoneToVector(bone, z_axis, FALSE); } } @@ -240,7 +240,7 @@ float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float /* real qroll between normal and up_axis */ rotation_between_vecs_to_quat(qroll, new_up_axis, normal); - return ED_rollBoneToVector(edge->bone, normal); + return ED_rollBoneToVector(edge->bone, normal, FALSE); } } @@ -251,9 +251,7 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) VECCOPY(new_up_axis, old_up_axis); mul_qt_v3(qrot, new_up_axis); - normalize_v3(new_up_axis); - - return ED_rollBoneToVector(bone, new_up_axis); + return ED_rollBoneToVector(bone, new_up_axis, FALSE); } /************************************ DESTRUCTORS ******************************************************/ diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index 2567494ddf3..171659a70df 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -106,6 +106,7 @@ void CURVE_OT_de_select_last(struct wmOperatorType *ot); void CURVE_OT_select_all(struct wmOperatorType *ot); void CURVE_OT_select_inverse(struct wmOperatorType *ot); void CURVE_OT_select_linked(struct wmOperatorType *ot); +void CURVE_OT_select_linked_pick(struct wmOperatorType *ot); void CURVE_OT_select_row(struct wmOperatorType *ot); void CURVE_OT_select_next(struct wmOperatorType *ot); void CURVE_OT_select_previous(struct wmOperatorType *ot); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 80582c7f1b0..1b3e5130c2d 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -117,6 +117,7 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_select_all); WM_operatortype_append(CURVE_OT_select_inverse); WM_operatortype_append(CURVE_OT_select_linked); + WM_operatortype_append(CURVE_OT_select_linked_pick); WM_operatortype_append(CURVE_OT_select_row); WM_operatortype_append(CURVE_OT_select_next); WM_operatortype_append(CURVE_OT_select_previous); @@ -201,8 +202,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "CURVE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1); + WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "CURVE_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1); WM_keymap_add_item(keymap, "CURVE_OT_separate", PKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CURVE_OT_extrude", EKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 97379cc110c..b35657cb266 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2597,7 +2597,7 @@ void CURVE_OT_select_inverse(wmOperatorType *ot) static void subdividenurb(Object *obedit, int number_cuts) { Curve *cu= obedit->data; - ListBase *editnurb= curve_get_editcurve(obedit); + EditNurb *editnurb= cu->editnurb; Nurb *nu; BezTriple *prevbezt, *bezt, *beztnew, *beztn; BPoint *bp, *prevbp, *bpnew, *bpn; @@ -2607,7 +2607,7 @@ static void subdividenurb(Object *obedit, int number_cuts) // printf("*** subdivideNurb: entering subdivide\n"); - for(nu= editnurb->first; nu; nu= nu->next) { + for(nu= editnurb->nurbs.first; nu; nu= nu->next) { amount= 0; if(nu->type == CU_BEZIER) { /* @@ -2649,6 +2649,7 @@ static void subdividenurb(Object *obedit, int number_cuts) } while(a--) { memcpy(beztn, prevbezt, sizeof(BezTriple)); + keyIndex_updateBezt(editnurb, prevbezt, beztn, 1, 1); beztn++; if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { @@ -2691,7 +2692,10 @@ static void subdividenurb(Object *obedit, int number_cuts) bezt++; } /* last point */ - if((nu->flagu & CU_NURB_CYCLIC)==0) memcpy(beztn, prevbezt, sizeof(BezTriple)); + if((nu->flagu & CU_NURB_CYCLIC)==0) { + memcpy(beztn, prevbezt, sizeof(BezTriple)); + keyIndex_updateBezt(editnurb, prevbezt, beztn, 1, 1); + } MEM_freeN(nu->bezt); nu->bezt= beztnew; @@ -2742,6 +2746,7 @@ static void subdividenurb(Object *obedit, int number_cuts) } while(a--) { memcpy(bpn, prevbp, sizeof(BPoint)); + keyIndex_updateBP(editnurb, prevbp, bpn, 1, 1); bpn++; if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) { @@ -2758,7 +2763,10 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbp= bp; bp++; } - if((nu->flagu & CU_NURB_CYCLIC)==0) memcpy(bpn, prevbp, sizeof(BPoint)); /* last point */ + if((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */ + memcpy(bpn, prevbp, sizeof(BPoint)); + keyIndex_updateBP(editnurb, prevbp, bpn, 1, 1); + } MEM_freeN(nu->bp); nu->bp= bpnew; @@ -2845,6 +2853,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for(a=0; a<nu->pntsv; a++) { for(b=0; b<nu->pntsu; b++) { *bpn= *bp; + keyIndex_updateBP(editnurb, bp, bpn, 1, 1); bpn++; bp++; if(b<nu->pntsu-1) { @@ -2901,6 +2910,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for(a=0; a<nu->pntsv; a++) { for(b=0; b<nu->pntsu; b++) { *bpn= *bp; + keyIndex_updateBP(editnurb, bp, bpn, 1, 1); bpn++; bp++; } @@ -2947,6 +2957,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for(a=0; a<nu->pntsv; a++) { for(b=0; b<nu->pntsu; b++) { *bpn= *bp; + keyIndex_updateBP(editnurb, bp, bpn, 1, 1); bpn++; bp++; if( (b<nu->pntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) { @@ -3712,7 +3723,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) BezTriple *bezt; BPoint *bp; float *fp, offset; - int a; + int a, ok= 0; /* first decide if this is a surface merge! */ if(obedit->type==OB_SURF) nu= nubase->first; @@ -3854,16 +3865,27 @@ static int make_segment_exec(bContext *C, wmOperator *op) } set_actNurb(obedit, NULL); /* for selected */ - - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_flush_update(obedit->data, OB_RECALC_DATA); - - return OPERATOR_FINISHED; + ok= 1; + } else if(nu1 && !nu2 && nu1->type == CU_BEZIER) { + if(!(nu1->flagu & CU_NURB_CYCLIC)) { + if(BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt) && + BEZSELECTED_HIDDENHANDLES(cu, bezt+(nu1->pntsu-1))) { + nu1->flagu|= CU_NURB_CYCLIC; + calchandlesNurb(nu1); + ok= 1; + } + } } - else { + + if(!ok) { BKE_report(op->reports, RPT_ERROR, "Can't make segment"); return OPERATOR_CANCELLED; } + + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + DAG_id_flush_update(obedit->data, OB_RECALC_DATA); + + return OPERATOR_FINISHED; } void CURVE_OT_make_segment(wmOperatorType *ot) @@ -4117,7 +4139,10 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) invert_m3_m3(imat,mat); findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp); - if(bezt==0 && bp==0) return OPERATOR_CANCELLED; + + if((nu->type==CU_BEZIER && bezt==NULL) || (nu->type!=CU_BEZIER && bp==NULL)) { + return OPERATOR_CANCELLED; + } if(nu->type == CU_BEZIER) { /* which bezpoint? */ @@ -4454,24 +4479,99 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) /***************** select linked operator ******************/ -static int select_linked_exec(bContext *C, wmOperator *op) +static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit= CTX_data_edit_object(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); + Curve *cu= (Curve*)obedit->data; + EditNurb *editnurb= cu->editnurb; + ListBase *nurbs= &editnurb->nurbs; + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + int a; + + for(nu= nurbs->first; nu; nu= nu->next) { + if(nu->type == CU_BEZIER) { + bezt= nu->bezt; + a= nu->pntsu; + while(a--) { + if( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) { + a= nu->pntsu; + bezt= nu->bezt; + while(a--) { + select_beztriple(bezt, SELECT, 1, VISIBLE); + bezt++; + } + break; + } + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + while(a--) { + if( bp->f1 & 1 ) { + a= nu->pntsu*nu->pntsv; + bp= nu->bp; + while(a--) { + select_bpoint(bp, SELECT, 1, VISIBLE); + bp++; + } + break; + } + bp++; + } + } + } + + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + + return OPERATOR_FINISHED; +} + +static int select_linked_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + return select_linked_exec(C, op); +} + +void CURVE_OT_select_linked(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Select Linked All"; + ot->idname= "CURVE_OT_select_linked"; + + /* api callbacks */ + ot->exec= select_linked_exec; + ot->invoke= select_linked_invoke; + ot->poll= ED_operator_editsurfcurve; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ +} + + +/***************** select linked pick operator ******************/ + +static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *obedit= CTX_data_edit_object(C); + ARegion *ar= CTX_wm_region(C); ViewContext vc; Nurb *nu; BezTriple *bezt; BPoint *bp; int a, location[2], deselect; - if(!rv3d) - return OPERATOR_CANCELLED; - deselect= RNA_boolean_get(op->ptr, "deselect"); - RNA_int_get_array(op->ptr, "location", location); - + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; + view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); + findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); if(bezt) { @@ -4494,39 +4594,25 @@ static int select_linked_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - - return OPERATOR_FINISHED; -} - -static int select_linked_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ARegion *ar= CTX_wm_region(C); - int location[2]; - location[0]= event->x - ar->winrct.xmin; - location[1]= event->y - ar->winrct.ymin; - RNA_int_set_array(op->ptr, "location", location); - - return select_linked_exec(C, op); + return OPERATOR_FINISHED; } -void CURVE_OT_select_linked(wmOperatorType *ot) +void CURVE_OT_select_linked_pick(wmOperatorType *ot) { /* identifiers */ ot->name= "Select Linked"; - ot->idname= "CURVE_OT_select_linked"; - + ot->idname= "CURVE_OT_select_linked_pick"; + /* api callbacks */ - ot->exec= select_linked_exec; - ot->invoke= select_linked_invoke; - ot->poll= ED_operator_editsurfcurve; + ot->invoke= select_linked_pick_invoke; + ot->poll= ED_operator_editsurfcurve_region_view3d; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect linked control points rather than selecting them."); - RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "", 0, 16384); } /***************** select row operator **********************/ @@ -5298,6 +5384,7 @@ static int delete_exec(bContext *C, wmOperator *op) bezt2= bezt+(nu->pntsu-1); if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) { nu->flagu &= ~CU_NURB_CYCLIC; + calchandlesNurb(nu); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); DAG_id_flush_update(obedit->data, OB_RECALC_DATA); } @@ -5610,7 +5697,48 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) } /************ add primitive, used by object/ module ****************/ -Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) + +static char *get_curve_defname(int type) +{ + int stype= type & CU_PRIMITIVE; + + if((type & CU_TYPE)==CU_BEZIER) { + switch (stype) { + case CU_PRIM_CURVE: return "BezierCurve"; + case CU_PRIM_CIRCLE: return "BezierCircle"; + case CU_PRIM_PATH: return "CurvePath"; + default: + return "Curve"; + } + } + else { + switch (stype) { + case CU_PRIM_CURVE: return "NurbsCurve"; + case CU_PRIM_CIRCLE: return "NurbsCircle"; + case CU_PRIM_PATH: return "NurbsPath"; + default: + return "Curve"; + } + } +} + +static char *get_surf_defname(int type) +{ + int stype= type & CU_PRIMITIVE; + + switch (stype) { + case CU_PRIM_CURVE: return "SurfCurve"; + case CU_PRIM_CIRCLE: return "SurfCircle"; + case CU_PRIM_PATCH: return "SurfPatch"; + case CU_PRIM_SPHERE: return "SurfSphere"; + case CU_PRIM_DONUT: return "SurfTorus"; + default: + return "Surface"; + } +} + + +Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) { static int xzproj= 0; /* this function calls itself... */ Object *obedit= CTX_data_edit_object(C); @@ -5635,7 +5763,6 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) if (v3d) grid = v3d->grid; else grid = 1.0; - setflagsNurb(editnurb, 0); /* these types call this function to return a Nurb */ @@ -5649,10 +5776,6 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) switch(stype) { case CU_PRIM_CURVE: /* curve */ nu->resolu= cu->resolu; - if(newname) { - rename_id((ID *)obedit, "Curve"); - rename_id((ID *)obedit->data, "Curve"); - } if(cutype==CU_BEZIER) { if (!force_3d) nu->flag |= CU_2D; nu->pntsu= 2; @@ -5755,10 +5878,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) break; case CU_PRIM_CIRCLE: /* circle */ nu->resolu= cu->resolu; - if(newname) { - rename_id((ID *)obedit, "CurveCircle"); - rename_id((ID *)obedit->data, "CurveCircle"); - } + if(cutype==CU_BEZIER) { if (!force_3d) nu->flag |= CU_2D; nu->pntsu= 4; @@ -5826,10 +5946,6 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) break; case CU_PRIM_PATCH: /* 4x4 patch */ if( cutype==CU_NURBS ) { /* nurb */ - if(newname) { - rename_id((ID *)obedit, "Surf"); - rename_id((ID *)obedit->data, "Surf"); - } nu->pntsu= 4; nu->pntsv= 4; @@ -5865,11 +5981,6 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) if( cutype==CU_NURBS ) { Curve *cu= (Curve*)obedit->data; - if(newname) { - rename_id((ID *)obedit, "SurfCylinder"); - rename_id((ID *)obedit->data, "SurfCylinder"); - } - nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ nu->resolu= cu->resolu; nu->flag= CU_SMOOTH; @@ -5877,7 +5988,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) vec[0]=vec[1]= 0.0; vec[2]= -grid; - if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) { + if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { /* pass */ } else { @@ -5906,11 +6017,6 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) float tmp_cent[3] = {0.f, 0.f, 0.f}; float tmp_vec[3] = {0.f, 0.f, 1.f}; - if(newname) { - rename_id((ID *)obedit, "SurfSphere"); - rename_id((ID *)obedit->data, "SurfSphere"); - } - nu->pntsu= 5; nu->pntsv= 1; nu->orderu= 3; @@ -5935,7 +6041,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) BLI_addtail(editnurb, nu); /* temporal for spin */ - if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(rv3d->viewmat, obedit, rv3d->viewinv[2], mat[3]); else spin_nurb(umat, obedit, tmp_vec, mat[3]); @@ -5955,11 +6061,6 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) float tmp_cent[3] = {0.f, 0.f, 0.f}; float tmp_vec[3] = {0.f, 0.f, 1.f}; - if(newname) { - rename_id((ID *)obedit, "SurfTorus"); - rename_id((ID *)obedit->data, "SurfTorus"); - } - xzproj= 1; nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ xzproj= 0; @@ -5969,7 +6070,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) BLI_addtail(editnurb, nu); /* temporal for spin */ /* same as above */ - if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(rv3d->viewmat, obedit, rv3d->viewinv[2], mat[3]); else spin_nurb(umat, obedit, tmp_vec, mat[3]); @@ -6012,21 +6113,43 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) if (!isSurf) { /* adding curve */ if(obedit==NULL || obedit->type!=OB_CURVE) { Curve *cu; + obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); newob = 1; cu= (Curve*)obedit->data; cu->flag |= CU_DEFORM_FILL; + if(type & CU_PRIM_PATH) cu->flag |= CU_PATH|CU_3D; - } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - } else { /* adding surface */ + } + else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + } + else { /* adding surface */ if(obedit==NULL || obedit->type!=OB_SURF) { obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); newob = 1; - } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + } + else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); } + /* rename here, the undo stack checks name for valid undo pushes */ + if(newob) { + + if(obedit->type==OB_CURVE) { + rename_id((ID *)obedit, get_curve_defname(type)); + rename_id((ID *)obedit->data, get_curve_defname(type)); + } + else { + rename_id((ID *)obedit, get_surf_defname(type)); + rename_id((ID *)obedit->data, get_surf_defname(type)); + } + } + + /* ED_object_add_type doesnt do an undo, is needed for redo operator on primitive */ + if(newob && enter_editmode) + ED_undo_push(C, "Enter Editmode"); + ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); nu= add_nurbs_primitive(C, mat, type, newob); @@ -6468,7 +6591,7 @@ static void *get_data(bContext *C) } /* and this is all the undo system needs to know */ -void undo_push_curve(bContext *C, char *name) +void undo_push_curve(bContext *C, const char *name) { undo_editmode_push(C, name, get_data, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve, NULL); } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 13678b0dfe5..19a8030c6be 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -325,7 +325,7 @@ void FONT_OT_insert_lorem(wmOperatorType *ot) /* note this handles both ascii and utf8 unicode, previously * there were 3 functions that did effectively the same thing. */ -static int paste_file(bContext *C, ReportList *reports, char *filename) +static int paste_file(bContext *C, ReportList *reports, const char *filename) { Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); @@ -1696,7 +1696,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) cu = ob->data; font = cu->vfont; } - printf("%s\n", font->name); + path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir; if(RNA_property_is_set(op->ptr, "filepath")) @@ -1840,7 +1840,7 @@ static void *get_undoFont(bContext *C) } /* and this is all the undo system needs to know */ -void undo_push_font(bContext *C, char *name) +void undo_push_font(bContext *C, const char *name) { undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL); } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 1514facc441..f32555baa67 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -35,6 +35,7 @@ struct AnimData; struct bContext; struct wmKeyConfig; +struct ReportList; struct ScrArea; struct ARegion; struct View2D; @@ -73,7 +74,8 @@ typedef struct bAnimContext { struct Scene *scene; /* active scene */ struct Object *obact; /* active object */ ListBase *markers; /* active set of markers */ - ListBase *reports; /* pointer to current reports list */ // XXX not yet used + + struct ReportList *reports; /* pointer to current reports list */ } bAnimContext; /* Main Data container types */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 3e16cae5527..0db8ffd733e 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -115,13 +115,13 @@ int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int int mouse_armature(struct bContext *C, short mval[2], int extend); int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone (struct Object *ob, int index); -float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]); +float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, EditBone *ebo); // XXX this is needed for populating the context iterators void ED_armature_sync_selection(struct ListBase *edbo); void ED_armature_validate_active(struct bArmature *arm); void add_primitive_bone(struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d); -struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, char *name); +struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name); void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone); void transform_armature_mirror_update(struct Object *obedit); @@ -140,7 +140,7 @@ void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode); void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */ void ED_armature_bone_rename(struct bArmature *arm, char *oldnamep, char *newnamep); -void undo_push_armature(struct bContext *C, char *name); +void undo_push_armature(struct bContext *C, const char *name); /* poseobject.c */ struct Object *ED_object_pose_armature(struct Object *ob); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 0ff98b504d0..b59ac68e328 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -52,7 +52,7 @@ void CU_select_all(struct Object *obedit); void CU_select_swap(struct Object *obedit); -void undo_push_curve (struct bContext *C, char *name); +void undo_push_curve (struct bContext *C, const char *name); ListBase *curve_get_editcurve(struct Object *ob); void load_editNurb (struct Object *obedit); @@ -63,14 +63,14 @@ void free_curve_editNurb (struct Curve *cu); int mouse_nurb (struct bContext *C, short mval[2], int extend); -struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newname); +struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob); int isNurbsel (struct Nurb *nu);; int join_curve_exec (struct bContext *C, struct wmOperator *op); /* editfont.h */ -void undo_push_font (struct bContext *C, char *name); +void undo_push_font (struct bContext *C, const char *name); void make_editText (struct Object *obedit); void load_editText (struct Object *obedit); void free_editText (struct Object *obedit); diff --git a/source/blender/editors/include/ED_info.h b/source/blender/editors/include/ED_info.h index 33b890cea60..ece57d19ace 100644 --- a/source/blender/editors/include/ED_info.h +++ b/source/blender/editors/include/ED_info.h @@ -27,6 +27,6 @@ /* info_stats.c */ void ED_info_stats_clear(struct Scene *scene); -char *ED_info_stats_string(struct Scene *scene); +const char *ED_info_stats_string(struct Scene *scene); #endif /* ED_INFO_H */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 2650005a489..ff4ec92562f 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -47,6 +47,7 @@ struct bConstraint; struct bContext; struct wmOperatorType; +struct ReportList; struct PointerRNA; struct PropertyRNA; @@ -93,7 +94,7 @@ int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag); * Use this to insert a keyframe using the current value being keyframed, in the * nominated F-Curve (no creation of animation data performed). Returns success. */ -short insert_keyframe_direct(struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, short flag); +short insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, short flag); /* -------- */ @@ -101,12 +102,12 @@ short insert_keyframe_direct(struct PointerRNA ptr, struct PropertyRNA *prop, st * Use this to create any necessary animation data, and then insert a keyframe * using the current value being keyframed, in the relevant place. Returns success. */ -short insert_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag); +short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag); /* Main Keyframing API call: * Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case. */ -short delete_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag); +short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag); /* ************ Keying Sets ********************** */ @@ -201,7 +202,7 @@ int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks); struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const char *tranformKSName); /* Create (and show) a menu containing all the Keying Sets which can be used in the current context */ -void ANIM_keying_sets_menu_setup(struct bContext *C, char title[], char op_name[]); +void ANIM_keying_sets_menu_setup(struct bContext *C, const char title[], const char op_name[]); /* Check if KeyingSet can be used in the current context */ short ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 3fd74a9cdaf..f5021fb9570 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -41,5 +41,5 @@ void free_editMball(struct Object *obedit); void make_editMball(struct Object *obedit); void load_editMball(struct Object *obedit); -void undo_push_mball(struct bContext *C, char *name); +void undo_push_mball(struct bContext *C, const char *name); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index cf0334ce6b3..e376fa9a655 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -117,7 +117,7 @@ struct EditFace *EM_get_face_for_index(int index); int EM_texFaceCheck(struct EditMesh *em); int EM_vertColorCheck(struct EditMesh *em); -void undo_push_mesh(struct bContext *C, char *name); +void undo_push_mesh(struct bContext *C, const char *name); /* editmesh_lib.c */ @@ -196,7 +196,7 @@ int paintface_minmax(struct Object *ob, float *min, float *max); #define WEIGHT_SUBTRACT 3 struct bDeformGroup *ED_vgroup_add(struct Object *ob); -struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, char *name); +struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name); void ED_vgroup_select_by_name(struct Object *ob, char *name); void 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 63af7c5abd3..dec13558792 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -125,7 +125,7 @@ void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *sc /* object_lattice.c */ int mouse_lattice(struct bContext *C, short mval[2], int extend); -void undo_push_lattice(struct bContext *C, char *name); +void undo_push_lattice(struct bContext *C, const char *name); /* object_lattice.c */ @@ -137,7 +137,7 @@ enum { MODIFIER_APPLY_SHAPE, } eModifier_Apply_Mode; -struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, char *name, int type); +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); 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); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index f3b65b343ef..32b2b8194d2 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -63,7 +63,7 @@ int PE_lasso_select(struct bContext *C, short mcords[][2], short moves, short ex void PE_deselect_all_visible(struct PTCacheEdit *edit); /* undo */ -void PE_undo_push(struct Scene *scene, char *str); +void PE_undo_push(struct Scene *scene, const char *str); void PE_undo_step(struct Scene *scene, int step); void PE_undo(struct Scene *scene); void PE_redo(struct Scene *scene); diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 4d3e40274f7..559156fe89d 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -81,7 +81,7 @@ void ED_area_tag_redraw(ScrArea *sa); void ED_area_tag_redraw_regiontype(ScrArea *sa, int type); void ED_area_tag_refresh(ScrArea *sa); void ED_area_do_refresh(struct bContext *C, ScrArea *sa); -void ED_area_headerprint(ScrArea *sa, char *str); +void ED_area_headerprint(ScrArea *sa, const char *str); void ED_area_newspace(struct bContext *C, ScrArea *sa, int type); void ED_area_prevspace(struct bContext *C, ScrArea *sa); void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2); @@ -156,6 +156,7 @@ int ED_operator_editarmature(struct bContext *C); int ED_operator_editcurve(struct bContext *C); int ED_operator_editsurf(struct bContext *C); int ED_operator_editsurfcurve(struct bContext *C); +int ED_operator_editsurfcurve_region_view3d(struct bContext *C); int ED_operator_editfont(struct bContext *C); int ED_operator_editlattice(struct bContext *C); int ED_operator_editmball(struct bContext *C); diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 7bf3ec88a4b..618353c100b 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -43,7 +43,7 @@ void ED_editors_exit (struct bContext *C); /* ************** Undo ************************ */ /* undo.c */ -void ED_undo_push (struct bContext *C, char *str); +void ED_undo_push (struct bContext *C, const char *str); void ED_undo_push_op (struct bContext *C, struct wmOperator *op); void ED_undo_pop_op (struct bContext *C, struct wmOperator *op); void ED_undo_pop (struct bContext *C); @@ -52,7 +52,7 @@ void ED_OT_undo (struct wmOperatorType *ot); void ED_OT_redo (struct wmOperatorType *ot); /* undo_editmode.c */ -void undo_editmode_push(struct bContext *C, char *name, +void undo_editmode_push(struct bContext *C, const char *name, void * (*getdata)(struct bContext *C), void (*freedata)(void *), void (*to_editmode)(void *, void *), diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 2b5dc3b14ff..870fd452b22 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -79,6 +79,7 @@ void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my); void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ +void view3d_update_depths(struct ARegion *ar); float read_cached_depth(struct ViewContext *vc, int x, int y); void request_depth_update(struct RegionView3D *rv3d); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index bb3dad8d065..c0b2843d62b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -280,7 +280,7 @@ uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon); void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head); struct uiLayout *uiPupMenuLayout(uiPopupMenu *head); -void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...); +void uiPupMenuOkee(struct bContext *C, const char *opname, char *str, ...); void uiPupMenuSaveOver(struct bContext *C, struct wmOperator *op, char *filename); void uiPupMenuNotice(struct bContext *C, char *str, ...); void uiPupMenuError(struct bContext *C, char *str, ...); @@ -295,7 +295,7 @@ void uiPupMenuInvoke(struct bContext *C, const char *idname); /* popup registere typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1); void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg); -void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext); +void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext); void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); void uiPupBlockClose(struct bContext *C, uiBlock *block); @@ -315,7 +315,7 @@ uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, const ch void uiEndBlock(const struct bContext *C, uiBlock *block); void uiDrawBlock(const struct bContext *C, struct uiBlock *block); -uiBlock *uiGetBlock(char *name, struct ARegion *ar); +uiBlock *uiGetBlock(const char *name, struct ARegion *ar); void uiBlockSetEmboss(uiBlock *block, char dt); @@ -384,13 +384,13 @@ int uiButActiveOnly (const struct bContext *C, uiBlock *block, uiBut *but); * - O: operator */ uiBut *uiDefBut(uiBlock *block, - int type, int retval, char *str, + int type, int retval, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefButF(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefButF(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefButI(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip); @@ -398,9 +398,9 @@ uiBut *uiDefButS(uiBlock *block, int type, int retval, char *str, short x1, shor uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefButC(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip); -uiBut *uiDefButTextO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip); +uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, @@ -418,25 +418,25 @@ uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip); +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip); uiBut *uiDefIconTextBut(uiBlock *block, - int type, int retval, int icon, char *str, + int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip); -uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip); +uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip); +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, short x1, short y1, short x2, short y2, char *tip); /* for passing inputs to ButO buttons */ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); @@ -526,7 +526,7 @@ 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, char *str, uiSearchItems *items); +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 */ @@ -637,8 +637,8 @@ void uiBlockLayoutResolve(uiBlock *block, int *x, int *y); uiBlock *uiLayoutGetBlock(uiLayout *layout); void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); -void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr); -char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing +void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr); +const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); void uiLayoutSetActive(uiLayout *layout, int active); @@ -675,28 +675,28 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout); /* templates */ void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus); void uiTemplateDopeSheetFilter(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); -void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop); -void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop); -void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, - char *newop, char *openop, char *unlinkop, int rows, int cols); -void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, char *propname, - char *proptypename, char *text); -void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, char *propname, - struct PointerRNA *root_ptr, char *text); +void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, + const char *newop, const char *openop, const char *unlinkop); +void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, + const char *newop, const char *openop, const char *unlinkop); +void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, + const char *newop, const char *openop, const char *unlinkop, int rows, int cols); +void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, + const char *proptypename, const char *text); +void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, + struct PointerRNA *root_ptr, const char *text); uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); -void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); -void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand); -void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, char *propname); -void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, char *propname); -void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, char *propname); -void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, char *propname, int type, int levels, int brush); -void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, char *propname, int value_slider, int lock, int lock_luminosity, int cubic); -void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname, - PointerRNA *used_ptr, char *used_propname, int active_layer); -void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *userptr, int compact); +void uiTemplatePreview(uiLayout *layout, struct ID *id, int show_buttons, struct ID *parent, struct MTex *slot); +void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand); +void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname); +void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname); +void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname); +void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush); +void uiTemplateColorWheel(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic); +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 uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); @@ -704,36 +704,36 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex); void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C); -void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int maxrows, int type); +void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type); /* items */ -void uiItemO(uiLayout *layout, char *name, int icon, char *opname); -void uiItemEnumO(uiLayout *layout, char *opname, char *name, int icon, char *propname, int value); -void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value); -void uiItemsEnumO(uiLayout *layout, char *opname, char *propname); -void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value); -void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value); -void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value); -void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value); -PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, struct IDProperty *properties, int context, int flag); - -void uiItemR(uiLayout *layout, struct PointerRNA *ptr, char *propname, int flag, char *name, int icon); -void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, char *name, int icon); -void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value); -void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *value, char *name, int icon); -void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname); -void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname, char *name, int icon); -void uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, struct IDProperty *properties, int context, int flag); - -void uiItemL(uiLayout *layout, char *name, int icon); /* label */ +void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); +void uiItemEnumO(uiLayout *layout, const char *opname, char *name, int icon, const char *propname, int value); +void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, char *value); +void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname); +void uiItemBooleanO(uiLayout *layout, char *name, int icon, const char *opname, const char *propname, int value); +void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); +void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value); +void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, char *value); +PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag); + +void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon); +void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon); +void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value); +void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon); +void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname); +void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon); +void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, struct IDProperty *properties, int context, int flag); + +void uiItemL(uiLayout *layout, const char *name, int icon); /* label */ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, char *name, int icon); /* label icon for dragging */ -void uiItemM(uiLayout *layout, struct bContext *C, char *menuname, char *name, int icon); /* menu */ +void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */ void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */ void uiItemS(uiLayout *layout); /* separator */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg); -void uiItemMenuEnumO(uiLayout *layout, char *opname, char *propname, char *name, int icon); -void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *name, int icon); +void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg); +void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon); +void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon); /* UI Operators */ void UI_buttons_operatortypes(void); @@ -749,8 +749,8 @@ void uiStyleFontSet(struct uiFontStyle *fs); void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str); void uiStyleFontDrawRotated(struct uiFontStyle *fs, struct rcti *rect, char *str); -int UI_GetStringWidth(char *str); // XXX temp -void UI_DrawString(float x, float y, char *str); // XXX temp +int UI_GetStringWidth(const char *str); // XXX temp +void UI_DrawString(float x, float y, const char *str); // XXX temp #endif /* UI_INTERFACE_H */ diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index 73fc2d6316d..b698cd610a2 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -66,7 +66,7 @@ void UI_icons_free(); void UI_icons_free_drawinfo(void *drawinfo); struct ListBase *UI_iconfile_list(void); -int UI_iconfile_get_index(char *filename); +int UI_iconfile_get_index(const char *filename); #endif /* UI_INTERFACE_ICONS_H */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index dfb375225b4..62225adda3e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -759,6 +759,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block) /* widgets */ for(but= block->buttons.first; but; but= but->next) { ui_but_to_pixelrect(&rect, ar, block, but); + if(!(but->flag & UI_HIDDEN) && /* XXX: figure out why invalid coordinates happen when closing render window */ /* and material preview is redrawn in main window (temp fix for bug #23848) */ @@ -1252,8 +1253,8 @@ int ui_is_but_unit(uiBut *but) unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); -#if 0 // removed so angle buttons get correct snapping - if (scene->unit.flag & USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) +#if 1 // removed so angle buttons get correct snapping + if (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION) return 0; #endif @@ -1941,7 +1942,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor return block; } -uiBlock *uiGetBlock(char *name, ARegion *ar) +uiBlock *uiGetBlock(const char *name, ARegion *ar) { uiBlock *block= ar->uiblocks.first; @@ -2212,7 +2213,7 @@ static void ui_block_do_align_but(uiBut *first, int nr) /* clear old flag */ but->flag &= ~UI_BUT_ALIGN; - + if(flag==0) { /* first case */ if(next) { if(buts_are_horiz(but, next)) { @@ -2261,14 +2262,19 @@ static void ui_block_do_align_but(uiBut *first, int nr) else { /* next button switches to new row */ if(prev && buts_are_horiz(prev, but)) - flag |= UI_BUT_ALIGN_LEFT; + flag |= UI_BUT_ALIGN_LEFT; + else { + flag &= ~UI_BUT_ALIGN_LEFT; + flag |= UI_BUT_ALIGN_TOP; + } if( (flag & UI_BUT_ALIGN_TOP)==0) { /* stil top row */ if(prev) { - if(next && buts_are_horiz(next, but)) - flag = UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT; - else { + if(next && buts_are_horiz(but, next)) flag = UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT; + else { + /* last button in top row */ + flag = UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT; } } else @@ -2303,6 +2309,10 @@ static void ui_block_do_align_but(uiBut *first, int nr) /* the previous button is a single one in its row */ but->y2= (prev->y1+but->y2)/2.0; prev->y1= but->y2; + + but->x1= prev->x1; + if(next && buts_are_horiz(but, next)==0) + but->x2= prev->x2; } else { /* the previous button is not a single one in its row */ @@ -2344,7 +2354,7 @@ for float buttons: all greater values will be clamped to 4. */ -static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) +static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; short slen; @@ -2439,7 +2449,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short return but; } -uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip) +static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, short x1, short y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip) { uiBut *but; PropertyRNA *prop; @@ -2606,12 +2616,12 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, but->a1= ui_get_but_step_unit(but, but->a1); if(freestr) - MEM_freeN(str); + MEM_freeN((void *)str); return but; } -uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip) +static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, int opcontext, const char *str, short x1, short y1, short x2, short y2, const char *tip) { uiBut *but; wmOperatorType *ot; @@ -2640,7 +2650,7 @@ uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext return but; } -uiBut *ui_def_but_operator_text(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) +static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but; wmOperatorType *ot; @@ -2669,7 +2679,7 @@ uiBut *ui_def_but_operator_text(uiBlock *block, int type, char *opname, int opco return but; } -uiBut *uiDefBut(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) { uiBut *but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); @@ -2819,7 +2829,7 @@ uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, sh { return uiDefButBit(block, type|CHA, bit, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, short x1, short y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip) { uiBut *but; @@ -2829,7 +2839,7 @@ uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, shor return but; } -uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip) +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip) { uiBut *but; @@ -2840,7 +2850,7 @@ uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *st return but; } -uiBut *uiDefButTextO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) { uiBut *but= ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); @@ -2919,7 +2929,7 @@ uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, s return but; } -uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip) +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip) { uiBut *but; @@ -2934,7 +2944,7 @@ uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int } /* Button containing both string label and icon */ -uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) { uiBut *but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); @@ -2947,7 +2957,7 @@ uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, char *st return but; } -static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) +static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip) { int bitIdx= findBitIndex(bit); if (bitIdx==-1) { @@ -2957,39 +2967,39 @@ static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, } } -uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextBut(block, type|FLO, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextButBit(block, type|FLO, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextBut(block, type|INT, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextButBit(block, type|INT, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextBut(block, type|SHO, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextButBit(block, type|SHO, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextBut(block, type|CHA, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip) { return uiDefIconTextButBit(block, type|CHA, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip); } -uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip) +uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, short x1, short y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip) { uiBut *but; @@ -3005,7 +3015,7 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *s return but; } -uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip) +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, short x1, short y1, short x2, short y2, char *tip) { uiBut *but; diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 2a30a36ffe0..4021e4208dc 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -105,10 +105,11 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) // TODO: this should probably respect the keyingset only option for anim if(autokeyframe_cfra_can_key(scene, id)) { + ReportList *reports = CTX_wm_reports(C); short flag = ANIM_get_keyframing_flags(scene, 1); fcu->flag &= ~FCURVE_SELECTED; - insert_keyframe(id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b6db799a443..9216e3f2a83 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -324,7 +324,7 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but) { Scene *scene= CTX_data_scene(C); uiAfterFunc *after; - char *str= NULL; + const char *str= NULL; if(but->flag & UI_BUT_UNDO) { /* define which string to use for undo */ @@ -4090,7 +4090,7 @@ static int ui_but_menu(bContext *C, uiBut *but) uiPopupMenu *pup; uiLayout *layout; int length; - char *name; + const char *name; if((but->rnapoin.data && but->rnaprop)==0 && but->optype==NULL) return 0; @@ -4960,15 +4960,14 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P if(activebut) { if(activebut->rnapoin.data) { + uiHandleButtonData *data= activebut->active; + /* found RNA button */ *ptr= activebut->rnapoin; *prop= activebut->rnaprop; *index= activebut->rnaindex; - return; - } - else { - /* recurse into opened menu */ - uiHandleButtonData *data= activebut->active; + + /* recurse into opened menu, like colorpicker case */ if(data && data->menu) ar = data->menu->region; else @@ -5006,18 +5005,12 @@ void uiContextAnimUpdate(const bContext *C) } if(activebut) { - if(activebut->rnapoin.data) { - /* found RNA button */ + /* always recurse into opened menu, so all buttons update (like colorpicker) */ + uiHandleButtonData *data= activebut->active; + if(data && data->menu) + ar = data->menu->region; + else return; - } - else { - /* recurse into opened menu */ - uiHandleButtonData *data= activebut->active; - if(data && data->menu) - ar = data->menu->region; - else - return; - } } else { /* no active button */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 0ade3e6199f..e39e594af66 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -682,7 +682,7 @@ static void free_iconfile_list(struct ListBase *list) } } -int UI_iconfile_get_index(char *filename) +int UI_iconfile_get_index(const char *filename) { IconFile *ifile; ListBase *list=&(iconfilelist); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 7a0f69fc838..001bd4b9157 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -204,7 +204,7 @@ struct uiBut { uiLink *link; short linkto[2]; - char *tip, *lockstr; + const char *tip, *lockstr; BIFIconID icon; char lock; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f729124e405..4e669746c2f 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -152,7 +152,7 @@ typedef struct uiLayoutItemRoot { /************************** Item ***************************/ -static char *ui_item_name_add_colon(char *name, char namestr[UI_MAX_NAME_STR]) +static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_NAME_STR]) { int len= strlen(name); @@ -205,7 +205,7 @@ static int ui_layout_vary_direction(uiLayout *layout) } /* estimated size of text + icon */ -static int ui_text_icon_width(uiLayout *layout, char *name, int icon, int compact) +static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, int compact) { int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X; @@ -326,7 +326,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) } /* create buttons for an item with an RNA array */ -static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider, int toggle, int icon_only) +static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider, int toggle, int icon_only) { uiStyle *style= layout->root->style; uiBut *but; @@ -434,7 +434,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon uiBlockSetCurLayout(block, layout); } -static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int h, int icon_only) +static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, const char *uiname, int h, int icon_only) { uiBut *but; EnumPropertyItem *item; @@ -483,7 +483,7 @@ static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_ } /* create label + button for RNA property */ -static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag) +static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag) { uiLayout *sub; uiBut *but=NULL; @@ -569,7 +569,7 @@ void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA /********************* Button Items *************************/ /* disabled item */ -static void ui_item_disabled(uiLayout *layout, char *name) +static void ui_item_disabled(uiLayout *layout, const char *name) { uiBlock *block= layout->root->block; uiBut *but; @@ -589,7 +589,7 @@ static void ui_item_disabled(uiLayout *layout, char *name) } /* operator items */ -PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, IDProperty *properties, int context, int flag) +PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, IDProperty *properties, int context, int flag) { uiBlock *block= layout->root->block; wmOperatorType *ot= WM_operatortype_find(idname, 0); @@ -646,7 +646,7 @@ PointerRNA uiItemFullO(uiLayout *layout, char *idname, char *name, int icon, IDP return PointerRNA_NULL; } -static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname, int retval) +static char *ui_menu_enumpropname(uiLayout *layout, const char *opname, const char *propname, int retval) { wmOperatorType *ot= WM_operatortype_find(opname, 0); PointerRNA ptr; @@ -676,7 +676,7 @@ static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname return ""; } -void uiItemEnumO(uiLayout *layout, char *opname, char *name, int icon, char *propname, int value) +void uiItemEnumO(uiLayout *layout, const char *opname, char *name, int icon, const char *propname, int value) { PointerRNA ptr; @@ -689,7 +689,7 @@ void uiItemEnumO(uiLayout *layout, char *opname, char *name, int icon, char *pro uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } -void uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, IDProperty *properties, int context, int flag) +void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, IDProperty *properties, int context, int flag) { wmOperatorType *ot= WM_operatortype_find(opname, 0); PointerRNA ptr; @@ -753,13 +753,13 @@ void uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, IDProperty } } -void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) +void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) { uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0); } /* for use in cases where we have */ -void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value_str) +void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, char *value_str) { PointerRNA ptr; @@ -796,7 +796,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } -void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value) +void uiItemBooleanO(uiLayout *layout, char *name, int icon, const char *opname, const char *propname, int value) { PointerRNA ptr; @@ -806,7 +806,7 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char * uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } -void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value) +void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { PointerRNA ptr; @@ -816,7 +816,7 @@ void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *prop uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } -void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value) +void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value) { PointerRNA ptr; @@ -826,7 +826,7 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } -void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value) +void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, char *value) { PointerRNA ptr; @@ -836,14 +836,14 @@ void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *p uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } -void uiItemO(uiLayout *layout, char *name, int icon, char *opname) +void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname) { uiItemFullO(layout, opname, name, icon, NULL, layout->root->opcontext, 0); } /* RNA property items */ -static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int icon_only, int *r_w, int *r_h) +static void ui_item_rna_size(uiLayout *layout, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int icon_only, int *r_w, int *r_h) { PropertyType type; PropertySubType subtype; @@ -887,7 +887,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *r_h= h; } -void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, char *name, int icon) +void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon) { uiBlock *block= layout->root->block; uiBut *but; @@ -977,7 +977,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index uiBlockSetEmboss(block, UI_EMBOSS); } -void uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, int flag, char *name, int icon) +void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, const char *name, int icon) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); @@ -990,7 +990,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, int flag, char * uiItemFullR(layout, ptr, prop, RNA_NO_INDEX, 0, flag, name, icon); } -void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value) +void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); @@ -1003,7 +1003,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, value, 0, name, icon); } -void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *value, char *name, int icon) +void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); EnumPropertyItem *item; @@ -1035,7 +1035,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, char *propname MEM_freeN(item); } -void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) +void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname) { PropertyRNA *prop; uiBlock *block= layout->root->block; @@ -1102,7 +1102,7 @@ int sort_search_items_list(void *a, void *b) return 0; } -static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, uiSearchItems *items) +static void rna_search_cb(const struct bContext *C, void *arg_but, const char *str, uiSearchItems *items) { uiBut *but= arg_but; char *name; @@ -1220,7 +1220,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN } } -void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname, char *name, int icon) +void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) { PropertyRNA *prop, *searchprop; PropertyType type; @@ -1282,7 +1282,7 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt) mt->draw(C, &menu); } -static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN) +static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN) { uiBlock *block= layout->root->block; uiBut *but; @@ -1324,7 +1324,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun } } -void uiItemM(uiLayout *layout, bContext *UNUSED(C), char *menuname, char *name, int icon) +void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const char *name, int icon) { MenuType *mt; @@ -1344,7 +1344,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), char *menuname, char *name, } /* label item */ -static uiBut *uiItemL_(uiLayout *layout, char *name, int icon) +static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) { uiBlock *block= layout->root->block; uiBut *but; @@ -1360,16 +1360,16 @@ static uiBut *uiItemL_(uiLayout *layout, char *name, int icon) w= ui_text_icon_width(layout, name, icon, 0); if(icon && strcmp(name, "") != 0) - but= uiDefIconTextBut(block, LABEL, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + but= uiDefIconTextBut(block, LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); else if(icon) but= uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); else - but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + but= uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); return but; } -void uiItemL(uiLayout *layout, char *name, int icon) +void uiItemL(uiLayout *layout, const char *name, int icon) { uiItemL_(layout, name, icon); } @@ -1419,7 +1419,7 @@ void uiItemS(uiLayout *layout) } /* level items */ -void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg) +void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg) { if(!func) return; @@ -1429,8 +1429,8 @@ void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, typedef struct MenuItemLevel { int opcontext; - char *opname; - char *propname; + const char *opname; + const char *propname; PointerRNA rnapoin; } MenuItemLevel; @@ -1442,7 +1442,7 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo uiItemsEnumO(layout, lvl->opname, lvl->propname); } -void uiItemMenuEnumO(uiLayout *layout, char *opname, char *propname, char *name, int icon) +void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon) { wmOperatorType *ot= WM_operatortype_find(opname, 0); MenuItemLevel *lvl; @@ -1473,7 +1473,7 @@ static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void uiItemsEnumR(layout, &lvl->rnapoin, lvl->propname); } -void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *name, int icon) +void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon) { MenuItemLevel *lvl; PropertyRNA *prop; @@ -2553,7 +2553,7 @@ void uiBlockLayoutResolve(uiBlock *block, int *x, int *y) } } -void uiLayoutSetContextPointer(uiLayout *layout, char *name, PointerRNA *ptr) +void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *ptr) { uiBlock *block= layout->root->block; layout->context= CTX_store_add(&block->contexts, name, ptr); @@ -2631,7 +2631,7 @@ static void ui_intro_uiLayout(DynStr *ds, uiLayout *layout) } static char *str = NULL; // XXX, constant re-freeing, far from ideal. -char *uiLayoutIntrospect(uiLayout *layout) +const char *uiLayoutIntrospect(uiLayout *layout) { DynStr *ds= BLI_dynstr_new(); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 10458a763e6..1c2b0f9e7f3 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -34,11 +34,15 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_text_types.h" /* for UI_OT_reports_to_text */ #include "BLI_blenlib.h" #include "BLI_math_color.h" #include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_text.h" /* for UI_OT_reports_to_text */ +#include "BKE_report.h" #include "RNA_access.h" #include "RNA_define.h" @@ -402,7 +406,51 @@ void UI_OT_copy_to_selected_button(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array."); } - + +/* Reports to Textblock Operator ------------------------ */ + +/* FIXME: this is just a temporary operator so that we can see all the reports somewhere + * when there are too many to display... + */ + +static int reports_to_text_poll(bContext *C) +{ + return CTX_wm_reports(C) != NULL; +} + +static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ReportList *reports = CTX_wm_reports(C); + Text *txt; + char *str; + + /* create new text-block to write to */ + txt = add_empty_text("Recent Reports"); + + /* convert entire list to a display string, and add this to the text-block + * - if commandline debug option enabled, show debug reports too + * - otherwise, up to info (which is what users normally see) + */ + str = BKE_reports_string(reports, (G.f & G_DEBUG)? RPT_DEBUG : RPT_INFO); + + write_text(txt, str); + MEM_freeN(str); + + return OPERATOR_FINISHED; +} + +void UI_OT_reports_to_textblock(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Reports to Text Block"; + ot->idname= "UI_OT_reports_to_textblock"; + ot->description= "Write the reports "; + + /* callbacks */ + ot->poll= reports_to_text_poll; + ot->exec= reports_to_text_exec; +} + /* ********************************************************* */ /* Registration */ @@ -413,5 +461,6 @@ void UI_buttons_operatortypes(void) WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_reset_default_button); WM_operatortype_append(UI_OT_copy_to_selected_button); + WM_operatortype_append(UI_OT_reports_to_textblock); // XXX: temp? } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index e244565a6a6..d67d63423f2 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -403,9 +403,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } /* rna info */ - BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s.%s", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop)); - data->color[data->totline]= 0x888888; - data->totline++; + if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s.%s", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop)); + data->color[data->totline]= 0x888888; + data->totline++; + } if(but->rnapoin.id.data) { ID *id= but->rnapoin.id.data; @@ -424,9 +426,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) str= WM_operator_pystring(C, but->optype, opptr, 0); /* operator info */ - BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str); - data->color[data->totline]= 0x888888; - data->totline++; + if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str); + data->color[data->totline]= 0x888888; + data->totline++; + } MEM_freeN(str); @@ -2246,7 +2250,7 @@ static void confirm_cancel_operator(void *opv) WM_operator_free(opv); } -static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap) +static void vconfirm_opname(bContext *C, const char *opname, char *title, char *itemfmt, va_list ap) { uiPopupBlockHandle *handle; char *s, buf[512]; @@ -2258,7 +2262,7 @@ static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfm handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf); handle->popup_func= operator_name_cb; - handle->popup_arg= opname; + handle->popup_arg= (void *)opname; } static void confirm_operator(bContext *C, wmOperator *op, char *title, char *item) @@ -2276,7 +2280,7 @@ static void confirm_operator(bContext *C, wmOperator *op, char *title, char *ite handle->cancel_func= confirm_cancel_operator; } -void uiPupMenuOkee(bContext *C, char *opname, char *str, ...) +void uiPupMenuOkee(bContext *C, const char *opname, char *str, ...) { va_list ap; char titlestr[256]; @@ -2391,7 +2395,7 @@ void uiPupMenuInvoke(bContext *C, const char *idname) /*************************** Popup Block API **************************/ -void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext) +void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext) { wmWindow *window= CTX_wm_window(C); uiPopupBlockHandle *handle; diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 719be6c3463..43f11ae421e 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -230,7 +230,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str) /* ************** helpers ************************ */ /* temporarily, does widget font */ -int UI_GetStringWidth(char *str) +int UI_GetStringWidth(const char *str) { uiStyle *style= U.uistyles.first; uiFontStyle *fstyle= &style->widget; @@ -249,7 +249,7 @@ int UI_GetStringWidth(char *str) } /* temporarily, does widget font */ -void UI_DrawString(float x, float y, char *str) +void UI_DrawString(float x, float y, const char *str) { uiStyle *style= U.uistyles.first; @@ -314,6 +314,20 @@ void uiStyleInit(void) if(style==NULL) { ui_style_new(&U.uistyles, "Default Style"); } + + // XXX, this should be moved into a style, but for now best only load the monospaced font once. + if (blf_mono_font == -1) + blf_mono_font= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + + BLF_aspect(blf_mono_font, 1.0); + BLF_size(blf_mono_font, 12, 72); + + /* second for rendering else we get threading problems */ + if (blf_mono_font_render == -1) + blf_mono_font_render= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + + BLF_aspect(blf_mono_font_render, 1.0); + BLF_size(blf_mono_font_render, 12, 72); } void uiStyleFontSet(uiFontStyle *fs) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 856164990e8..a9fccdddd04 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -38,6 +38,7 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_material.h" #include "BKE_texture.h" #include "BKE_report.h" @@ -95,7 +96,7 @@ static void id_search_call_cb(bContext *C, void *arg_template, void *item) } /* ID Search browse menu, do the search */ -static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSearchItems *items) +static void id_search_cb(const bContext *C, void *arg_template, const char *str, uiSearchItems *items) { TemplateID *template= (TemplateID*)arg_template; ListBase *lb= template->idlb; @@ -287,7 +288,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } } -static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, char *newop, char *openop, char *unlinkop) +static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, const char *newop, const char *openop, const char *unlinkop) { uiBut *but; uiBlock *block; @@ -435,7 +436,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiBlockEndAlign(block); } -static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int flag, int prv_rows, int prv_cols) +static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols) { TemplateID *template; PropertyRNA *prop; @@ -473,17 +474,17 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, char MEM_freeN(template); } -void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) +void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop) { ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0); } -void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop) +void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop) { ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0); } -void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols) +void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols) { ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols); } @@ -495,7 +496,7 @@ void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, char *p * - propname: property identifier for property that ID-pointer gets stored to * - proptypename: property identifier for property used to determine the type of ID-pointer that can be used */ -void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, char *propname, char *proptypename, char *text) +void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename, const char *text) { PropertyRNA *propID, *propType; uiLayout *row; @@ -540,7 +541,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, char *propname, char *pr * - propname: property identifier for property that path gets stored to * - root_ptr: struct that path gets built from */ -void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, char *propname, PointerRNA *UNUSED(root_ptr), char *text) +void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *UNUSED(root_ptr), const char *text) { PropertyRNA *propPath; uiLayout *row; @@ -1054,7 +1055,7 @@ static void do_preview_buttons(bContext *C, void *arg, int event) } } -void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) +void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, MTex *slot) { uiLayout *row, *col; uiBlock *block; @@ -1102,7 +1103,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) uiBlockSetHandleFunc(block, do_preview_buttons, NULL); /* add buttons */ - if(pid) { + if (pid && show_buttons) { if(GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { if(GS(pid->name) == ID_MA) ma= (Material*)pid; else ma= (Material*)pparent; @@ -1293,7 +1294,7 @@ static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand colorband_buttons_large(layout, block, coba, 0, 0, cb); } -void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, char *propname, int expand) +void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); PointerRNA cptr; @@ -1323,7 +1324,7 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, char *propname, int /********************* Histogram Template ************************/ -void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, char *propname) +void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); PointerRNA cptr; @@ -1362,7 +1363,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, char *propname) /********************* Waveform Template ************************/ -void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, char *propname) +void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); PointerRNA cptr; @@ -1398,7 +1399,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, char *propname) /********************* Vectorscope Template ************************/ -void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, char *propname) +void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propname) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); PointerRNA cptr; @@ -1762,7 +1763,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiBlockSetNFunc(block, NULL, NULL, NULL); } -void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, char *propname, int type, int levels, int brush) +void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, int levels, int brush) { RNAUpdateCb *cb; PropertyRNA *prop= RNA_struct_find_property(ptr, propname); @@ -1788,7 +1789,7 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, char *propname, i #define WHEEL_SIZE 100 -void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, char *propname, int value_slider, int lock, int lock_luminosity, int cubic) +void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); uiBlock *block= uiLayoutGetBlock(layout); @@ -1853,8 +1854,8 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) // - for now, grouping of layers is determined by dividing up the length of // the array of layer bitflags -void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname, - PointerRNA *used_ptr, char *used_propname, int active_layer) +void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, + PointerRNA *used_ptr, const char *used_propname, int active_layer) { uiLayout *uRow, *uCol; PropertyRNA *prop, *used_prop= NULL; @@ -1956,7 +1957,7 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon) return rnaicon; } -static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, char *activepropname) +static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, const char *activepropname) { Object *ob; uiBlock *block= uiLayoutGetBlock(layout); @@ -2000,6 +2001,28 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiBlockSetEmboss(block, UI_EMBOSS); uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "use", 0, 0, 0, 0, 0, NULL); } + else if(RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) { + /* provision to draw active node name */ + Material *ma, *manode; + Object *ob= (Object*)ptr->id.data; + int index= (Material**)ptr->data - ob->mat; + + /* default item with material base name */ + uiItemL(sub, name, icon); + + ma= give_current_material(ob, index+1); + if(ma) { + manode= give_node_material(ma); + if(manode) { + char str[MAX_ID_NAME + 12]; + sprintf(str, "Node %s", manode->id.name+2); + uiItemL(sub, str, ui_id_icon_get(C, &manode->id, 1)); + } + else if(ma->use_nodes) { + uiItemL(sub, "Node <none>", 0); + } + } + } else if(itemptr->type == &RNA_ShapeKey) { ob= (Object*)activeptr->data; @@ -2025,7 +2048,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe MEM_freeN(namebuf); } -void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, PointerRNA *activeptr, char *activepropname, int rows, int maxrows, int listtype) +void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, int rows, int maxrows, int listtype) { //Scene *scene= CTX_data_scene(C); PropertyRNA *prop= NULL, *activeprop; @@ -2212,7 +2235,7 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2) WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); } -static void operator_search_cb(const bContext *C, void *UNUSED(arg), char *str, uiSearchItems *items) +static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); @@ -2331,6 +2354,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) uiBut *but; uiStyle *style= U.uistyles.first; int width; + int icon=0; /* if the report display has timed out, don't show */ if (!reports->reporttimer) return; @@ -2364,13 +2388,24 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) /* icon and report message on top */ if(report->type & RPT_ERROR_ALL) - uiDefIconBut(block, LABEL, 0, ICON_ERROR, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + icon = ICON_ERROR; else if(report->type & RPT_WARNING_ALL) - uiDefIconBut(block, LABEL, 0, ICON_ERROR, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + icon = ICON_ERROR; else if(report->type & RPT_INFO_ALL) - uiDefIconBut(block, LABEL, 0, ICON_INFO, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + icon = ICON_INFO; - uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + /* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report + * to be shown instead of icon when appropriate... + */ + uiBlockSetEmboss(block, UI_EMBOSSN); + + if (reports->list.first != reports->list.last) + uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, "Click to see rest of reports in textblock: 'Recent Reports'"); + else + uiDefIconBut(block, LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); + uiBlockSetEmboss(block, UI_EMBOSS); + + uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); } diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 1e26f273b41..41685b7e8bb 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -45,8 +45,4 @@ SET(SRC meshtools.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_mesh "${SRC}" "${INC}") diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index f8135e47d20..424b3c5467f 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1853,7 +1853,7 @@ static void *getEditMesh(bContext *C) } /* and this is all the undo system needs to know */ -void undo_push_mesh(bContext *C, char *name) +void undo_push_mesh(bContext *C, const char *name) { undo_editmode_push(C, name, getEditMesh, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh, NULL); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index eb450c7434b..2a04859f462 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -5841,6 +5841,7 @@ static int merge_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); int count= 0, uvs= RNA_boolean_get(op->ptr, "uvs"); + EditSelection *ese; switch(RNA_enum_get(op->ptr, "type")) { case 3: @@ -5850,10 +5851,21 @@ static int merge_exec(bContext *C, wmOperator *op) count = merge_target(C, em, 1, uvs); break; case 1: - count = merge_firstlast(em, 0, uvs); + ese= (EditSelection *)em->selected.last; + if(ese && ese->type == EDITVERT) { + count = merge_firstlast(em, 0, uvs); + } else { + BKE_report(op->reports, RPT_ERROR, "no last selected vertex set"); + } break; case 6: - count = merge_firstlast(em, 1, uvs); + ese= (EditSelection *)em->selected.first; + if(ese && ese->type == EDITVERT) { + count = merge_firstlast(em, 1, uvs); + } + else { + BKE_report(op->reports, RPT_ERROR, "no last selected vertex set"); + } break; case 5: count = collapseEdges(em); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index ec727d7d82b..3d534aaa4a2 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -623,7 +623,7 @@ static void *get_data(bContext *C) } /* this is undo system for MetaBalls */ -void undo_push_mball(bContext *C, char *name) +void undo_push_mball(bContext *C, const char *name) { undo_editmode_push(C, name, get_data, free_undoMball, undoMball_to_editMball, editMball_to_undoMball, NULL); } diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 224d72895ba..01b49a9e80b 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -51,10 +51,6 @@ SET(SRC object_vgroup.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 88072d7d045..198b68bce40 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -105,15 +105,16 @@ void ED_object_location_from_view(bContext *C, float *loc) void ED_object_rotation_from_view(bContext *C, float *rot) { - RegionView3D *rv3d= ED_view3d_context_rv3d(C); - + RegionView3D *rv3d= CTX_wm_region_view3d(C); if(rv3d) { - rv3d->viewquat[0]= -rv3d->viewquat[0]; - quat_to_eul( rot, rv3d->viewquat); - rv3d->viewquat[0]= -rv3d->viewquat[0]; + float quat[4]; + copy_qt_qt(quat, rv3d->viewquat); + quat[0]= -quat[0]; + quat_to_eul(rot, quat); + } + else { + zero_v3(rot); } - else - rot[0] = rot[1] = rot[2] = 0.f; } void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *rot) @@ -256,9 +257,11 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa view_align = FALSE; else if (RNA_property_is_set(op->ptr, "view_align")) view_align = RNA_boolean_get(op->ptr, "view_align"); - else + else { view_align = U.flag & USER_ADD_VIEWALIGNED; - + RNA_boolean_set(op->ptr, "view_align", view_align); + } + if (view_align) ED_object_rotation_from_view(C, rot); else @@ -276,6 +279,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa } /* for object add primitive operators */ +/* do not call undo push in this function (users of this function have to) */ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer) { Main *bmain= CTX_data_main(C); @@ -483,16 +487,6 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) /* ***************** add primitives *************** */ - -static EnumPropertyItem prop_metaball_types[]= { - {MB_BALL, "MBALL_BALL", ICON_META_BALL, "Meta Ball", ""}, - {MB_TUBE, "MBALL_CAPSULE", ICON_META_CAPSULE, "Meta Capsule", ""}, - {MB_PLANE, "MBALL_PLANE", ICON_META_PLANE, "Meta Plane", ""}, - {MB_CUBE, "MBALL_CUBE", ICON_META_CUBE, "Meta Cube", ""}, - {MB_ELIPSOID, "MBALL_ELLIPSOID", ICON_META_ELLIPSOID, "Meta Ellipsoid", ""}, - {0, NULL, 0, NULL, NULL} -}; - static int object_metaball_add_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); @@ -562,7 +556,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_metaball_types, 0, "Primitive", ""); + RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", ""); ED_object_add_generic_props(ot, TRUE); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 118c649adde..d9e0140c699 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -511,7 +511,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) if(!CTX_data_edit_object(C)) ED_object_enter_editmode(C, EM_WAITCURSOR); else - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 708aa38d3ea..5c68917a83a 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -414,7 +414,7 @@ static void *get_editlatt(bContext *C) } /* and this is all the undo system needs to know */ -void undo_push_lattice(bContext *C, char *name) +void undo_push_lattice(bContext *C, const char *name) { undo_editmode_push(C, name, get_editlatt, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt, validate_undoLatt); } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index a9759c8c838..6c7b57a0b69 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -76,7 +76,7 @@ /******************************** API ****************************/ -ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, char *name, int type) +ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type) { ModifierData *md=NULL, *new_md=NULL; ModifierTypeInfo *mti = modifierType_getInfo(type); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index b8edbb8c104..f3d4bea576f 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -357,7 +357,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) /* Generic itemf's for operators that take library args */ static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { - EnumPropertyItem *item= NULL, item_tmp; + EnumPropertyItem item_tmp= {0}, *item= NULL; int totitem= 0; int i= 0; Object *ob= ED_object_active_context(C); @@ -366,8 +366,6 @@ static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSE if(!ob || !ob->dup_group) return DummyRNA_DEFAULT_items; - memset(&item_tmp, 0, sizeof(item_tmp)); - /* find the object to affect */ for (go= ob->dup_group->gobject.first; go; go= go->next) { item_tmp.identifier= item_tmp.name= go->ob->id.name+2; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index dd4864f928f..693a8e9b0e7 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -79,7 +79,7 @@ static Lattice *vgroup_edit_lattice(Object *ob) return NULL; } -bDeformGroup *ED_vgroup_add_name(Object *ob, char *name) +bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name) { bDeformGroup *defgroup; diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 481f6d8df44..82c48becb0b 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -39,10 +39,6 @@ SET(SRC physics_pointcache.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(NOT WITH_MOD_FLUID) ADD_DEFINITIONS(-DDISABLE_ELBEEM) ENDIF(NOT WITH_MOD_FLUID) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index e654b868622..1fd9e91095f 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include <math.h> #include <string.h> +#include <assert.h> #include "MEM_guardedalloc.h" @@ -369,8 +370,18 @@ static void PE_set_view3d_data(bContext *C, PEData *data) /* note, the object argument means the modelview matrix does not account for the objects matrix, use viewmat rather then (obmat * viewmat) */ view3d_get_transformation(data->vc.ar, data->vc.rv3d, NULL, &data->mats); - if((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) - view3d_validate_backbuf(&data->vc); + if((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) { + if(data->vc.v3d->flag & V3D_INVALID_BACKBUF) { + /* needed or else the draw matrix can be incorrect */ + view3d_operator_needs_opengl(C); + + view3d_validate_backbuf(&data->vc); + /* we may need to force an update here by setting the rv3d as dirty + * for now it seems ok, but take care!: + * rv3d->depths->dirty = 1; */ + view3d_update_depths(data->vc.ar); + } + } } /*************************** selection utilities *******************************/ @@ -397,14 +408,23 @@ static int key_test_depth(PEData *data, float co[3]) x=wco[0]; y=wco[1]; +#if 0 /* works well but too slow on some systems [#23118] */ x+= (short)data->vc.ar->winrct.xmin; y+= (short)data->vc.ar->winrct.ymin; /* PE_set_view3d_data calls this. no need to call here */ /* view3d_validate_backbuf(&data->vc); */ glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); +#else /* faster to use depths, these are calculated in PE_set_view3d_data */ + { + ViewDepths *vd = data->vc.rv3d->depths; + assert(vd && vd->depths); + /* we know its not clipped */ + depth= vd->depths[y * vd->w + x]; + } +#endif - if((float)uz - 0.0001 > depth) + if((float)uz - 0.00001 > depth) return 0; else return 1; @@ -1467,8 +1487,6 @@ static int select_linked_exec(bContext *C, wmOperator *op) mval[0]= location[0]; mval[1]= location[1]; - view3d_operator_needs_opengl(C); - PE_set_view3d_data(C, &data); data.mval= mval; data.rad=75.0f; @@ -1590,12 +1608,17 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s float co[3], mat[4][4]; short vertco[2]; + PEData data; + if(!PE_start_edit(edit)) return OPERATOR_CANCELLED; if (extend == 0 && select) PE_deselect_all_visible(edit); - + + /* only for depths */ + PE_set_view3d_data(C, &data); + unit_m4(mat); LOOP_VISIBLE_POINTS { @@ -1607,7 +1630,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s VECCOPY(co, key->co); mul_m4_v3(mat, co); project_short(ar, co, vertco); - if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1])) { + if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { if(select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; @@ -1625,7 +1648,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s VECCOPY(co, key->co); mul_m4_v3(mat, co); project_short(ar, co,vertco); - if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1])) { + if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { if(select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; @@ -3321,6 +3344,9 @@ typedef struct BrushEdit { int first; int lastmouse[2]; + + /* optional cached view settings to avoid setting on every mousemove */ + PEData data; } BrushEdit; static int brush_edit_init(bContext *C, wmOperator *op) @@ -3345,6 +3371,9 @@ static int brush_edit_init(bContext *C, wmOperator *op) bedit->ob= ob; bedit->edit= edit; + /* cache view depths and settings for re-use */ + PE_set_view3d_data(C, &bedit->data); + return 1; } @@ -3392,6 +3421,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) if(((pset->brushtype == PE_BRUSH_ADD) ? (sqrt(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first) { + PEData data= bedit->data; view3d_operator_needs_opengl(C); selected= (short)count_selected_keys(scene, edit); @@ -3399,9 +3429,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) switch(pset->brushtype) { case PE_BRUSH_COMB: { - PEData data; - - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; @@ -3421,10 +3448,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_CUT: { - PEData data; - if(edit->psys && edit->pathcache) { - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; data.cutfac= brush->strength; @@ -3445,9 +3469,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_LENGTH: { - PEData data; - - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; @@ -3466,10 +3487,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_PUFF: { - PEData data; - if(edit->psys) { - PE_set_view3d_data(C, &data); data.dm= psmd->dm; data.mval= mval; data.rad= (float)brush->size; @@ -3490,10 +3508,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_ADD: { - PEData data; - if(edit->psys && edit->psys->part->from==PART_FROM_FACE) { - PE_set_view3d_data(C, &data); data.mval= mval; added= brush_add(&data, brush->count); @@ -3507,9 +3522,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_SMOOTH: { - PEData data; - - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; @@ -3531,9 +3543,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_WEIGHT: { - PEData data; - PE_set_view3d_data(C, &data); - if(edit->psys) { data.dm= psmd->dm; data.mval= mval; @@ -3810,7 +3819,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) } } -void PE_undo_push(Scene *scene, char *str) +void PE_undo_push(Scene *scene, const char *str) { PTCacheEdit *edit= PE_get_current(scene, OBACT); PTCacheUndo *undo; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 428d8ce6b82..9d4880ea2ed 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -623,7 +623,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) PTCacheEditPoint *point; PTCacheEditKey *ekey = NULL; HairKey *key; - BVHTreeFromMesh bvhtree; + BVHTreeFromMesh bvhtree= {0}; BVHTreeNearest nearest; MFace *mface; DerivedMesh *dm = NULL; @@ -646,8 +646,6 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) numverts = dm->getNumVerts (dm); - memset( &bvhtree, 0, sizeof(bvhtree) ); - /* convert to global coordinates */ for (i=0; i<numverts; i++) mul_m4_v3(ob->obmat, CDDM_get_vert(dm, i)->co); diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index d952d19bc00..f022249b59f 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -53,8 +53,4 @@ IF(WITH_OPENMP) ADD_DEFINITIONS(-DPARALLEL=1) ENDIF(WITH_OPENMP) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_render "${SRC}" "${INC}") diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 94057aa5087..6c52a04eb0b 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -347,6 +347,8 @@ static ScrArea *find_area_showing_r_result(bContext *C) break; } } + if(sa) + break; } return sa; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 6b067a94003..8dd9adf0777 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -257,7 +257,8 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) sizex= (scene->r.size*scene->r.xsch)/100; sizey= (scene->r.size*scene->r.ysch)/100; - ofs= GPU_offscreen_create(sizex, sizey); + /* corrects render size with actual size, some gfx cards return units of 256 or 512 */ + ofs= GPU_offscreen_create(&sizex, &sizey); if(!ofs) { BKE_report(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer."); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 0e8587e4642..f6d1f8d0bb8 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1085,14 +1085,13 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat if(idtype == ID_IM) { Image *ima= (Image*)id; ImBuf *ibuf= NULL; - ImageUser iuser; + ImageUser iuser= {0}; /* ima->ok is zero when Image cannot load */ if(ima==NULL || ima->ok==0) return; /* setup dummy image user */ - memset(&iuser, 0, sizeof(ImageUser)); iuser.ok= iuser.framenr= 1; iuser.scene= sp->scene; diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 4ea056ac400..ff143bab469 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -40,8 +40,4 @@ SET(SRC screendump.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_screen "${SRC}" "${INC}") diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index dcb3762c6f1..c25a912d597 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -427,7 +427,7 @@ void ED_area_tag_refresh(ScrArea *sa) /* *************************************************************** */ /* use NULL to disable it */ -void ED_area_headerprint(ScrArea *sa, char *str) +void ED_area_headerprint(ScrArea *sa, const char *str) { ARegion *ar; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4fac0abb50e..67ca31fbfff 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -364,6 +364,14 @@ int ED_operator_editsurfcurve(bContext *C) return 0; } +int ED_operator_editsurfcurve_region_view3d(bContext *C) +{ + if(ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C)) + return 1; + + CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editcurve"); + return 0; +} int ED_operator_editcurve(bContext *C) { diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 364677f9a8d..6db61cee168 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -43,8 +43,4 @@ SET(SRC sculpt_undo.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_sculpt_paint "${SRC}" "${INC}") diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index c5402a00942..bd4bae23c7d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4526,6 +4526,8 @@ typedef struct PaintOperation { ViewContext vc; wmTimer *timer; + + short restore_projection; } PaintOperation; static void paint_redraw(bContext *C, ImagePaintState *s, int final) @@ -4611,6 +4613,13 @@ static int texture_paint_init(bContext *C, wmOperator *op) pop->first= 1; op->customdata= pop; + /* XXX: Soften tool does not support projection painting atm, so just disable + projection for this brush */ + if(brush->imagepaint_tool == PAINT_TOOL_SOFTEN) { + settings->imapaint.flag |= IMAGEPAINT_PROJECT_DISABLE; + pop->restore_projection = 1; + } + /* initialize from context */ if(CTX_wm_region_view3d(C)) { pop->mode= PAINT_MODE_3D; @@ -4731,6 +4740,9 @@ static void paint_exit(bContext *C, wmOperator *op) if(pop->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), pop->timer); + if(pop->restore_projection) + settings->imapaint.flag &= ~IMAGEPAINT_PROJECT_DISABLE; + settings->imapaint.flag &= ~IMAGEPAINT_DRAWING; imapaint_canvas_free(&pop->s); brush_painter_free(pop->painter); @@ -5400,13 +5412,11 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) { Image *image= BLI_findlink(&CTX_data_main(C)->image, RNA_enum_get(op->ptr, "image")); Scene *scene= CTX_data_scene(C); - ProjPaintState ps; + ProjPaintState ps= {0}; int orig_brush_size; IDProperty *idgroup; IDProperty *view_data= NULL; - memset(&ps, 0, sizeof(ps)); - project_state_init(C, OBACT, &ps); if(ps.ob==NULL || ps.ob->type != OB_MESH) { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 79314ca4113..0d07583c28c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -511,15 +511,16 @@ float calc_overlap(StrokeCache *cache, const char symm, const char axis, const f { float mirror[3]; float distsq; - float mat[4][4]; //flip_coord(mirror, cache->traced_location, symm); flip_coord(mirror, cache->true_location, symm); - unit_m4(mat); - rotate_m4(mat, axis, angle); - - mul_m4_v3(mat, mirror); + if(axis != 0) { + float mat[4][4]; + unit_m4(mat); + rotate_m4(mat, axis, angle); + mul_m4_v3(mat, mirror); + } //distsq = len_squared_v3v3(mirror, cache->traced_location); distsq = len_squared_v3v3(mirror, cache->true_location); diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 32bb02ddcda..4d35b5ca4ff 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -410,6 +410,7 @@ static void insert_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; + ReportList *reports = ac->reports; Scene *scene= ac->scene; float cfra= (float)CFRA; short flag = 0; @@ -437,7 +438,7 @@ static void insert_action_keys(bAnimContext *ac, short mode) /* if there's an id */ if (ale->id) - insert_keyframe(ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); else insert_vert_fcurve(fcu, cfra, fcu->curval, 0); } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 44138119f7a..87c50936f90 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -235,13 +235,8 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) buttons_area_redraw(sa, BCONTEXT_RENDER); break; case ND_FRAME: - buttons_area_redraw(sa, BCONTEXT_RENDER); - buttons_area_redraw(sa, BCONTEXT_OBJECT); - buttons_area_redraw(sa, BCONTEXT_MATERIAL); - buttons_area_redraw(sa, BCONTEXT_TEXTURE); - buttons_area_redraw(sa, BCONTEXT_WORLD); - buttons_area_redraw(sa, BCONTEXT_DATA); - buttons_area_redraw(sa, BCONTEXT_PHYSICS); + /* any buttons area can have animated properties so redraw all */ + ED_area_tag_redraw(sa); sbuts->preview= 1; break; case ND_OB_ACTIVE: diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 5a9c3249abc..6d7eb45f31e 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -154,6 +154,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha int prompt_len= strlen(sc->prompt); int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; const int cursor = ((ConsoleLine *)sc->history.last)->cursor; + xy[1] += tvc->lheight/6; /* cursor */ UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, (char *)fg); diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index a4b402cce43..bc89b7e1850 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -67,8 +67,4 @@ IF(WITH_IMAGE_HDR) ADD_DEFINITIONS(-DWITH_HDR) ENDIF(WITH_IMAGE_HDR) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_space_file "${SRC}" "${INC}") diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 01a8ba4797c..1f92f32cc88 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -899,7 +899,7 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri * - if the option to only show controls if the F-Curve is selected is enabled, we must obey this */ if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) { - if (fcurve_needs_draw_fmodifier_controls(fcu, fcm)) { + if (fcurve_are_keyframes_usable(fcu) == 0) { /* only draw controls if this is the active modifier */ if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) { switch (fcm->type) { diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index e1d1e4194d5..35307a78e65 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -406,6 +406,7 @@ static void insert_graph_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; + ReportList *reports = ac->reports; Scene *scene= ac->scene; float cfra= (float)CFRA; short flag = 0; @@ -432,7 +433,7 @@ static void insert_graph_keys(bAnimContext *ac, short mode) /* if there's an id */ if (ale->id) - insert_keyframe(ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); else insert_vert_fcurve(fcu, cfra, fcu->curval, 0); } @@ -507,19 +508,33 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) } fcu = ale->data; - /* get frame and value from props */ - frame= RNA_float_get(op->ptr, "frame"); - val= RNA_float_get(op->ptr, "value"); - - /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */ - adt= ANIM_nla_mapping_get(&ac, ale); - frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); - - /* apply inverse unit-mapping to value to get correct value for F-Curves */ - val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1); - - /* insert keyframe on the specified frame + value */ - insert_vert_fcurve(fcu, frame, val, 0); + /* when there are F-Modifiers on the curve, only allow adding + * keyframes if these will be visible after doing so... + */ + if (fcurve_is_keyframable(fcu)) { + /* get frame and value from props */ + frame= RNA_float_get(op->ptr, "frame"); + val= RNA_float_get(op->ptr, "value"); + + /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */ + adt= ANIM_nla_mapping_get(&ac, ale); + frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); + + /* apply inverse unit-mapping to value to get correct value for F-Curves */ + val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1); + + /* insert keyframe on the specified frame + value */ + insert_vert_fcurve(fcu, frame, val, 0); + } + else { + /* warn about why this can't happen */ + if (fcu->fpt) + BKE_report(op->reports, RPT_ERROR, "Keyframes cannot be added to sampled F-Curves"); + else if (fcu->flag & FCURVE_PROTECTED) + BKE_report(op->reports, RPT_ERROR, "Active F-Curve is not editable"); + else + BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes"); + } /* free temp data */ MEM_freeN(ale); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index b4ca1b8c901..aa9cff71857 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -350,7 +350,7 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) /* insertkey */ WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_CLICK, KM_CTRL, 0); /* copy/paste */ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index 927149a268d..417d92782cc 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -87,57 +87,6 @@ bAnimListElem *get_active_fcurve_channel (bAnimContext *ac) /* ************************************************************** */ /* Operator Polling Callbacks */ -/* check if any FModifiers to draw controls for - fcm is 'active' modifier - * used for the polling callbacks + also for drawing - */ -// TODO: restructure these tests -// TODO: maybe for now, just allow editing always for now... -short fcurve_needs_draw_fmodifier_controls (FCurve *fcu, FModifier *fcm) -{ - /* don't draw if there aren't any modifiers at all */ - if (fcu->modifiers.first == NULL) - return 0; - - /* if only one modifier - * - don't draw if it is muted or disabled - * - set it as the active one if no active one is present - */ - if (fcu->modifiers.first == fcu->modifiers.last) { - fcm= fcu->modifiers.first; - if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) - return 0; - } - - /* if there's an active modifier - don't draw if it doesn't drastically - * alter the curve... - */ - if (fcm) { - switch (fcm->type) { - /* clearly harmless */ - case FMODIFIER_TYPE_CYCLES: - return 0; - case FMODIFIER_TYPE_STEPPED: - return 0; - - /* borderline... */ - case FMODIFIER_TYPE_NOISE: - return 0; - } - } - - /* if only active modifier - don't draw if it is muted or disabled */ - if (fcm) { - if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) - return 0; - } - - /* if we're still here, this means that there are modifiers with controls to be drawn */ - // FIXME: what happens if all the modifiers were muted/disabled - return 1; -} - -/* ------------------- */ - /* Check if there are any visible keyframes (for selection tools) */ int graphop_visible_keyframes_poll (bContext *C) { @@ -167,7 +116,6 @@ int graphop_visible_keyframes_poll (bContext *C) for (ale = anim_data.first; ale; ale= ale->next) { FCurve *fcu= (FCurve *)ale->data; - FModifier *fcm; /* visible curves for selection must fulfull the following criteria: * - it has bezier keyframes @@ -176,10 +124,10 @@ int graphop_visible_keyframes_poll (bContext *C) */ if (fcu->bezt == NULL) continue; - fcm= find_active_fmodifier(&fcu->modifiers); - - found= (fcurve_needs_draw_fmodifier_controls(fcu, fcm) == 0); - if (found) break; + if (fcurve_are_keyframes_usable(fcu)) { + found = 1; + break; + } } /* cleanup and return findings */ @@ -216,7 +164,6 @@ int graphop_editable_keyframes_poll (bContext *C) for (ale = anim_data.first; ale; ale= ale->next) { FCurve *fcu= (FCurve *)ale->data; - FModifier *fcm; /* editable curves must fulfull the following criteria: * - it has bezier keyframes @@ -226,10 +173,10 @@ int graphop_editable_keyframes_poll (bContext *C) */ if (fcu->bezt == NULL) continue; - fcm= find_active_fmodifier(&fcu->modifiers); - - found= (fcurve_needs_draw_fmodifier_controls(fcu, fcm) == 0); - if (found) break; + if (fcurve_is_keyframable(fcu)) { + found = 1; + break; + } } /* cleanup and return findings */ diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index c2166164b0a..d7415fb7067 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -40,6 +40,10 @@ SET(SRC space_image.c ) +IF(WITH_IMAGE_OPENJPEG) + ADD_DEFINITIONS(-DWITH_OPENJPEG) +ENDIF(WITH_IMAGE_OPENJPEG) + IF(WITH_IMAGE_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_IMAGE_OPENEXR) @@ -57,8 +61,4 @@ IF(WITH_LCMS) ADD_DEFINITIONS(-DWITH_LCMS) ENDIF(WITH_LCMS) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_space_image "${SRC}" "${INC}") diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index 15a7aeb828f..295e03caf32 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -14,11 +14,13 @@ if env['WITH_BF_LCMS']: incs += ' ' + env['BF_LCMS_INC'] if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_OPENJPEG']: + defs.append('WITH_OPENJPEG') if env['WITH_BF_TIFF']: defs.append('WITH_TIFF') if env['WITH_BF_CINEON']: defs.append('WITH_CINEON') - + if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index e245dfba275..cac56d76831 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -761,7 +761,7 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) RNA_property_update(C, &cb->ptr, cb->prop); } -void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, PointerRNA *userptr, int compact) +void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact) { PropertyRNA *prop; PointerRNA imaptr; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ea6579f3429..21db6372028 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1301,6 +1301,18 @@ static int new_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* XXX is temp, redo is not possible in editmode due to undo conflicts */ +static int space_image_no_editmode_poll(bContext *C) +{ + SpaceImage *sima= CTX_wm_space_image(C); + Object *ob= CTX_data_edit_object(C); + + if(sima && ob) + return 0; + + return 1; +} + void IMAGE_OT_new(wmOperatorType *ot) { PropertyRNA *prop; @@ -1313,7 +1325,8 @@ void IMAGE_OT_new(wmOperatorType *ot) /* api callbacks */ ot->exec= new_exec; ot->invoke= WM_operator_props_popup; - + ot->poll= space_image_no_editmode_poll; + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 3ed4f07d150..7eb7cc55bc1 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -269,7 +269,7 @@ static int find_missing_files_exec(bContext *UNUSED(C), wmOperator *op) char *path; path= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); - findMissingFiles(path, G.main->name); + findMissingFiles(G.main->name, path); MEM_freeN(path); return OPERATOR_FINISHED; @@ -312,7 +312,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) #define INFO_COLOR_TIMEOUT 3.0 #define ERROR_TIMEOUT 10.0 #define ERROR_COLOR_TIMEOUT 6.0 -#define COLLAPSE_TIMEOUT 0.2 +#define COLLAPSE_TIMEOUT 0.25 static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { wmWindowManager *wm= CTX_wm_manager(C); @@ -323,11 +323,12 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm float neutral_col[3] = {0.35, 0.35, 0.35}; float neutral_grey= 0.6; float timeout=0.0, color_timeout=0.0; + int send_note= 0; /* escape if not our timer */ if(reports->reporttimer==NULL || reports->reporttimer != event->customdata) return OPERATOR_PASS_THROUGH; - + report= BKE_reports_last_displayable(reports); rti = (ReportTimerInfo *)reports->reporttimer->customdata; @@ -366,17 +367,25 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm progress = reports->reporttimer->duration / timeout; color_progress = reports->reporttimer->duration / color_timeout; - /* fade colours out sharply according to progress through fade-out duration */ - interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress); - rti->greyscale = interpf(neutral_grey, rti->greyscale, color_progress); + /* save us from too many draws */ + if(color_progress <= 1.0f) { + send_note= 1; + + /* fade colours out sharply according to progress through fade-out duration */ + interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress); + rti->greyscale = interpf(neutral_grey, rti->greyscale, color_progress); + } /* collapse report at end of timeout */ if (progress*timeout > timeout - COLLAPSE_TIMEOUT) { rti->widthfac = (progress*timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT; rti->widthfac = 1.0 - rti->widthfac; + send_note= 1; } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); + if(send_note) { + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); + } return (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH); } diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 5f2ed46789e..0cdace3039c 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -39,18 +39,10 @@ #include "textview.h" - -static int mono= -1; // XXX needs proper storage and change all the BLF_* here! - - static void console_font_begin(TextViewContext *sc) { - if(mono == -1) { - mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - } - - BLF_aspect(mono, 1.0); - BLF_size(mono, sc->lheight-2, 72); + BLF_aspect(blf_mono_font, 1.0); + BLF_size(blf_mono_font, sc->lheight-2, 72); } typedef struct ConsoleDrawContext { @@ -95,6 +87,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str int rct_ofs= cdc->lheight/4; int tot_lines = (str_len/cdc->console_width)+1; /* total number of lines for wrapping */ int y_next = (str_len > cdc->console_width) ? cdc->xy[1]+cdc->lheight*tot_lines : cdc->xy[1]+cdc->lheight; + const int mono= blf_mono_font; /* just advance the height */ if(cdc->draw==0) { @@ -224,10 +217,11 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick { ConsoleDrawContext cdc= {0}; - int x_orig=CONSOLE_DRAW_MARGIN, y_orig=CONSOLE_DRAW_MARGIN; + int x_orig=CONSOLE_DRAW_MARGIN, y_orig=CONSOLE_DRAW_MARGIN + tvc->lheight/6; int xy[2], y_prev; int sel[2]= {-1, -1}; /* defaults disabled */ unsigned char fg[3], bg[3]; + const int mono= blf_mono_font; console_font_begin(tvc); @@ -244,6 +238,7 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick assert(cdc.cwidth > 0); cdc.lheight= tvc->lheight; cdc.console_width= (tvc->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN*2) ) / cdc.cwidth; + CLAMP(cdc.console_width, 1, INT_MAX); /* avoid divide by zero on small windows */ cdc.winx= tvc->winx-(CONSOLE_DRAW_MARGIN+CONSOLE_DRAW_SCROLL); cdc.ymin= tvc->ymin; cdc.ymax= tvc->ymax; diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 887d79f8fb3..aa98bfc9c0b 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -45,8 +45,4 @@ SET(SRC space_node.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - BLENDERLIB(bf_editor_space_node "${SRC}" "${INC}") diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index a19a498d88b..1b926b51dd3 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -5302,7 +5302,7 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); } -static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), char *str, uiSearchItems *items) +static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index b9ece0add2f..4e65c216cd3 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -90,6 +90,7 @@ static int script_reload_exec(bContext *C, wmOperator *UNUSED(op)) WM_cursor_wait(1); BPY_eval_string(C, "__import__('bpy').utils.load_scripts(reload_scripts=True)"); WM_cursor_wait(0); + WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; #else (void)C; /* unused */ diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index bbd18e7c1ee..6b4ae406b2b 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -693,6 +693,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq float proxy_size = 100.0; GLuint texid; GLuint last_texid; + SeqRenderData context; render_size = sseq->render_size; if (render_size == 0) { @@ -732,12 +733,14 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq if(G.rendering) return; + context = seq_new_render_data(bmain, scene, rectx, recty, proxy_size); + if (special_seq_update) - ibuf= give_ibuf_seq_direct(bmain, scene, rectx, recty, cfra + frame_ofs, proxy_size, special_seq_update); + ibuf= give_ibuf_seq_direct(context, cfra + frame_ofs, special_seq_update); else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { - ibuf= (ImBuf *)give_ibuf_seq(bmain, scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size); + ibuf= (ImBuf *)give_ibuf_seq(context, cfra + frame_ofs, sseq->chanshown); else - ibuf= (ImBuf *)give_ibuf_seq_threaded(bmain, scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size); + ibuf= (ImBuf *)give_ibuf_seq_threaded(context, cfra + frame_ofs, sseq->chanshown); if(ibuf==NULL) return; @@ -870,6 +873,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq UI_view2d_view_restore(C); } +#if 0 void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq) { int rectx, recty; @@ -893,6 +897,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq) proxy_size); } } +#endif /* draw backdrop of the sequencer strips view */ static void draw_seq_backdrop(View2D *v2d) diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 2b27186041f..3b0d8bb7a29 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -56,13 +56,11 @@ #include "text_intern.h" /******************** text font drawing ******************/ -static int mono= -1; // XXX needs proper storage and change all the BLF_* here +// XXX, fixme +#define mono blf_mono_font static void text_font_begin(SpaceText *st) { - if(mono == -1) - mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - BLF_aspect(mono, 1.0); BLF_size(mono, st->lheight, 72); } diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index e9ed8335061..0820b69ee46 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -58,10 +58,6 @@ IF(WITH_GAMEENGINE) ADD_DEFINITIONS(-DWITH_GAMEENGINE) ENDIF(WITH_GAMEENGINE) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - ADD_DEFINITIONS(-DGLEW_STATIC) BLENDERLIB(bf_editor_space_view3d "${SRC}" "${INC}") diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index f9af8bd5e79..0fb7ff8ec38 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -661,8 +661,9 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* draw the textured mesh */ draw_textured_begin(scene, v3d, rv3d, ob); + glColor4f(1.0f,1.0f,1.0f,1.0f); + if(ob->mode & OB_MODE_EDIT) { - glColor4f(1.0f,1.0f,1.0f,1.0f); dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh); } else if(faceselect) { if(ob->mode & OB_MODE_WEIGHT_PAINT) @@ -674,7 +675,6 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if( GPU_buffer_legacy(dm) ) dm->drawFacesTex(dm, draw_tface__set_draw_legacy); else { - glColor4f(1.0f,1.0f,1.0f,1.0f); if( !CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL) ) add_tface_color_layer(dm); dm->drawFacesTex(dm, draw_tface__set_draw); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index fa5000a5c9e..a55e054c457 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2509,7 +2509,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else if(dt==OB_WIRE || totface==0) { draw_wire = 1; /* draw wire only, no depth buffer stuff */ } - else if( (is_paint_sel && (ob->mode & OB_MODE_TEXTURE_PAINT)) || + else if( (is_paint_sel || (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 || is_paint_sel) && !draw_wire) { @@ -3559,6 +3559,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv case PART_DRAW_AXIS: /* lets calculate the scale: */ pixsize= view3d_pixel_size(rv3d, ob->obmat[3]); + + if(part->draw_size==0.0) + pixsize*=2.0; + else + pixsize*=part->draw_size; if(draw_as==PART_DRAW_AXIS) create_cdata = 1; @@ -4100,8 +4105,8 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); - glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); glShadeModel(GL_SMOOTH); if(pset->brushtype == PE_BRUSH_WEIGHT) { @@ -5352,10 +5357,12 @@ static void draw_bounding_volume(Scene *scene, Object *ob) bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb; } else if(ob->type==OB_MBALL) { - bb= ob->bb; - if(bb==0) { - makeDispListMBall(scene, ob); + if(is_basis_mball(ob)) { bb= ob->bb; + if(bb==0) { + makeDispListMBall(scene, ob); + bb= ob->bb; + } } } else { @@ -5406,7 +5413,7 @@ static void drawtexspace(Object *ob) } /* draws wire outline */ -static void drawSolidSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) +static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) { RegionView3D *rv3d= ar->regiondata; Object *ob= base->object; @@ -5435,8 +5442,10 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) draw_index_wire= 1; } } else if (ob->type==OB_MBALL) { - if((base->flag & OB_FROMDUPLI)==0) - drawDispListwire(&ob->disp); + if(is_basis_mball(ob)) { + if((base->flag & OB_FROMDUPLI)==0) + drawDispListwire(&ob->disp); + } } else if(ob->type==OB_ARMATURE) { if(!(ob->mode & OB_MODE_POSE)) @@ -5490,7 +5499,9 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) draw_index_wire= 1; } } else if (ob->type==OB_MBALL) { - drawDispListwire(&ob->disp); + if(is_basis_mball(ob)) { + drawDispListwire(&ob->disp); + } } glDepthMask(1); @@ -5800,12 +5811,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0); } - /* draw outline for selected solid objects, mesh does itself */ + /* draw outline for selected objects, mesh does itself */ if((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && ob->type!=OB_MESH) { - if(dt>OB_WIRE && dt<OB_TEXTURE && (ob->mode & OB_MODE_EDIT)==0 && (flag & DRAW_SCENESET)==0) { + if(dt>OB_WIRE && (ob->mode & OB_MODE_EDIT)==0 && (flag & DRAW_SCENESET)==0) { if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) { - drawSolidSelect(scene, v3d, ar, base); + drawObjectSelect(scene, v3d, ar, base); } } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 612f2b4af48..aeac6563e1c 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -620,6 +620,11 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; } + switch(wmn->action) { + case NA_ADDED: + ED_region_tag_redraw(ar); + break; + } break; case NC_GEOM: switch(wmn->data) { diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 9d17bbfe7da..5c95423e77f 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -919,7 +919,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob) uiItemR(col, &eboneptr, "head", 0, "Head", 0); if (ebone->parent && ebone->flag & BONE_CONNECTED ) { PointerRNA parptr = RNA_pointer_get(&eboneptr, "parent"); - uiItemR(col, &parptr, "tail_radius", 0, "Radius", 0); + uiItemR(col, &parptr, "tail_radius", 0, "Radius (Parent)", 0); } else { uiItemR(col, &eboneptr, "head_radius", 0, "Radius", 0); } @@ -946,7 +946,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&mball->id, &RNA_MetaElement, mball->lastelem, &ptr); col= uiLayoutColumn(layout, 0); - uiItemR(col, &ptr, "location", 0, "Location", 0); + uiItemR(col, &ptr, "co", 0, "Location", 0); uiItemR(col, &ptr, "radius", 0, "Radius", 0); uiItemR(col, &ptr, "stiffness", 0, "Stiffness", 0); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 2bdba27a237..96329ac5d68 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -243,15 +243,13 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo #define GRID_MIN_PX 6.0f -static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit) +static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit) { /* extern short bgpicmode; */ RegionView3D *rv3d= ar->regiondata; float wx, wy, x, y, fw, fx, fy, dx; float vec4[4]; char col[3], col2[3]; - - *grid_unit= NULL; vec4[0]=vec4[1]=vec4[2]=0.0; vec4[3]= 1.0; @@ -266,7 +264,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u x= (wx)*fx/fw; y= (wy)*fy/fw; - vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid; + vec4[0]=vec4[1]= v3d->grid; vec4[2]= 0.0; vec4[3]= 1.0; @@ -306,7 +304,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u /* Store the smallest drawn grid size units name so users know how big each grid cell is */ if(*grid_unit==NULL) { *grid_unit= bUnit_GetNameDisplay(usys, i); - rv3d->gridview= (scalar * unit->scale_length); + rv3d->gridview= (scalar * v3d->grid) / unit->scale_length; } blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar); @@ -417,9 +415,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u } #undef GRID_MIN_PX -static void drawfloor(Scene *scene, View3D *v3d) +static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) { - float vert[3], grid; + float vert[3], grid, grid_scale; int a, gridlines, emphasise; char col[3], col2[3]; short draw_line = 0; @@ -428,11 +426,28 @@ static void drawfloor(Scene *scene, View3D *v3d) if(v3d->gridlines<3) return; + grid_scale= v3d->grid; + /* use 'grid_scale' instead of 'v3d->grid' from now on */ + + /* apply units */ + if(scene->unit.system) { + void *usys; + int len; + + bUnit_GetSystem(&usys, &len, scene->unit.system, B_UNIT_LENGTH); + + if(usys) { + int i= bUnit_GetBaseUnit(usys); + *grid_unit= bUnit_GetNameDisplay(usys, i); + grid_scale = (grid_scale * bUnit_GetScaler(usys, i)) / scene->unit.scale_length; + } + } + if(v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select gridlines= v3d->gridlines/2; - grid= gridlines*v3d->grid; - + grid= gridlines * grid_scale; + UI_GetThemeColor3ubv(TH_GRID, col); UI_GetThemeColor3ubv(TH_BACK, col2); @@ -472,7 +487,7 @@ static void drawfloor(Scene *scene, View3D *v3d) if (draw_line) { glBegin(GL_LINE_STRIP); - vert[0]= a*v3d->grid; + vert[0]= a * grid_scale; vert[1]= grid; glVertex3fv(vert); vert[1]= -grid; @@ -511,7 +526,7 @@ static void drawfloor(Scene *scene, View3D *v3d) if (draw_line) { glBegin(GL_LINE_STRIP); - vert[1]= a*v3d->grid; + vert[1]= a * grid_scale; vert[0]= grid; glVertex3fv(vert ); vert[0]= -grid; @@ -2138,9 +2153,12 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in RegionView3D *rv3d= ar->regiondata; ImBuf *ibuf; GPUOffScreen *ofs; + + /* state changes make normal drawing go weird otherwise */ + glPushAttrib(GL_LIGHTING_BIT); /* bind */ - ofs= GPU_offscreen_create(sizex, sizey); + ofs= GPU_offscreen_create(&sizex, &sizey); if(ofs == NULL) return NULL; @@ -2175,6 +2193,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in GPU_offscreen_unbind(ofs); GPU_offscreen_free(ofs); + glPopAttrib(); + if(ibuf->rect_float && ibuf->rect) IMB_rect_from_float(ibuf); @@ -2279,10 +2299,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) Base *base; Object *ob; float backcol[3]; - int retopo= 0, sculptparticle= 0; unsigned int lay_used; Object *obact = OBACT; - char *grid_unit= NULL; + const char *grid_unit= NULL; /* from now on all object derived meshes check this */ v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact); @@ -2335,7 +2354,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) if(rv3d->view==0 || rv3d->persp != RV3D_ORTHO) { if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { - drawfloor(scene, v3d); + drawfloor(scene, v3d, &grid_unit); } if(rv3d->persp==RV3D_CAMOB) { if(scene->world) { @@ -2419,11 +2438,6 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) v3d->lay_used= lay_used; } -// retopo= retopo_mesh_check() || retopo_curve_check(); - sculptparticle= (obact && obact->mode & (OB_MODE_PARTICLE_EDIT)) && !scene->obedit; - if(retopo) - view3d_update_depths(ar); - /* draw selected and editmode */ for(base= scene->base.first; base; base= base->next) { if(v3d->lay & base->lay) { @@ -2431,11 +2445,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) draw_object(scene, ar, v3d, base, 0); } } - - if(!retopo && sculptparticle && !(obact && (obact->dtx & OB_DRAWXRAY))) { - view3d_update_depths(ar); - } - + // REEB_draw(); /* Transp and X-ray afterdraw stuff */ @@ -2444,11 +2454,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) if(v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - - if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) { - view3d_update_depths(ar); - } - + if(rv3d->rflag & RV3D_CLIPPING) view3d_clr_clipping(); @@ -2502,8 +2508,14 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) draw_viewport_name(ar, v3d); } if (grid_unit) { /* draw below the viewport name */ + char tstr[32]= ""; + UI_ThemeColor(TH_TEXT_HI); - BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit, 65535); /* XXX, use real length */ + if(v3d->grid != 1.0f) { + BLI_snprintf(tstr, sizeof(tstr), "%s x %.4g", grid_unit, v3d->grid); + } + + BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, tstr[0]?tstr : grid_unit, sizeof(tstr)); /* XXX, use real length */ } ob= OBACT; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 3bfe4fa604a..59453707361 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2030,6 +2030,14 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } + +int region3d_unlocked_poll(bContext *C) +{ + RegionView3D *rv3d= CTX_wm_region_view3d(C); + return (rv3d && rv3d->viewlock==0); +} + + void VIEW3D_OT_viewnumpad(wmOperatorType *ot) { /* identifiers */ @@ -2039,7 +2047,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) /* api callbacks */ ot->exec= viewnumpad_exec; - ot->poll= ED_operator_region_view3d_active; + ot->poll= region3d_unlocked_poll; /* flags */ ot->flag= 0; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index b6372242a9a..1711520df63 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -894,7 +894,9 @@ static int fly_modal(bContext *C, wmOperator *op, wmEvent *event) { int exit_code; short do_draw= FALSE; - FlyInfo *fly = op->customdata; + FlyInfo *fly= op->customdata; + RegionView3D *rv3d= fly->rv3d; + Object *fly_object= fly->root_parent ? fly->root_parent : fly->v3d->camera; fly->redraw= 0; @@ -909,10 +911,10 @@ static int fly_modal(bContext *C, wmOperator *op, wmEvent *event) if(exit_code!=OPERATOR_RUNNING_MODAL) do_draw= TRUE; - + if(do_draw) { - if(fly->rv3d->persp==RV3D_CAMOB) { - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, fly->root_parent ? fly->root_parent : fly->v3d->camera); + if(rv3d->persp==RV3D_CAMOB) { + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, fly_object); } ED_region_tag_redraw(CTX_wm_region(C)); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 92167f0f45e..445a83b4266 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -91,6 +91,7 @@ void VIEW3D_OT_drawtype(struct wmOperatorType *ot); void view3d_boxview_copy(ScrArea *sa, ARegion *ar); void view3d_persp_mat4(struct RegionView3D *rv3d, float mat[][4]); +int region3d_unlocked_poll(struct bContext *C); /* view3d_fly.c */ void view3d_keymap(struct wmKeyConfig *keyconf); @@ -135,7 +136,6 @@ void add_view3d_after(ListBase *lb, Base *base, int flag); void circf(float x, float y, float rad); void circ(float x, float y, float rad); -void view3d_update_depths(struct ARegion *ar); void view3d_update_depths_rect(struct ARegion *ar, struct ViewDepths *d, struct rcti *rect); float view3d_depth_near(struct ViewDepths *d); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 16896f75915..1064611b84f 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -64,23 +64,34 @@ /* ******************* view3d space & buttons ************** */ -/* op->invoke */ +/* op->exec */ +/* XXX DUPLICATE CODE */ static void redo_cb(bContext *C, void *arg_op, void *UNUSED(arg2)) { wmOperator *lastop= arg_op; if(lastop) { + ARegion *ar= CTX_wm_region(C); + ARegion *ar1= BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW); int retval; + if(ar1) + CTX_wm_region_set(C, ar1); + if (G.f & G_DEBUG) printf("operator redo %s\n", lastop->type->name); + ED_undo_pop_op(C, lastop); retval= WM_operator_repeat(C, lastop); + if((retval & OPERATOR_FINISHED)==0) { if (G.f & G_DEBUG) printf("operator redo failed %s\n", lastop->type->name); ED_undo_redo(C); } + + /* set region back */ + CTX_wm_region_set(C, ar); } } @@ -177,7 +188,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) } -static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), char *str, uiSearchItems *items) +static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index d0d4c9ee5c8..123c15bdb5b 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -479,7 +479,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) /* api callbacks */ ot->exec= view3d_setobjectascamera_exec; - ot->poll= ED_operator_region_view3d_active; + ot->poll= region3d_unlocked_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 8822e868556..e7215c3273c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -571,7 +571,9 @@ int transformEvent(TransInfo *t, wmEvent *event) t->mval[0] = event->x - t->ar->winrct.xmin; t->mval[1] = event->y - t->ar->winrct.ymin; - t->redraw |= TREDRAW_SOFT; + // t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */ + t->redraw |= TREDRAW_HARD; + if (t->state == TRANS_STARTING) { t->state = TRANS_RUNNING; @@ -1487,6 +1489,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int { int options = 0; + t->context = C; + /* added initialize, for external calls to set stuff in TransInfo, like undo string */ t->state = TRANS_STARTING; @@ -1628,6 +1632,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int break; case TFM_EDGE_SLIDE: initEdgeSlide(t); + if(t->state == TRANS_CANCEL) + { + postTrans(C, t); + return 0; + } break; case TFM_BONE_ROLL: initBoneRoll(t); @@ -1715,11 +1724,15 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int } } + t->context = NULL; + return 1; } -void transformApply(const bContext *C, TransInfo *t) +void transformApply(bContext *C, TransInfo *t) { + t->context = C; + if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { if (t->modifiers & MOD_CONSTRAINT_SELECT) @@ -1747,15 +1760,17 @@ void transformApply(const bContext *C, TransInfo *t) //do_screenhandlers(G.curscreen); t->redraw |= TREDRAW_HARD; } + + t->context = NULL; } -void drawTransformApply(const struct bContext *C, struct ARegion *UNUSED(ar), void *arg) +void drawTransformApply(const bContext *C, struct ARegion *UNUSED(ar), void *arg) { TransInfo *t = arg; if (t->redraw & TREDRAW_SOFT) { t->redraw |= TREDRAW_HARD; - transformApply(C, t); + transformApply((bContext *)C, t); } } @@ -1763,6 +1778,8 @@ int transformEnd(bContext *C, TransInfo *t) { int exit_code = OPERATOR_RUNNING_MODAL; + t->context = C; + if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) { /* handle restoring objects */ @@ -1799,6 +1816,8 @@ int transformEnd(bContext *C, TransInfo *t) viewRedrawForce(C, t); } + t->context = NULL; + return exit_code; } @@ -4271,6 +4290,7 @@ static int createSlideVerts(TransInfo *t) efa->e1->f1++; if(efa->e1->f1 > 2) { //BKE_report(op->reports, RPT_ERROR, "3+ face edge"); + MEM_freeN(sld); return 0; } } @@ -4279,6 +4299,7 @@ static int createSlideVerts(TransInfo *t) efa->e2->f1++; if(efa->e2->f1 > 2) { //BKE_report(op->reports, RPT_ERROR, "3+ face edge"); + MEM_freeN(sld); return 0; } } @@ -4287,6 +4308,7 @@ static int createSlideVerts(TransInfo *t) efa->e3->f1++; if(efa->e3->f1 > 2) { //BKE_report(op->reports, RPT_ERROR, "3+ face edge"); + MEM_freeN(sld); return 0; } } @@ -4295,13 +4317,15 @@ static int createSlideVerts(TransInfo *t) efa->e4->f1++; if(efa->e4->f1 > 2) { //BKE_report(op->reports, RPT_ERROR, "3+ face edge"); + MEM_freeN(sld); return 0; } } // Make sure loop is not 2 edges of same face if(ct > 1) { //BKE_report(op->reports, RPT_ERROR, "Loop crosses itself"); - return 0; + MEM_freeN(sld); + return 0; } } @@ -4313,6 +4337,7 @@ static int createSlideVerts(TransInfo *t) // Test for multiple segments if(vertsel > numsel+1) { //BKE_report(op->reports, RPT_ERROR, "Please choose a single edge loop"); + MEM_freeN(sld); return 0; } @@ -4349,6 +4374,7 @@ static int createSlideVerts(TransInfo *t) if(timesthrough >= numsel*2) { BLI_linklist_free(edgelist,NULL); //BKE_report(op->reports, RPT_ERROR, "Could not order loop"); + MEM_freeN(sld); return 0; } } @@ -4759,7 +4785,11 @@ void initEdgeSlide(TransInfo *t) t->mode = TFM_EDGE_SLIDE; t->transform = EdgeSlide; - createSlideVerts(t); + if(!createSlideVerts(t)) { + t->state= TRANS_CANCEL; + return; + } + sld = t->customData; if (!sld) diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index de978626b3e..2778aa4df08 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -317,6 +317,7 @@ typedef struct TransInfo { float axis_orig[3]; /* TransCon can change 'axis', store the original value here */ void *view; + struct bContext *context; /* Only valid (non null) during an operator called function. */ struct ScrArea *sa; struct ARegion *ar; struct Scene *scene; @@ -448,7 +449,7 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot); int initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event, int mode); void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op); int transformEvent(TransInfo *t, struct wmEvent *event); -void transformApply(const struct bContext *C, TransInfo *t); +void transformApply(struct bContext *C, TransInfo *t); int transformEnd(struct bContext *C, TransInfo *t); void setTransformViewMatrices(TransInfo *t); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 54b724d69f7..305a9331d1d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -68,6 +68,7 @@ #include "BKE_pointcache.h" #include "BKE_bmesh.h" #include "BKE_scene.h" +#include "BKE_report.h" #include "ED_anim_api.h" @@ -4546,6 +4547,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { + ReportList *reports = CTX_wm_reports(C); KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); ListBase dsources = {NULL, NULL}; float cfra= (float)CFRA; // xxx this will do for now @@ -4570,7 +4572,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, if (adt && adt->action) { for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) { fcu->flag &= ~FCURVE_SELECTED; - insert_keyframe(id, adt->action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, id, adt->action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); } } } @@ -4645,6 +4647,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { + ReportList *reports = CTX_wm_reports(C); KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); float cfra= (float)CFRA; short flag= 0; @@ -4686,7 +4689,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o * NOTE: this will do constraints too, but those are ok to do here too? */ if (pchanName && strcmp(pchanName, pchan->name) == 0) - insert_keyframe(id, act, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, id, act, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); if (pchanName) MEM_freeN(pchanName); } @@ -4883,6 +4886,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (ELEM(t->frame_side, 'L', 'R')) scene_marker_tfm_extend(t->scene, floor(t->vec[0] + 0.5f), SELECT, t->scene->r.cfra, t->frame_side); } + else if(t->mode == TFM_TIME_SCALE) { + scene_marker_tfm_scale(t->scene, t->vec[0], SELECT); + } } #if 0 // XXX future of this is still not clear diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 6e71cf30112..8ff852bad32 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -747,7 +747,7 @@ void recalcData(TransInfo *t) mul_m3_v3(t->mat, up_axis); } - ebo->roll = ED_rollBoneToVector(ebo, up_axis); + ebo->roll = ED_rollBoneToVector(ebo, up_axis, FALSE); } } } @@ -817,7 +817,7 @@ void recalcData(TransInfo *t) // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { animrecord_check_state(t->scene, &ob->id, t->animtimer); - autokeyframe_ob_cb_func(NULL, t->scene, (View3D *)t->view, ob, t->mode); + autokeyframe_ob_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode); } /* sets recalc flags fully, instead of flushing existing ones diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 06a2db527fd..6128c62f670 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -261,6 +261,8 @@ void applyProject(TransInfo *t) } else if (t->flag & T_OBJECT) { + td->ob->recalc |= OB_RECALC_ALL; + object_handle_update(t->scene, td->ob); VECCOPY(iloc, td->ob->obmat[3]); } @@ -372,7 +374,8 @@ void initSnappingMode(TransInfo *t) if (t->tsnap.applySnap != NULL && // A snapping function actually exist (obedit != NULL && ELEM3(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE)) ) // Temporary limited to edit mode meshes, armature, curves { - if ((t->flag & T_PROP_EDIT) || t->tsnap.project) /* also exclude edit for project, for now */ + /* editmode meshes now supported */ + if ((obedit->type != OB_MESH) && ((t->flag & T_PROP_EDIT) || t->tsnap.project)) /* also exclude edit for project, for now */ { t->tsnap.modeSelect = SNAP_NOT_OBEDIT; } @@ -1264,7 +1267,7 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E int retval = 0; int totvert = dm->getNumVerts(dm); int totface = dm->getNumFaces(dm); - + if (totvert > 0) { float imat[4][4]; float timat[3][3]; /* transpose inverse matrix for normals */ @@ -1304,6 +1307,7 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E /* local scale in normal direction */ float local_scale = len_v3(ray_normal_local); + treeData.em_evil= em; bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6); hit.index = -1; @@ -1538,7 +1542,8 @@ int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obma if (editobject) { em = ((Mesh *)ob->data)->edit_mesh; - dm = editmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); + /* dm = editmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); */ + dm = editmesh_get_derived_base(ob, em); /* limitation, em & dm MUST have the same number of faces */ } else { diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index debb8cedd07..2b9b8c7f162 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -56,7 +56,7 @@ Add this in your local code: -void undo_editmode_push(bContext *C, char *name, +void undo_editmode_push(bContext *C, const char *name, void * (*getdata)(bContext *C), // use context to retrieve current editdata void (*freedata)(void *), // pointer to function freeing data void (*to_editmode)(void *, void *), // data to editmode conversion @@ -109,7 +109,7 @@ static void undo_restore(UndoElem *undo, void *editdata) } /* name can be a dynamic string */ -void undo_editmode_push(bContext *C, char *name, +void undo_editmode_push(bContext *C, const char *name, void * (*getdata)(bContext *C), void (*freedata)(void *), void (*to_editmode)(void *, void *), diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 37a3a65f170..e8c4edf3d57 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -63,7 +63,7 @@ /* ***************** generic undo system ********************* */ -void ED_undo_push(bContext *C, char *str) +void ED_undo_push(bContext *C, const char *str) { wmWindowManager *wm= CTX_wm_manager(C); Object *obedit= CTX_data_edit_object(C); diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index a2bfddd96fb..4045e83dafa 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -46,10 +46,6 @@ SET(SRC intern/gpu_shader_vertex.glsl.c ) -IF(WIN32) - INCLUDE_DIRECTORIES(${PTHREADS_INC}) -ENDIF(WIN32) - ADD_DEFINITIONS(-DGLEW_STATIC) BLENDERLIB(bf_gpu "${SRC}" "${INC}") diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index a7f43d3b0ae..96c68778201 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -140,9 +140,10 @@ void GPU_framebuffer_free(GPUFrameBuffer *fb); void GPU_framebuffer_restore(); /* GPU OffScreen - - wrapper around framebuffer and texture for simple offscreen drawing */ + - wrapper around framebuffer and texture for simple offscreen drawing + - changes size if graphics card can't support it */ -GPUOffScreen *GPU_offscreen_create(int width, int height); +GPUOffScreen *GPU_offscreen_create(int *width, int *height); void GPU_offscreen_free(GPUOffScreen *ofs); void GPU_offscreen_bind(GPUOffScreen *ofs); void GPU_offscreen_unbind(GPUOffScreen *ofs); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 129ba188e5f..00644eb02f7 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1496,7 +1496,7 @@ void GPU_interleaved_attrib_setup( GPUBuffer *buffer, GPUAttrib data[], int numd glBindBufferARB( GL_ARRAY_BUFFER_ARB, buffer->id ); for( i = 0; i < numdata; i++ ) { glEnableVertexAttribArrayARB( data[i].index ); - glVertexAttribPointerARB( data[i].index, data[i].size, data[i].type, GL_TRUE, elementsize, (void *)offset ); + glVertexAttribPointerARB( data[i].index, data[i].size, data[i].type, GL_FALSE, elementsize, (void *)offset ); offset += data[i].size*GPU_typesize(data[i].type); attribData[i].index = data[i].index; @@ -1508,7 +1508,7 @@ void GPU_interleaved_attrib_setup( GPUBuffer *buffer, GPUAttrib data[], int numd else { for( i = 0; i < numdata; i++ ) { glEnableVertexAttribArrayARB( data[i].index ); - glVertexAttribPointerARB( data[i].index, data[i].size, data[i].type, GL_TRUE, elementsize, (char *)buffer->pointer + offset ); + glVertexAttribPointerARB( data[i].index, data[i].size, data[i].type, GL_FALSE, elementsize, (char *)buffer->pointer + offset ); offset += data[i].size*GPU_typesize(data[i].type); } } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a93d8cbbb8e..a3a42054cbc 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -810,7 +810,8 @@ void GPU_free_unused_buffers(void) BLI_freelistN(&image_free_queue); /* vbo buffers */ - GPU_buffer_pool_free_unused(0); + /* it's probably not necessary to free all buffers every frame */ + /* GPU_buffer_pool_free_unused(0); */ BLI_unlock_thread(LOCK_OPENGL); } diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 70a74aafead..d823eddcc83 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -67,10 +67,11 @@ static struct GPUGlobal { int glslsupport; int extdisabled; int colordepth; + int npotdisabled; /* Special case for Ati R500 chipset cards that only support npot with severe restrictions */ GPUDeviceType device; GPUOSType os; GPUDriverType driver; -} GG = {1, 0, 0, 0}; +} GG = {1, 0, 0, 0, 0}; /* GPU Types */ @@ -119,6 +120,12 @@ void GPU_extensions_init() if(strstr(vendor, "ATI")) { GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OFFICIAL; + + /* ATI X1xxx cards (R500 chipset) lack full support for npot textures + * although they report the GLEW_ARB_texture_non_power_of_two extension. + */ + if(strstr(renderer, "X1")) + GG.npotdisabled = 1; } else if(strstr(vendor, "NVIDIA")) { GG.device = GPU_DEVICE_NVIDIA; @@ -177,6 +184,9 @@ int GPU_non_power_of_two_support() if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) return 0; + if(GG.npotdisabled) + return 0; + return GLEW_ARB_texture_non_power_of_two; } @@ -820,7 +830,7 @@ struct GPUOffScreen { GPUTexture *depth; }; -GPUOffScreen *GPU_offscreen_create(int width, int height) +GPUOffScreen *GPU_offscreen_create(int *width, int *height) { GPUOffScreen *ofs; @@ -832,18 +842,24 @@ GPUOffScreen *GPU_offscreen_create(int width, int height) return NULL; } - ofs->depth = GPU_texture_create_depth(width, height); + ofs->depth = GPU_texture_create_depth(*width, *height); if(!ofs->depth) { GPU_offscreen_free(ofs); return NULL; } + if(*width!=ofs->depth->w || *height!=ofs->depth->h) { + *width= ofs->depth->w; + *height= ofs->depth->h; + printf("Offscreen size differs from given size!\n"); + } + if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth)) { GPU_offscreen_free(ofs); return NULL; } - ofs->color = GPU_texture_create_2D(width, height, NULL); + ofs->color = GPU_texture_create_2D(*width, *height, NULL); if(!ofs->color) { GPU_offscreen_free(ofs); return NULL; diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index f89ef033d78..36dcfefdc1c 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -66,10 +66,6 @@ SET(SRC intern/writeimage.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_IMAGE_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_IMAGE_OPENEXR) diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 22dfc5e9592..eff42e48dad 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -206,7 +206,7 @@ void IMB_close_anim(struct anim *anim); * @attention Defined in anim.c */ -int ismovie(char *name); +int ismovie(const char *name); void IMB_anim_set_preseek(struct anim *anim, int preseek); int IMB_anim_get_preseek(struct anim *anim); @@ -283,7 +283,7 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned * * @attention Defined in writeimage.c */ -short IMB_saveiff(struct ImBuf *ibuf, char *filepath, int flags); +short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags); /** * Encodes a png image from an ImBuf @@ -296,19 +296,19 @@ short IMB_png_encode(struct ImBuf *ibuf, int file, int flags); * * @attention Defined in util.c */ -int IMB_ispic(char *name); +int IMB_ispic(const char *name); /** * * @attention Defined in util.c */ -int IMB_isanim(char *name); +int IMB_isanim(const char *name); /** * * @attention Defined in util.c */ -int imb_get_anim_type(char *name); +int imb_get_anim_type(const char *name); /** * diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 8529c72c7ae..f82f93c83a1 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -38,7 +38,7 @@ typedef struct ImFileType { int (*is_a)(unsigned char *buf); int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags); - int (*save)(struct ImBuf *ibuf, char *name, int flags); + int (*save)(struct ImBuf *ibuf, const char *name, int flags); void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); int flag; @@ -61,52 +61,52 @@ void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); /* png */ int imb_is_a_png(unsigned char *buf); struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags); -int imb_savepng(struct ImBuf *ibuf, char *name, int flags); +int imb_savepng(struct ImBuf *ibuf, const char *name, int flags); /* targa */ int imb_is_a_targa(unsigned char *buf); struct ImBuf *imb_loadtarga(unsigned char *mem, size_t size, int flags); -int imb_savetarga(struct ImBuf * ibuf, char *name, int flags); +int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags); /* iris */ int imb_is_a_iris(unsigned char *mem); struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags); -int imb_saveiris(struct ImBuf * ibuf, char *name, int flags); +int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags); /* jp2 */ int imb_is_a_jp2(unsigned char *buf); struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags); -int imb_savejp2(struct ImBuf *ibuf, char *name, int flags); +int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags); /* jpeg */ int imb_is_a_jpeg(unsigned char *mem); -int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags); +int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags); struct ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags); struct ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags); /* bmp */ int imb_is_a_bmp(unsigned char *buf); struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags); -int imb_savebmp(struct ImBuf *ibuf, char *name, int flags); +int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags); /* cocoa */ struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags); -short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags); +short imb_cocoaSaveImage(struct ImBuf *ibuf, const char *name, int flags); /* cineon */ -int imb_savecineon(struct ImBuf *buf, char *myfil, int flags); +int imb_savecineon(struct ImBuf *buf, const char *name, int flags); struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags); int imb_is_cineon(unsigned char *buf); /* dpx */ -int imb_save_dpx(struct ImBuf *buf, char *myfile, int flags); +int imb_save_dpx(struct ImBuf *buf, const char *name, int flags); struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags); int imb_is_dpx(unsigned char *buf); /* hdr */ int imb_is_a_hdr(unsigned char *buf); struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags); -int imb_savehdr(struct ImBuf * ibuf, char *name, int flags); +int imb_savehdr(struct ImBuf * ibuf, const char *name, int flags); /* tiff */ void imb_inittiff(void); @@ -114,7 +114,7 @@ int imb_is_a_tiff(unsigned char *buf); struct ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags); void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect); -int imb_savetiff(struct ImBuf *ibuf, char *name, int flags); +int imb_savetiff(struct ImBuf *ibuf, const char *name, int flags); void *libtiff_findsymbol(char *name); #endif /* IMB_FILETYPE_H */ diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 421ef08dc25..1bf8eb899db 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -215,7 +215,7 @@ int ismovie(char *name) { #else -int ismovie(char *UNUSED(name)) { +int ismovie(const char *UNUSED(name)) { return 0; } diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 10dc23b1ad2..8aae41b653c 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -195,7 +195,7 @@ static int putShortLSB(unsigned short us,FILE *ofile) { } /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ -int imb_savebmp(struct ImBuf *ibuf, char *name, int flags) { +int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags) { BMPINFOHEADER infoheader; int bytesize, extrabytes, x, y, t, ptr; diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt index a39235b20ec..0a1d2d3fd74 100644 --- a/source/blender/imbuf/intern/cineon/CMakeLists.txt +++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt @@ -44,4 +44,4 @@ SET(SRC logmemfile.c ) -BLENDERLIB(bf_cineon "${SRC}" "${INC}") +BLENDERLIB(bf_imbuf_cineon "${SRC}" "${INC}") diff --git a/source/blender/imbuf/intern/cineon/SConscript b/source/blender/imbuf/intern/cineon/SConscript index d9c8ab14d35..25088c6e34a 100644 --- a/source/blender/imbuf/intern/cineon/SConscript +++ b/source/blender/imbuf/intern/cineon/SConscript @@ -14,4 +14,4 @@ incs = ['.', defs = [] -env.BlenderLib ('bf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [220,175]) +env.BlenderLib ('bf_imbuf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [220,175]) diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 7a5a3fb011b..816d2d27b78 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -116,7 +116,7 @@ static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int return ibuf; } -static int imb_save_dpx_cineon(ImBuf *buf, char *filename, int use_cineon, int flags) +static int imb_save_dpx_cineon(ImBuf *buf, const char *filename, int use_cineon, int flags) { LogImageByteConversionParameters conversion; int width, height, depth; @@ -182,7 +182,7 @@ static int imb_save_dpx_cineon(ImBuf *buf, char *filename, int use_cineon, int f return 1; } -short imb_savecineon(struct ImBuf *buf, char *myfile, int flags) +short imb_savecineon(struct ImBuf *buf, const char *myfile, int flags) { return imb_save_dpx_cineon(buf, myfile, 1, flags); } @@ -200,7 +200,7 @@ ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags) return NULL; } -short imb_save_dpx(struct ImBuf *buf, char *myfile, int flags) +short imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) { return imb_save_dpx_cineon(buf, myfile, 0, flags); } diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt index 78513b35b87..5634368383d 100644 --- a/source/blender/imbuf/intern/dds/CMakeLists.txt +++ b/source/blender/imbuf/intern/dds/CMakeLists.txt @@ -48,4 +48,4 @@ if(WITH_IMAGE_DDS) ADD_DEFINITIONS(-DWITH_DDS) ENDIF(WITH_IMAGE_DDS) -BLENDERLIB(bf_dds "${SRC}" "${INC}") +BLENDERLIB(bf_imbuf_dds "${SRC}" "${INC}") diff --git a/source/blender/imbuf/intern/dds/SConscript b/source/blender/imbuf/intern/dds/SConscript index 59509c88f03..918ae7b530b 100644 --- a/source/blender/imbuf/intern/dds/SConscript +++ b/source/blender/imbuf/intern/dds/SConscript @@ -16,4 +16,4 @@ incs = ['.', defs = ['WITH_DDS'] -env.BlenderLib ('bf_dds', source_files, incs, defs, libtype=['core','player'], priority = [230,190]) +env.BlenderLib ('bf_imbuf_dds', source_files, incs, defs, libtype=['core','player'], priority = [230,190]) diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 08f60589977..94ff8fd5d78 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -37,7 +37,7 @@ extern "C" { #include "IMB_allocimbuf.h" -int imb_save_dds(struct ImBuf * ibuf, char *name, int flags) +int imb_save_dds(struct ImBuf * ibuf, const char *name, int flags) { return(0); /* todo: finish this function */ diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h index 384570ceb72..6aea3058863 100644 --- a/source/blender/imbuf/intern/dds/dds_api.h +++ b/source/blender/imbuf/intern/dds/dds_api.h @@ -29,7 +29,7 @@ extern "C" { #endif -int imb_save_dds(struct ImBuf *ibuf, char *name, int flags); +int imb_save_dds(struct ImBuf *ibuf, const char *name, int flags); int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags); diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 71ba9b06cad..51359dc0e68 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -175,9 +175,8 @@ static void readheader(FILE *inf, IMAGE *image) static int writeheader(FILE *outf, IMAGE *image) { - IMAGE t; + IMAGE t= {0}; - memset(&t, 0, sizeof(IMAGE)); fwrite(&t,sizeof(IMAGE),1,outf); fseek(outf,0,SEEK_SET); putshort(outf,image->imagic); @@ -662,7 +661,7 @@ static void expandrow(unsigned char *optr, unsigned char *iptr, int z) * Added: zbuf write */ -static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, char *name, int *zptr) +static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr) { FILE *outf; IMAGE *image; @@ -816,7 +815,7 @@ static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cn return optr - (unsigned char *)rlebuf; } -int imb_saveiris(struct ImBuf * ibuf, char *name, int flags) +int imb_saveiris(struct ImBuf * ibuf, const char *name, int flags) { short zsize; int ret; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 0403d0044f5..49920219d8c 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -55,14 +55,14 @@ typedef struct img_folder{ float *rates; }img_fol_t; -static int checkj2p(unsigned char *mem) /* J2K_CFMT */ +static int check_jp2(unsigned char *mem) /* J2K_CFMT */ { return memcmp(JP2_HEAD, mem, 12) ? 0 : 1; } int imb_is_a_jp2(unsigned char *buf) { - return checkj2p(buf); + return check_jp2(buf); } @@ -112,7 +112,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */ opj_cio_t *cio = NULL; - if (checkj2p(mem) == 0) return(0); + if (check_jp2(mem) == 0) return(0); /* configure the event callbacks (not required) */ memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); @@ -661,7 +661,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) { /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ -int imb_savejp2(struct ImBuf *ibuf, char *name, int flags) { +int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) { int quality = ibuf->ftype & 0xff; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index e7737e68fce..c685a54cbe9 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -622,7 +622,7 @@ static int init_jpeg(FILE * outfile, struct jpeg_compress_struct * cinfo, struct } -static int save_stdjpeg(char * name, struct ImBuf * ibuf) +static int save_stdjpeg(const char *name, struct ImBuf *ibuf) { FILE * outfile; struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo; @@ -656,7 +656,7 @@ static int save_stdjpeg(char * name, struct ImBuf * ibuf) } -static int save_vidjpeg(char * name, struct ImBuf * ibuf) +static int save_vidjpeg(const char *name, struct ImBuf *ibuf) { FILE * outfile; struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo; @@ -695,7 +695,7 @@ static int save_vidjpeg(char * name, struct ImBuf * ibuf) return 1; } -static int save_jstjpeg(char * name, struct ImBuf * ibuf) +static int save_jstjpeg(const char *name, struct ImBuf *ibuf) { char fieldname[1024]; struct ImBuf * tbuf; @@ -726,7 +726,7 @@ static int save_jstjpeg(char * name, struct ImBuf * ibuf) return returnval; } -static int save_maxjpeg(char * name, struct ImBuf * ibuf) +static int save_maxjpeg(const char *name, struct ImBuf *ibuf) { FILE * outfile; struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo; @@ -765,7 +765,7 @@ static int save_maxjpeg(char * name, struct ImBuf * ibuf) return 1; } -int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags) +int imb_savejpeg(struct ImBuf *ibuf, const char *name, int flags) { ibuf->flags = flags; diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt index 836958f4b09..edea033bb3a 100644 --- a/source/blender/imbuf/intern/openexr/CMakeLists.txt +++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt @@ -44,4 +44,4 @@ IF(WITH_IMAGE_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_IMAGE_OPENEXR) -BLENDERLIB(bf_openexr "${SRC}" "${INC}") +BLENDERLIB(bf_imbuf_openexr "${SRC}" "${INC}") diff --git a/source/blender/imbuf/intern/openexr/SConscript b/source/blender/imbuf/intern/openexr/SConscript index 47f83868baa..082bb82c322 100644 --- a/source/blender/imbuf/intern/openexr/SConscript +++ b/source/blender/imbuf/intern/openexr/SConscript @@ -15,4 +15,4 @@ incs += Split(env['BF_OPENEXR_INC']) defs = ['WITH_OPENEXR'] -env.BlenderLib ('bf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [225,180]) +env.BlenderLib ('bf_imbuf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [225,180]) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 2be935a9565..964e57f6cfe 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -187,7 +187,7 @@ static void openexr_header_metadata(Header *header, struct ImBuf *ibuf) header->insert(info->key, StringAttribute(info->value)); } -static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) +static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags) { int channels = ibuf->channels; int width = ibuf->x; @@ -314,7 +314,7 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) return (1); } -static int imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags) +static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flags) { int channels = ibuf->channels; int width = ibuf->x; @@ -372,7 +372,7 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags) } -int imb_save_openexr(struct ImBuf *ibuf, char *name, int flags) +int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags) { if (flags & IB_mem) { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index c7e4c7d2f57..8ca6dcd36e9 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -46,7 +46,7 @@ extern "C" { int imb_is_a_openexr (unsigned char *mem); -int imb_save_openexr (struct ImBuf *ibuf, char *name, int flags); +int imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags); struct ImBuf *imb_load_openexr (unsigned char *mem, size_t size, int flags); diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index b29a4ae0627..390e04ba303 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -94,7 +94,7 @@ static void ReadData( png_structp png_ptr, png_bytep data, png_size_t length) longjmp(png_jmpbuf(png_ptr), 1); } -int imb_savepng(struct ImBuf *ibuf, char *name, int flags) +int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) { png_structp png_ptr; png_infop info_ptr; @@ -110,35 +110,33 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) compression= (int)(((float)(ibuf->ftype & 0xff) / 11.1111f)); compression= compression < 0 ? 0 : (compression > 9 ? 9 : compression); + /* for prints */ + if(flags & IB_mem) + name= "<memory>"; + bytesperpixel = (ibuf->depth + 7) >> 3; if ((bytesperpixel > 4) || (bytesperpixel == 2)) { - printf("imb_savepng: unsupported bytes per pixel: %d\n", bytesperpixel); + printf("imb_savepng: Cunsupported bytes per pixel: %d for file: '%s'\n", bytesperpixel, name); return (0); } png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { - printf("Cannot png_create_write_struct\n"); + printf("imb_savepng: Cannot png_create_write_struct for file: '%s'\n", name); return 0; } info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - printf("Cannot png_create_info_struct\n"); + printf("imb_savepng: Cannot png_create_info_struct for file: '%s'\n", name); return 0; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); - if (pixels) MEM_freeN(pixels); - if (row_pointers) MEM_freeN(row_pointers); - // printf("Aborting\n"); - if (fp) { - fflush(fp); - fclose(fp); - } + printf("imb_savepng: Cannot setjmp for file: '%s'\n", name); return 0; } @@ -146,7 +144,8 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); if (pixels == NULL) { - printf("Cannot allocate pixels array\n"); + png_destroy_write_struct(&png_ptr, &info_ptr); + printf("imb_savepng: Cannot allocate pixels array of %dx%d, %d bytes per pixel for file: '%s'\n", ibuf->x, ibuf->y, bytesperpixel, name); return 0; } @@ -194,7 +193,9 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) } else { fp = fopen(name, "wb"); if (!fp) { + png_destroy_write_struct(&png_ptr, &info_ptr); MEM_freeN(pixels); + printf("imb_savepng: Cannot open file for writing: '%s'\n", name); return 0; } png_init_io(png_ptr, fp); @@ -257,8 +258,12 @@ int imb_savepng(struct ImBuf *ibuf, char *name, int flags) // allocate memory for an array of row-pointers row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { - printf("Cannot allocate row-pointers array\n"); + printf("imb_savepng: Cannot allocate row-pointers array for file '%s'\n", name); + png_destroy_write_struct(&png_ptr, &info_ptr); MEM_freeN(pixels); + if (fp) { + fclose(fp); + } return 0; } diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index b356f56ab74..9dbb4512e1f 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -333,7 +333,7 @@ static void writeHeader(FILE *file, int width, int height) fputc(10, file); } -int imb_savehdr(struct ImBuf *ibuf, char *name, int flags) +int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags) { FILE* file = fopen(name, "wb"); float *fp= NULL; diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 89a69242a46..a748cc1ab1d 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -233,21 +233,14 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) } -int imb_savetarga(struct ImBuf * ibuf, char *name, int flags) +int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) { - char buf[20]; + char buf[20]= {0}; FILE *fildes; short ok = 0; (void)flags; /* unused */ - if (ibuf == 0) return (0); - if (ibuf->rect == 0) return (0); - - memset(buf,0,sizeof(buf)); - - /* buf[0] = 0; length string */ - buf[16] = (ibuf->depth + 0x7 ) & ~0x7; if (ibuf->depth > 8 ){ buf[2] = 10; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index eb5d1f2c039..c086a55a70a 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -642,7 +642,7 @@ void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int * @return: 1 if the function is successful, 0 on failure. */ -int imb_savetiff(ImBuf *ibuf, char *name, int flags) +int imb_savetiff(ImBuf *ibuf, const char *name, int flags) { TIFF *image = NULL; uint16 samplesperpixel, bitspersample; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index cd447e5e43a..0365b712f24 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -142,7 +142,7 @@ const char *imb_ext_audio[] = { ".eac3", NULL}; -static int IMB_ispic_name(char *name) +static int IMB_ispic_name(const char *name) { ImFileType *type; struct stat st; @@ -176,7 +176,7 @@ static int IMB_ispic_name(char *name) return FALSE; } -int IMB_ispic(char *filename) +int IMB_ispic(const char *filename) { if(U.uiflag & USER_FILTERFILEEXTS) { if( (BLI_testextensie_array(filename, imb_ext_image)) || @@ -195,12 +195,12 @@ int IMB_ispic(char *filename) -static int isavi (char *name) { +static int isavi (const char *name) { return AVI_is_avi (name); } #ifdef WITH_QUICKTIME -static int isqtime (char *name) { +static int isqtime (const char *name) { return anim_is_quicktime (name); } #endif @@ -248,7 +248,7 @@ static AVCodecContext* get_codec_from_stream(AVStream* stream) #endif -static int isffmpeg (char *filename) { +static int isffmpeg (const char *filename) { AVFormatContext *pFormatCtx; unsigned int i; int videoStream; @@ -331,7 +331,7 @@ static int isredcode(char * filename) #endif -int imb_get_anim_type(char * name) { +int imb_get_anim_type(const char * name) { int type; struct stat st; @@ -372,7 +372,7 @@ int imb_get_anim_type(char * name) { return(0); } -int IMB_isanim(char *filename) { +int IMB_isanim(const char *filename) { int type; if(U.uiflag & USER_FILTERFILEEXTS) { diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index b55ce4b1df4..9c2855b0544 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -37,7 +37,7 @@ #include "imbuf.h" -short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags) +short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { ImFileType *type; @@ -50,7 +50,7 @@ short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags) if(ibuf->rect==NULL && ibuf->rect_float) IMB_rect_from_float(ibuf); } - + /* TODO. have const char for image write funcs */ return type->save(ibuf, name, flags); } } diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 50579660806..ba357b575d5 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -189,11 +189,11 @@ typedef struct Curve { float rot[3]; short texflag, pad1; /* keep a short because of give_obdata_texspace() */ - - short drawflag, twist_mode, pad[2]; + short drawflag, twist_mode; float twist_smooth, smallcaps_scale; - short pathlen, totcol; + int pathlen; + short pad, totcol; short flag, bevresol; float width, ext1, ext2; diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index b58bd259983..3df3c8b41c6 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -44,17 +44,20 @@ struct GPUTexture; /* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */ /* should be used in conjunction with an ID * to Image. */ typedef struct ImageUser { + struct Scene *scene; /* to retrieve render result */ + int framenr; /* movies, sequences: current to display */ int frames; /* total amount of frames to use */ int offset, sfra; /* offset within movie, start frame in global time */ - short fie_ima, cycl; /* fields/image in movie, cyclic flag */ - short flag, ok; - + char fie_ima, cycl; /* fields/image in movie, cyclic flag */ + char ok, pad; + short multi_index, layer, pass; /* listbase indices, for menu browsing or retrieve buffer */ - /* short menunr; */ /* localized menu entry, for handling browse event */ - short pad; - struct Scene *scene; /* to retrieve render result */ + short flag; + + int pad2; + } ImageUser; /* iuser->flag */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 3d774c7eb2e..078e99eba69 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -226,8 +226,8 @@ typedef struct RenderData { float edgeR, edgeG, edgeB; short fullscreen, xplay, yplay, freqplay; /* standalone player */ // XXX deprecated since 2.5 - short depth, attrib, rt2; /* standalone player */ // XXX deprecated since 2.5 - short frame_step; /* frames to jump during render/playback */ + short depth, attrib; /* standalone player */ // XXX deprecated since 2.5 + int frame_step; /* frames to jump during render/playback */ short stereomode; /* standalone player stereo settings */ // XXX deprecated since 2.5 @@ -458,7 +458,7 @@ typedef struct GameData { /* stereo/dome mode */ struct GameDome dome; - short stereoflag, stereomode, xsch, ysch; //xsch and ysch can be deleted !!! + short stereoflag, stereomode, xsch, ysch; //xsch and ysch used for backwards compat. float eyeseparation, pad1; } GameData; @@ -748,8 +748,10 @@ typedef struct bStats { typedef struct UnitSettings { /* Display/Editing unit options for each scene */ float scale_length; /* maybe have other unit conversions? */ - short system; - short flag; /* imperial, metric etc */ + char system; /* imperial, metric etc */ + char system_rotation; /* not implimented as a propper unit system yet */ + short flag; + } UnitSettings; typedef struct PhysicsSettings { diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 7091bc79a5b..132dd21913d 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -214,6 +214,7 @@ typedef struct ARegion { #define SCREEN_HANDLER_VERSE 3 /* regiontype, first two are the default set */ +/* Do NOT change order, append on end. Types are hardcoded needed */ enum { RGN_TYPE_WINDOW = 0, RGN_TYPE_HEADER, diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h index d7256b5b9e0..d2f6eb11952 100644 --- a/source/blender/makesdna/DNA_sensor_types.h +++ b/source/blender/makesdna/DNA_sensor_types.h @@ -207,6 +207,14 @@ typedef struct bJoystickSensor { #define SENS_RAY_NEG_Z_AXIS 5 //#define SENS_RAY_NEGATIVE_AXIS 1 +/* bRadarSensor->axis */ +#define SENS_RADAR_X_AXIS 0 +#define SENS_RADAR_Y_AXIS 1 +#define SENS_RADAR_Z_AXIS 2 +#define SENS_RADAR_NEG_X_AXIS 3 +#define SENS_RADAR_NEG_Y_AXIS 4 +#define SENS_RADAR_NEG_Z_AXIS 5 + /* bMessageSensor->type */ #define SENS_MESG_MESG 0 #define SENS_MESG_PROP 1 diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index b8be51b378f..95b6505529b 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -35,6 +35,7 @@ #define MOD_SMOKE_DISSOLVE_LOG (1<<3) /* using 1/x for dissolve */ #define MOD_SMOKE_HIGH_SMOOTH (1<<5) /* smoothens high res emission*/ +#define MOD_SMOKE_FILE_LOAD (1<<6) /* flag for file load */ /* noise */ #define MOD_SMOKE_NOISEWAVE (1<<0) diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index eafb03accb8..06ec96df848 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -923,6 +923,7 @@ enum { /* space types, moved from DNA_screen_types.h */ +/* Do NOT change order, append on end. types are hardcoded needed */ enum { SPACE_EMPTY, SPACE_VIEW3D, diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index c504c61bc90..5290a353580 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -376,6 +376,9 @@ typedef struct UserDef { short autokey_mode; /* autokeying mode */ short autokey_flag; /* flags for autokeying */ + + short text_render, pad9; /*options for text rendering*/ + float pad10; struct ColorBand coba_weight; /* from texture.h */ @@ -425,6 +428,7 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_FILENOUI (1 << 23) #define USER_NONEGFRAMES (1 << 24) #define USER_TXT_TABSTOSPACES_DISABLE (1 << 25) +#define USER_TOOLTIPS_PYTHON (1 << 26) /* helper macro for checking frame clamping */ #define FRAMENUMBER_MIN_CLAMP(cfra) \ @@ -530,6 +534,9 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_DRAW_AUTOMATIC 3 #define USER_DRAW_OVERLAP_FLIP 4 +/* text draw options*/ +#define USER_TEXT_DISABLE_AA (1 << 0) + /* tw_flag (transform widget) */ /* gp_settings (Grease Pencil Settings) */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 77b42bbed62..dcc620463c9 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -94,9 +94,9 @@ typedef struct RegionView3D { float camdx, camdy; /* camera view offsets, 1.0 = viewplane moves entire width/height */ float pixsize; float ofs[3]; - short camzoom, viewbut; + short camzoom; short twdrawflag; - short pad; + int pad; short rflag, viewlock; short persp; diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index d42289e17c4..61a6778c13f 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -33,9 +33,9 @@ SET(SRC ../../../../intern/guardedalloc/intern/mallocn.c ) -IF(WIN32) +IF(WIN32 AND NOT UNIX) LIST(APPEND SRC ../../../../intern/guardedalloc/intern/mmap_win.c) -ENDIF(WIN32) +ENDIF(WIN32 AND NOT UNIX) ADD_EXECUTABLE(makesdna ${SRC} ${INC_FILES}) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index d26e018e266..32f0389a714 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -600,7 +600,7 @@ void RNA_pointer_create(struct ID *id, StructRNA *type, void *data, PointerRNA * void RNA_blender_rna_pointer_create(PointerRNA *r_ptr); void RNA_pointer_recast(PointerRNA *ptr, PointerRNA *r_ptr); -extern PointerRNA PointerRNA_NULL; +extern const PointerRNA PointerRNA_NULL; /* Structs */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index bb4fb21f3a1..8d813f5c4f0 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -36,6 +36,7 @@ extern EnumPropertyItem DummyRNA_NULL_items[]; extern EnumPropertyItem DummyRNA_DEFAULT_items[]; extern EnumPropertyItem object_mode_items[]; +extern EnumPropertyItem metaelem_type_items[]; extern EnumPropertyItem proportional_falloff_items[]; extern EnumPropertyItem proportional_editing_items[]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 3329eda16bc..9479e9507f2 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -192,7 +192,7 @@ typedef enum PropertyFlag { PROP_RAW_ARRAY = 1<<14, PROP_FREE_POINTERS = 1<<15, PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */ - PROP_ENUM_NO_CONTEXT = 1<<18 /* for enum that shouldn't be contextual */ + PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */ } PropertyFlag; typedef struct CollectionPropertyIterator { diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index d280278b677..83484f655e9 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -7,7 +7,7 @@ o = SConscript('intern/SConscript') objs += o incs = '#/intern/guardedalloc #/intern/memutil #/intern/audaspace/intern ../blenkernel ../blenlib ../makesdna intern .' -incs += ' ../windowmanager ../editors/include ../gpu ../imbuf ../ikplugin' +incs += ' ../windowmanager ../editors/include ../gpu ../imbuf ../ikplugin ../blenfont' incs += ' ../render/extern/include' incs += ' ../freestyle' diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 9343459e061..ac744ae835e 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -54,6 +54,7 @@ INCLUDE_DIRECTORIES( ../../makesdna ../../blenkernel ../../blenlib + ../../blenfont ../../ikplugin ../../windowmanager ../../editors/include @@ -70,10 +71,6 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_GAMEENGINE) ADD_DEFINITIONS(-DWITH_GAMEENGINE) ENDIF(WITH_GAMEENGINE) diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile index 69d5581184d..2ff2c0d7eb3 100644 --- a/source/blender/makesrna/intern/Makefile +++ b/source/blender/makesrna/intern/Makefile @@ -52,6 +52,7 @@ CPPFLAGS += -I$(NAN_MEMUTIL)/include CPPFLAGS += -I../../../../intern/audaspace/intern CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../blenfont CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../ikplugin CPPFLAGS += -I../../makesdna diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index ec588319eae..ac71e292552 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -31,7 +31,7 @@ defs = [] incs = '#/intern/guardedalloc ../../blenlib ../../blenkernel' incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin' -incs += ' ../../windowmanager ../../editors/include' +incs += ' ../../windowmanager ../../editors/include ../../blenfont' incs += ' ../../render/extern/include' incs += ' #/intern/audaspace/intern ' diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index f1dfaacf932..00c3f924c27 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -292,7 +292,12 @@ static const char *rna_type_type_name(PropertyRNA *prop) case PROP_FLOAT: return "float"; case PROP_STRING: - return "char*"; + if(prop->flag & PROP_THICK_WRAP) { + return "char*"; + } + else { + return "const char*"; + } default: return NULL; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 0144a0c1bdf..1cac7aefdfa 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -56,6 +56,8 @@ #include "rna_internal.h" +const PointerRNA PointerRNA_NULL= {{0}}; + /* Init/Exit */ void RNA_init() @@ -90,8 +92,6 @@ void RNA_exit() /* Pointer */ -PointerRNA PointerRNA_NULL = {{0}, 0, 0}; - void RNA_main_pointer_create(struct Main *main, PointerRNA *r_ptr) { r_ptr->id.data= NULL; @@ -168,9 +168,8 @@ void RNA_blender_rna_pointer_create(PointerRNA *r_ptr) PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data) { - PointerRNA result; - if(data) { + PointerRNA result; result.data= data; result.type= type; rna_pointer_inherit_id(type, ptr, &result); @@ -183,11 +182,11 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da else result.type= type; } + return result; + } + else { + return PointerRNA_NULL; } - else - memset(&result, 0, sizeof(result)); - - return result; } /**/ @@ -531,7 +530,7 @@ int RNA_struct_is_a(StructRNA *type, StructRNA *srna) PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier) { - if(identifier[0]=='[' && ELEM(identifier[1], '"', '\'')) { // " (dummy comment to avoid confusing some function lists in text editors) + if(identifier[0]=='[' && identifier[1]=='"') { // " (dummy comment to avoid confusing some function lists in text editors) /* id prop lookup, not so common */ PropertyRNA *r_prop= NULL; PointerRNA r_ptr; /* only support single level props */ @@ -1972,8 +1971,7 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) return RNA_property_pointer_get(ptr, prop); } else { - PointerRNA result= {{0}}; - return result; + return PointerRNA_NULL; } } @@ -2883,7 +2881,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int /* 2 kinds of lookups now, quoted or unquoted */ quote= *p; - if(quote != '\'' && quote != '"') + if(quote != '"') quote= 0; if(quote==0) { @@ -2962,14 +2960,6 @@ static int rna_token_strip_quotes(char *token) return 1; } } - else if(token[0]=='\'') { - int len = strlen(token); - if (len >= 2 && token[len-1]=='\'') { - /* strip away "" */ - token[len-1]= '\0'; - return 1; - } - } return 0; } @@ -3561,12 +3551,9 @@ PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name) return RNA_property_pointer_get(ptr, prop); } else { - PointerRNA result; - printf("RNA_pointer_get: %s.%s not found.\n", ptr->type->identifier, name); - memset(&result, 0, sizeof(result)); - return result; + return PointerRNA_NULL; } } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index d5f494ebbfb..5077db345dc 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -59,7 +59,7 @@ static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter) iter->valid= (internal->link != NULL); } -static bActionGroup *rna_Action_groups_new(bAction *act, char name[]) +static bActionGroup *rna_Action_groups_new(bAction *act, const char name[]) { return action_groups_add_new(act, name); } @@ -89,7 +89,7 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionG MEM_freeN(agrp); } -static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, char *data_path, int index, char *group) +static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path, int index, const char *group) { if(group && group[0]=='\0') group= NULL; @@ -128,7 +128,7 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve * } } -static TimeMarker *rna_Action_pose_markers_new(bAction *act, ReportList *reports, char name[]) +static TimeMarker *rna_Action_pose_markers_new(bAction *act, ReportList *reports, const char name[]) { TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag= 1; diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 49df68d6681..2fa93bcecdd 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include "RNA_define.h" +#include "RNA_access.h" #include "rna_internal.h" #include "DNA_constraint_types.h" @@ -360,7 +361,7 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre Object *ob= NULL; int totitem= 0; - if (ptr->type == &RNA_Actuator) { + if (ptr->type==&RNA_Actuator || RNA_struct_is_a(ptr->type, &RNA_Actuator)){ ob = (Object *)ptr->id.data; } else { /* can't use ob from ptr->id.data because that enum is also used by operators */ @@ -669,7 +670,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Loc", "Sets the location"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "offset_rotation", PROP_FLOAT, PROP_XYZ); + prop= RNA_def_property(srna, "offset_rotation", PROP_FLOAT, PROP_EULER); RNA_def_property_float_sdna(prop, NULL, "drot"); RNA_def_property_array(prop, 3); RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 2); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index e872037db2a..85f070b3162 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -321,7 +321,7 @@ static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr) static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *reports, - ID *id, char rna_path[], int index, int group_method, char group_name[]) + ID *id, const char rna_path[], int index, int group_method, const char group_name[]) { KS_Path *ksp = NULL; short flag = 0; diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 25ac6f5e558..444c2be67cf 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -93,7 +93,7 @@ static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value) } } -EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, char *name) +EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const char *name) { if(arm->edbo==NULL) { BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant add an editbone.", arm->id.name+2); @@ -117,6 +117,20 @@ void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone ED_armature_edit_bone_remove(arm, ebone); } +static void rna_Armature_update_layers(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bArmature *arm= ptr->id.data; + Object *ob; + + /* proxy lib exception, store it here so we can restore layers on file + load, since it would otherwise get lost due to being linked data */ + for(ob = bmain->object.first; ob; ob=ob->id.next) + if(ob->data == arm && ob->pose) + ob->pose->proxy_layer = arm->layer; + + WM_main_add_notifier(NC_GEOM|ND_DATA, arm); +} + static void rna_Armature_redraw_data(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id= ptr->id.data; @@ -785,6 +799,7 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_pose_position_items); RNA_def_property_ui_text(prop, "Pose Position", "Show armature in binding pose or final posed state"); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); + RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); prop= RNA_def_property(srna, "draw_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "drawtype"); @@ -809,7 +824,7 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_array(prop, 32); RNA_def_property_ui_text(prop, "Visible Layers", "Armature layer visibility"); RNA_def_property_boolean_funcs(prop, NULL, "rna_Armature_layer_set"); - RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Armature_redraw_data"); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Armature_update_layers"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); /* layer protection */ diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c index 4e161e5b22e..a2b765e9959 100644 --- a/source/blender/makesrna/intern/rna_armature_api.c +++ b/source/blender/makesrna/intern/rna_armature_api.c @@ -38,20 +38,15 @@ #include "BLI_blenlib.h" #include "BKE_armature.h" -void rna_EditBone_align_roll(EditBone *ebo, float *no) +void rna_EditBone_align_roll(EditBone *ebo, float no[3]) { - if(!is_zero_v3(no)) { - float normal[3]; - copy_v3_v3(normal, no); - normalize_v3(normal); - ebo->roll= ED_rollBoneToVector(ebo, normal); - } + ebo->roll= ED_rollBoneToVector(ebo, no, FALSE); } float rna_Bone_do_envelope(Bone *bone, float *vec) { float scale = (bone->flag & BONE_MULT_VG_ENV) == BONE_MULT_VG_ENV ? bone->weight : 1.0f; - return distfactor_to_bone(vec, bone->head, bone->tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); + return distfactor_to_bone(vec, bone->arm_head, bone->arm_tail, bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); } #else diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 8cd6fcbeff9..b77f40a31f3 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -175,6 +175,26 @@ static void rna_BoidState_active_boid_rule_index_set(struct PointerRNA *ptr, int } } +static int particle_id_check(PointerRNA *ptr) +{ + ID *id= ptr->id.data; + + return (GS(id->name) == ID_PA); +} + +static char *rna_BoidSettings_path(PointerRNA *ptr) +{ + BoidSettings *boids = (BoidSettings *)ptr->data; + + if(particle_id_check(ptr)) { + ParticleSettings *part = (ParticleSettings*)ptr->id.data; + + if (part->boids == boids) + return BLI_sprintfN("boids"); + } + return NULL; +} + static PointerRNA rna_BoidSettings_active_boid_state_get(PointerRNA *ptr) { BoidSettings *boids= (BoidSettings*)ptr->data; @@ -466,6 +486,7 @@ static void rna_def_boid_settings(BlenderRNA *brna) PropertyRNA *prop; srna = RNA_def_struct(brna, "BoidSettings", NULL); + RNA_def_struct_path_func(srna, "rna_BoidSettings_path"); RNA_def_struct_ui_text(srna, "Boid Settings", "Settings for boid physics"); prop= RNA_def_property(srna, "land_smooth", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 7f6ab4720fa..b0d93bcd09a 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -117,8 +117,8 @@ void RNA_def_camera(BlenderRNA *brna) prop= RNA_def_property(srna, "draw_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "drawsize"); - RNA_def_property_range(prop, 0.1f, 1000.0f); - RNA_def_property_ui_range(prop, 0.01, 100, 1, 1); + RNA_def_property_range(prop, 0.01f, 1000.0f); + RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); RNA_def_property_ui_text(prop, "Draw Size", "Apparent size of the Camera object in the 3D View"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index dee12d43144..ffc42eb97e4 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -324,6 +324,47 @@ static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const flo memcpy(ikData->points, values, ikData->numpoints * sizeof(float)); } +/* Array Get/Set Functions for RigidBodyJointConstraint Min/Max Cone Limits */ +void rna_RigidBodyJointConstraint_limit_cone_min_get(PointerRNA *ptr, float values[3]) +{ + bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint*)(((bConstraint*)ptr->data)->data); + float *limit = data->minLimit; + + values[0]= limit[3]; + values[1]= limit[4]; + values[2]= limit[5]; +} + +static void rna_RigidBodyJointConstraint_limit_cone_min_set(PointerRNA *ptr, const float values[3]) +{ + bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint*)(((bConstraint*)ptr->data)->data); + float *limit = data->minLimit; + + limit[3]= values[0]; + limit[4]= values[1]; + limit[5]= values[2]; +} + +void rna_RigidBodyJointConstraint_limit_cone_max_get(PointerRNA *ptr, float values[3]) +{ + bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint*)(((bConstraint*)ptr->data)->data); + float *limit = data->maxLimit; + + values[0]= limit[3]; + values[1]= limit[4]; + values[2]= limit[5]; +} + +static void rna_RigidBodyJointConstraint_limit_cone_max_set(PointerRNA *ptr, const float values[3]) +{ + bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint*)(((bConstraint*)ptr->data)->data); + float *limit = data->maxLimit; + + limit[3]= values[0]; + limit[4]= values[1]; + limit[5]= values[2]; +} + #else EnumPropertyItem constraint_distance_items[] = { @@ -1241,26 +1282,76 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) RNA_def_property_range(prop, -M_PI*2, M_PI*2); RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis in degrees"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_linked_collision", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE_LINKED_COLLISION); + RNA_def_property_ui_text(prop, "Disable Linked Collision", "Disable collision between linked bodies"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "show_pivot", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DRAW_PIVOT); + RNA_def_property_ui_text(prop, "Draw Pivot", "Display the pivot point and rotation in 3D view"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + - prop= RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE); + /* Limit */ + + /* Limit Min/Max for genereic 6 DoF */ + prop= RNA_def_property(srna, "limit_generic_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "minLimit"); RNA_def_property_array(prop, 6); RNA_def_property_ui_text(prop, "Minimum Limit", ""); - prop= RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "limit_generic_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "maxLimit"); RNA_def_property_array(prop, 6); RNA_def_property_ui_text(prop, "Maximum Limit", ""); + + /* Limit Min/Max for Cone Twist */ + prop= RNA_def_property(srna, "limit_cone_min", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minLimit"); + RNA_def_property_float_funcs(prop, "rna_RigidBodyJointConstraint_limit_cone_min_get", "rna_RigidBodyJointConstraint_limit_cone_min_set", NULL); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Minimum Limit", ""); - prop= RNA_def_property(srna, "use_linked_collision", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE_LINKED_COLLISION); - RNA_def_property_ui_text(prop, "Disable Linked Collision", "Disable collision between linked bodies"); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + prop= RNA_def_property(srna, "limit_cone_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxLimit"); + RNA_def_property_float_funcs(prop, "rna_RigidBodyJointConstraint_limit_cone_max_get", "rna_RigidBodyJointConstraint_limit_cone_max_set", NULL); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Maximum Limit", ""); - prop= RNA_def_property(srna, "show_pivot", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DRAW_PIVOT); - RNA_def_property_ui_text(prop, "Draw Pivot", "Display the pivot point and rotation in 3D view"); + + /* Limit Booleans */ + prop= RNA_def_property(srna, "use_limit_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); + RNA_def_property_ui_text(prop, "Use X Limit", "Use minimum/maximum x limit"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_limit_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 2); + RNA_def_property_ui_text(prop, "Use Y Limit", "Use minimum/maximum y limit"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_limit_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 4); + RNA_def_property_ui_text(prop, "Use Z Limit", "Use minimum/maximum z limit"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_angular_limit_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 8); + RNA_def_property_ui_text(prop, "Use Angular X Limit", "Use minimum/maximum x angular limit"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_angular_limit_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 16); + RNA_def_property_ui_text(prop, "Use Angular Y Limit", "Use minimum/maximum y angular limit"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_angular_limit_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 32); + RNA_def_property_ui_text(prop, "Use Angular Z Limit", "Use minimum/maximum z angular limit"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + } static void rna_def_constraint_clamp_to(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 9f59d3b8573..1972abfd3ec 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -77,6 +77,40 @@ EnumPropertyItem curve_type_items[] = { #include "ED_curve.h" /* for BKE_curve_nurbs */ +/* highly irritating but from RNA we cant know this */ +static Nurb *curve_nurb_from_point(Curve *cu, const void *point, int *nu_index, int *pt_index) +{ + ListBase *nurbs= BKE_curve_nurbs(cu); + Nurb *nu; + int i= 0; + + for(nu= nurbs->first; nu; nu= nu->next, i++) { + if(nu->type == CU_BEZIER) { + if(point >= (void *)nu->bezt && point < (void *)(nu->bezt + nu->pntsu)) { + break; + } + } + else { + if(point >= (void *)nu->bp && point < (void *)(nu->bp + (nu->pntsu * nu->pntsv))) { + break; + } + } + } + + if(nu) { + if(nu_index) { + *nu_index= i; + } + + if(pt_index) { + if(nu->type == CU_BEZIER) *pt_index= (int)((BezTriple *)point - nu->bezt); + else *pt_index= (int)((BPoint *)point - nu->bp); + } + } + + return nu; +} + static StructRNA *rna_Curve_refine(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->data; @@ -259,6 +293,17 @@ static void rna_Curve_update_deps(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Curve_update_data(bmain, scene, ptr); } +static void rna_Curve_update_points(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->id.data; + Nurb *nu= curve_nurb_from_point(cu, ptr->data, NULL, NULL); + + if(nu) + calchandlesNurb(nu); + + rna_Curve_update_data(bmain, scene, ptr); +} + static PointerRNA rna_Curve_bevelObject_get(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->id.data; @@ -499,7 +544,7 @@ static Nurb *rna_Curve_spline_new(Curve *cu, int type) nu->resolu= nu->resolv= 12; nu->flag= CU_SMOOTH; - BLI_addtail(&cu->nurb, nu); + BLI_addtail(BKE_curve_nurbs(cu), nu); return nu; } @@ -548,6 +593,43 @@ static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value) cu->actnu= BLI_findindex(nubase, nu); } +static char *rna_Curve_spline_path(PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->id.data; + ListBase *nubase= BKE_curve_nurbs(cu); + Nurb *nu= ptr->data; + int index= BLI_findindex(nubase, nu); + + if (index >= 0) + return BLI_sprintfN("splines[%d]", index); + else + return BLI_strdup(""); +} + +/* use for both bezier and nurbs */ +static char *rna_Curve_spline_point_path(PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->id.data; + Nurb *nu; + void *point= ptr->data; + int nu_index, pt_index; + + nu= curve_nurb_from_point(cu, point, &nu_index, &pt_index); + + if (nu) { + if(nu->type == CU_BEZIER) { + return BLI_sprintfN("splines[%d].bezier_points[%d]", nu_index, pt_index); + } + else { + return BLI_sprintfN("splines[%d].points[%d]", nu_index, pt_index); + } + } + else { + return BLI_strdup(""); + } +} + + static char *rna_TextBox_path(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->id.data; @@ -560,6 +642,12 @@ static char *rna_TextBox_path(PointerRNA *ptr) return BLI_strdup(""); } +static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->id.data; + rna_iterator_listbase_begin(iter, BKE_curve_nurbs(cu), NULL); +} + #else static void rna_def_bpoint(BlenderRNA *brna) @@ -609,10 +697,11 @@ static void rna_def_bpoint(BlenderRNA *brna) prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); - /*RNA_def_property_range(prop, 0.0f, 1.0f);*/ - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path"); } static void rna_def_beztriple(BlenderRNA *brna) @@ -650,32 +739,32 @@ static void rna_def_beztriple(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "h1"); RNA_def_property_enum_items(prop, beztriple_handle_type_items); RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + RNA_def_property_update(prop, 0, "rna_Curve_update_points"); prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h2"); RNA_def_property_enum_items(prop, beztriple_handle_type_items); RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + RNA_def_property_update(prop, 0, "rna_Curve_update_points"); /* Vector values */ prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL); RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + RNA_def_property_update(prop, 0, "rna_Curve_update_points"); prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL); RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + RNA_def_property_update(prop, 0, "rna_Curve_update_points"); prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL); RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + RNA_def_property_update(prop, 0, "rna_Curve_update_points"); /* Number values */ prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); @@ -691,10 +780,11 @@ static void rna_def_beztriple(BlenderRNA *brna) prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); - /*RNA_def_property_range(prop, 0.0f, 1.0f);*/ - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path"); } static void rna_def_path(BlenderRNA *brna, StructRNA *srna) @@ -1105,8 +1195,14 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "key"); RNA_def_property_ui_text(prop, "Shape Keys", ""); + prop= RNA_def_property(srna, "splines", PROP_COLLECTION, PROP_NONE); +#if 0 RNA_def_property_collection_sdna(prop, NULL, "nurb", NULL); +#else + /* this way we get editmode nurbs too, keyframe in editmode */ + RNA_def_property_collection_funcs(prop, "rna_Curve_splines_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); +#endif RNA_def_property_struct_type(prop, "Spline"); RNA_def_property_ui_text(prop, "Splines", "Collection of splines in this curve data object"); rna_def_curve_splines(brna, prop); @@ -1153,7 +1249,7 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 64, 1, 0); RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction"); RNA_def_property_update(prop, 0, "rna_Curve_resolution_u_update_data"); @@ -1161,20 +1257,20 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); RNA_def_property_ui_range(prop, 1, 64, 1, 0); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction"); RNA_def_property_update(prop, 0, "rna_Curve_resolution_v_update_data"); prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu_ren"); - RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_range(prop, 0, 64, 1, 0); RNA_def_property_ui_text(prop, "Render Resolution U", "Surface resolution in U direction used while rendering. Zero skips this property"); prop= RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv_ren"); RNA_def_property_ui_range(prop, 0, 64, 1, 0); - RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering. Zero skips this property"); @@ -1353,14 +1449,14 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 64, 1, 0); RNA_def_property_ui_text(prop, "Resolution U", "Curve or Surface subdivisions per segment"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 64, 1, 0); RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); @@ -1419,6 +1515,8 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_ui_text(prop, "Character Index", "Location of this character in the text data (only for text curves)"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + RNA_def_struct_path_func(srna, "rna_Curve_spline_path"); } void RNA_def_curve(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 68060e2cfe3..025c3b81efc 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -42,6 +42,7 @@ #include "BKE_depsgraph.h" #include "BKE_fluidsim.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_particle.h" @@ -79,6 +80,38 @@ static void rna_fluid_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob); } +static int fluidsim_find_lastframe(FluidsimSettings *fss) +{ + char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; + int curFrame = 1; + + strncpy(targetDir, fss->surfdataPath, FILE_MAXDIR); + strcat(targetDir,"fluidsurface_final_####"); + BLI_path_abs(targetDir, G.main->name); + + do { + strcpy(targetFile,targetDir); + BLI_path_frame(targetFile, curFrame++, 0); + strcat(targetFile, ".bobj.gz"); + } while(BLI_exist(targetFile)); + + return curFrame - 1; +} + +static void rna_fluid_find_enframe(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Object *ob= ptr->id.data; + FluidsimModifierData *fluidmd= (FluidsimModifierData*)modifiers_findByType(ob, eModifierType_Fluidsim); + + if(fluidmd->fss->flag & OB_FLUIDSIM_REVERSE) { + fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(fluidmd->fss); + } + else { + fluidmd->fss->lastgoodframe = -1; + } + rna_fluid_update(bmain, scene, ptr); +} + static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; @@ -231,6 +264,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) prop= RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse fluid frames"); + RNA_def_property_update(prop, 0, "rna_fluid_find_enframe"); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_maxlength(prop, 240); @@ -527,6 +561,7 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse control object movement"); + RNA_def_property_update(prop, 0, "rna_fluid_find_enframe"); } void RNA_def_fluidsim(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 62e7b516e9e..3874103ef7a 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -280,7 +280,7 @@ static void rna_def_imageuser(BlenderRNA *brna) prop= RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "fie_ima"); - RNA_def_property_range(prop, 1, MAXFRAMEF); + RNA_def_property_range(prop, 1, 200); RNA_def_property_ui_text(prop, "Fields per Frame", "The number of fields per rendered frame (2 fields is 1 image)"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 6e495c5db8e..699b21e840e 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -53,7 +53,7 @@ #include "MEM_guardedalloc.h" -static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports, char *path, Scene *scene) +static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports, const char *path, Scene *scene) { ImBuf *ibuf; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 0a82cbc1c42..a121ac1fbc3 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -80,12 +80,12 @@ #include "ED_screen.h" -Tex *rna_Main_add_texture(Main *bmain, char *name) +Tex *rna_Main_add_texture(Main *bmain, const char *name) { return add_texture(name); } -Camera *rna_Main_cameras_new(Main *bmain, char* name) +Camera *rna_Main_cameras_new(Main *bmain, const char *name) { ID *id= add_camera(name); id->us--; @@ -101,7 +101,7 @@ void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *ca /* XXX python now has invalid pointer? */ } -Scene *rna_Main_scenes_new(Main *bmain, char* name) +Scene *rna_Main_scenes_new(Main *bmain, const char *name) { return add_scene(name); } @@ -119,12 +119,13 @@ void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struc return; } - ED_screen_set_scene(C, newscene); + if(CTX_wm_screen(C)->scene == scene) + ED_screen_set_scene(C, newscene); unlink_scene(bmain, scene, newscene); } -Object *rna_Main_objects_new(Main *bmain, ReportList *reports, char* name, ID *data) +Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char *name, ID *data) { Object *ob; int type= OB_EMPTY; @@ -185,7 +186,7 @@ void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *ob } } -struct Material *rna_Main_materials_new(Main *bmain, char* name) +struct Material *rna_Main_materials_new(Main *bmain, const char *name) { ID *id= (ID *)add_material(name); id->us--; @@ -218,7 +219,7 @@ void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree /* XXX python now has invalid pointer? */ } -Mesh *rna_Main_meshes_new(Main *bmain, char* name) +Mesh *rna_Main_meshes_new(Main *bmain, const char *name) { Mesh *me= add_mesh(name); me->id.us--; @@ -234,7 +235,7 @@ void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) /* XXX python now has invalid pointer? */ } -Lamp *rna_Main_lamps_new(Main *bmain, char* name) +Lamp *rna_Main_lamps_new(Main *bmain, const char *name) { Lamp *lamp= add_lamp(name); lamp->id.us--; @@ -250,14 +251,14 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) /* XXX python now has invalid pointer? */ } -Image *rna_Main_images_new(Main *bmain, char* name, int width, int height, int alpha, int float_buffer) +Image *rna_Main_images_new(Main *bmain, const char *name, int width, int height, int alpha, int float_buffer) { float color[4]= {0.0, 0.0, 0.0, 1.0}; Image *image= BKE_add_image_size(width, height, name, alpha ? 32:24, float_buffer, 0, color); image->id.us--; return image; } -Image *rna_Main_images_load(Main *bmain, ReportList *reports, char *filepath) +Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath) { Image *ima; @@ -279,7 +280,7 @@ void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) /* XXX python now has invalid pointer? */ } -Lattice *rna_Main_lattices_new(Main *bmain, char* name) +Lattice *rna_Main_lattices_new(Main *bmain, const char *name) { Lattice *lt= add_lattice(name); lt->id.us--; @@ -293,7 +294,7 @@ void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice * BKE_reportf(reports, RPT_ERROR, "Lattice \"%s\" must have zero users to be removed, found %d.", lt->id.name+2, ID_REAL_USERS(lt)); } -Curve *rna_Main_curves_new(Main *bmain, char* name, int type) +Curve *rna_Main_curves_new(Main *bmain, const char *name, int type) { Curve *cu= add_curve(name, type); cu->id.us--; @@ -307,7 +308,7 @@ void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d.", cu->id.name+2, ID_REAL_USERS(cu)); } -MetaBall *rna_Main_metaballs_new(Main *bmain, char* name) +MetaBall *rna_Main_metaballs_new(Main *bmain, const char *name) { MetaBall *mb= add_mball(name); mb->id.us--; @@ -321,7 +322,7 @@ void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall BKE_reportf(reports, RPT_ERROR, "MetaBall \"%s\" must have zero users to be removed, found %d.", mb->id.name+2, ID_REAL_USERS(mb)); } -VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, char *filepath) +VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath) { VFont *font; @@ -344,7 +345,7 @@ void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) /* XXX python now has invalid pointer? */ } -Tex *rna_Main_textures_new(Main *bmain, char* name, int type) +Tex *rna_Main_textures_new(Main *bmain, const char *name, int type) { Tex *tex= add_texture(name); tex_set_type(tex, type); @@ -359,7 +360,7 @@ void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d.", tex->id.name+2, ID_REAL_USERS(tex)); } -Brush *rna_Main_brushes_new(Main *bmain, char* name) +Brush *rna_Main_brushes_new(Main *bmain, const char *name) { Brush *brush = add_brush(name); brush->id.us--; @@ -373,7 +374,7 @@ void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *bru BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d.", brush->id.name+2, ID_REAL_USERS(brush)); } -World *rna_Main_worlds_new(Main *bmain, char* name) +World *rna_Main_worlds_new(Main *bmain, const char *name) { World *world = add_world(name); world->id.us--; @@ -387,7 +388,7 @@ void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *worl BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d.", world->id.name+2, ID_REAL_USERS(world)); } -Group *rna_Main_groups_new(Main *bmain, char* name) +Group *rna_Main_groups_new(Main *bmain, const char *name) { return add_group(name); } @@ -398,7 +399,7 @@ void rna_Main_groups_remove(Main *bmain, ReportList *reports, Group *group) /* XXX python now has invalid pointer? */ } -Text *rna_Main_texts_new(Main *bmain, char* name) +Text *rna_Main_texts_new(Main *bmain, const char *name) { return add_empty_text(name); } @@ -409,7 +410,7 @@ void rna_Main_texts_remove(Main *bmain, ReportList *reports, Text *text) /* XXX python now has invalid pointer? */ } -Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* filepath) +Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath) { Text *txt; @@ -422,7 +423,7 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* filepath) return txt; } -bArmature *rna_Main_armatures_new(Main *bmain, char* name) +bArmature *rna_Main_armatures_new(Main *bmain, const char *name) { bArmature *arm= add_armature(name); arm->id.us--; @@ -438,7 +439,7 @@ void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) /* XXX python now has invalid pointer? */ } -bAction *rna_Main_actions_new(Main *bmain, char* name) +bAction *rna_Main_actions_new(Main *bmain, const char *name) { bAction *act= add_empty_action(name); act->id.us--; @@ -455,7 +456,7 @@ void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) /* XXX python now has invalid pointer? */ } -ParticleSettings *rna_Main_particles_new(Main *bmain, char* name) +ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) { ParticleSettings *part = psys_new_settings(name, bmain); part->id.us--; diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index c238ed6991d..3ec9d9f32ba 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1425,8 +1425,10 @@ static void rna_def_material_strand(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Tangent Shading", "Uses direction of strands as normal for tangent-shading"); RNA_def_property_update(prop, 0, "rna_Material_update"); + /* this flag is only set when rendering, not to be edited manually */ prop= RNA_def_property(srna, "use_surface_diffuse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface"); RNA_def_property_update(prop, 0, "rna_Material_update"); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 8d16c705d96..7b49edb9158 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1064,7 +1064,7 @@ static int rna_Mesh_tot_face_get(PointerRNA *ptr) return me->edit_mesh ? me->edit_mesh->totfacesel : 0; } -static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, char *name) +static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name) { CustomData *fdata; CustomDataLayer *cdl= NULL; @@ -1078,7 +1078,7 @@ static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bConte return cdl; } -static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, char *name) +static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name) { CustomData *fdata; CustomDataLayer *cdl= NULL; diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 18dfd05b971..6fb8f159758 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -138,14 +139,6 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Meta #else -static EnumPropertyItem metaelem_type_items[] = { - {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""}, - {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""}, - {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""}, - {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, // NOTE: typo at original definition! - {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""}, - {0, NULL, 0, NULL, NULL}}; - static void rna_def_metaelement(BlenderRNA *brna) { StructRNA *srna; @@ -155,7 +148,7 @@ static void rna_def_metaelement(BlenderRNA *brna) RNA_def_struct_sdna(srna, "MetaElem"); RNA_def_struct_ui_text(srna, "Meta Element", "Blobby element in a MetaBall datablock"); RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_META); - + /* enums */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, metaelem_type_items); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index a434eb645cd..1b9cdc5a482 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -992,36 +992,36 @@ static void rna_def_modifier_armature(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); - prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); - RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name"); - RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureModifier_vgroup_set"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop= RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); - RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + prop= RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); + RNA_def_property_ui_text(prop, "Use Bone Envelopes", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); RNA_def_property_ui_text(prop, "Use Vertex Groups", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop= RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); - RNA_def_property_ui_text(prop, "Use Bone Envelopes", ""); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - + prop= RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION); - RNA_def_property_ui_text(prop, "Quaternion", "Deform rotation interpolation with quaternions"); + RNA_def_property_ui_text(prop, "Preserve Volume", "Deform rotation interpolation with quaternions"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_multi_modifier", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "multi", 0); RNA_def_property_ui_text(prop, "Multi Modifier", "Use same input as previous modifier, and mix results using overall vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "vertex_group_multi_modifier", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureModifier_vgroup_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "invert_vertex_group_multi_modifier", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_hook(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 7a382f537a6..45cc0394f16 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1128,7 +1128,7 @@ static void def_cmp_output_file(StructRNA *srna) {0, "NONE", 0, "None", ""}, {1, "PXR24", 0, "Pxr24 (lossy)", ""}, {2, "ZIP", 0, "ZIP (lossless)", ""}, - {3, "PIZ", 0, "PIX (lossless)", ""}, + {3, "PIZ", 0, "PIZ (lossless)", ""}, {4, "RLE", 0, "RLE (lossless)", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index fab30668a5b..37459db7280 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -40,6 +40,7 @@ #include "DNA_object_types.h" #include "DNA_property_types.h" #include "DNA_scene_types.h" +#include "DNA_meta_types.h" #include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */ #include "ED_mesh.h" @@ -80,6 +81,14 @@ static EnumPropertyItem collision_bounds_items[] = { //{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem metaelem_type_items[] = { + {MB_BALL, "BALL", ICON_META_BALL, "Ball", ""}, + {MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""}, + {MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""}, + {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""}, // NOTE: typo at original definition! + {MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""}, + {0, NULL, 0, NULL, NULL}}; + /* used for 2 enums */ #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""} #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""} @@ -1062,7 +1071,7 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, b WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT, object); } -static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, char *name, int type) +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); } @@ -1132,7 +1141,7 @@ static void rna_def_vertex_group(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Vertex group name"); RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, NULL); + RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */ prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 3c8fb5ab871..34e3caad618 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -281,7 +281,7 @@ static void rna_Object_update(Object *ob, Scene *sce, int object, int data, int DAG_id_flush_update(&ob->id, flag); } -static PointerRNA rna_Object_add_shape_key(Object *ob, bContext *C, ReportList *reports, char *name, int from_mix) +static PointerRNA rna_Object_add_shape_key(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix) { Scene *scene= CTX_data_scene(C); KeyBlock *kb= NULL; @@ -343,7 +343,7 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3], float r_location[3], float r_normal[3], int *index) { - BVHTreeFromMesh treeData; + BVHTreeFromMesh treeData= {0}; if(ob->derivedFinal==NULL) { BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting.", ob->id.name+2); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 7a8165e9aa5..e8088caec03 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -518,6 +518,27 @@ static void rna_ParticleTarget_name_get(PointerRNA *ptr, char *str) else strcpy(str, "Invalid target!"); } + +static int particle_id_check(PointerRNA *ptr) +{ + ID *id= ptr->id.data; + + return (GS(id->name) == ID_PA); +} + +static char *rna_SPHFluidSettings_path(PointerRNA *ptr) +{ + SPHFluidSettings *fluid = (SPHFluidSettings *)ptr->data; + + if(particle_id_check(ptr)) { + ParticleSettings *part = (ParticleSettings*)ptr->id.data; + + if (part->fluid == fluid) + return BLI_sprintfN("fluid"); + } + return NULL; +} + static int rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr) { ParticleSystem *psys= (ParticleSystem*)ptr->data; @@ -942,7 +963,7 @@ static void rna_def_particle_dupliweight(BlenderRNA *brna) RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED); - RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_range(prop, 0, SHRT_MAX); RNA_def_property_ui_text(prop, "Count", "The number of times this object is repeated with respect to other objects"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); } @@ -953,6 +974,7 @@ static void rna_def_fluid_settings(BlenderRNA *brna) PropertyRNA *prop; srna = RNA_def_struct(brna, "SPHFluidSettings", NULL); + RNA_def_struct_path_func(srna, "rna_SPHFluidSettings_path"); RNA_def_struct_ui_text(srna, "SPH Fluid Settings", "Settings for particle fluids physics"); /* Fluid settings */ @@ -960,7 +982,7 @@ static void rna_def_fluid_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "spring_k"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Spring", "Spring force constant"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop= RNA_def_property(srna, "fluid_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); @@ -1396,7 +1418,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "draw_size", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 1000); - RNA_def_property_ui_range(prop, 1, 100, 1, 0); + RNA_def_property_ui_range(prop, 0, 100, 1, 0); RNA_def_property_ui_text(prop, "Draw Size", "Size of particles on viewport in pixels (0=default)"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); @@ -1426,7 +1448,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) //TODO: not found in UI, readonly? prop= RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, INT_MAX);//TODO:min,max + RNA_def_property_range(prop, 0, SHRT_MAX);//TODO:min,max RNA_def_property_ui_text(prop, "Keys Step", ""); /* adaptive path rendering */ @@ -1948,18 +1970,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_range(prop, 1.0f, 100.0f, 0.1, 3); RNA_def_property_ui_text(prop, "Loop count", "Number of times the keys are looped"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - - /* boids */ - prop= RNA_def_property(srna, "boids", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "BoidSettings"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Boid Settings", ""); - - /* Fluid particles */ - prop= RNA_def_property(srna, "fluid", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "SPHFluidSettings"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "SPH Fluid Settings", ""); /* draw objects & groups */ prop= RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); @@ -1997,6 +2007,19 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Billboard Object", "Billboards face this object (default is active camera)"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); + /* boids */ + prop= RNA_def_property(srna, "boids", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "BoidSettings"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Boid Settings", ""); + + /* Fluid particles */ + prop= RNA_def_property(srna, "fluid", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SPHFluidSettings"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "SPH Fluid Settings", ""); + + /* Effector weights */ prop= RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "EffectorWeights"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -2142,7 +2165,7 @@ static void rna_def_particle_system(BlenderRNA *brna) prop= RNA_def_property(srna, "reactor_target_particle_system", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "target_psys"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Reactor Target Particle System", "For reactor systems, index of particle system on the target object"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); @@ -2347,10 +2370,9 @@ static void rna_def_particle_system(BlenderRNA *brna) void RNA_def_particle(BlenderRNA *brna) { rna_def_particle_target(brna); - + rna_def_fluid_settings(brna); rna_def_particle_hair_key(brna); rna_def_particle_key(brna); - rna_def_fluid_settings(brna); rna_def_child_particle(brna); rna_def_particle(brna); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 81b0df1d840..3152fc04b0d 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -115,11 +115,12 @@ static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data) /* function to skip any id properties that are already known by RNA, * for the second loop where we go over unknown id properties */ + do { + for(prop= ptype->cont.properties.first; prop; prop=prop->next) + if((prop->flag & PROP_BUILTIN) == 0 && strcmp(prop->identifier, idprop->name) == 0) + return 1; + } while((ptype=ptype->base)); - for(prop= ptype->cont.properties.first; prop; prop=prop->next) - if(strcmp(prop->identifier, idprop->name) == 0) - return 1; - return 0; } @@ -303,9 +304,8 @@ PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key { StructRNA *srna; PropertyRNA *prop; - PointerRNA propptr; + PointerRNA propptr= {{0}}; - memset(&propptr, 0, sizeof(propptr)); srna= ptr->type; do { diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b12e8552ef6..f44f018a939 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -936,7 +936,7 @@ static void rna_GameSettings_auto_start_set(PointerRNA *ptr, int value) } -static TimeMarker *rna_TimeLine_add(Scene *scene, char name[]) +static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) { TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag= SELECT; @@ -958,7 +958,7 @@ static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *m MEM_freeN(marker); } -static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, char name[]) +static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char name[]) { KeyingSet *ks= NULL; @@ -1259,7 +1259,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "etch_subdivision_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "skgen_subdivision_number"); - RNA_def_property_range(prop, 1, 10000); + RNA_def_property_range(prop, 1, 255); RNA_def_property_ui_text(prop, "Subdivisions", "Number of bones in the subdivided stroke"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); @@ -1324,6 +1324,11 @@ static void rna_def_unit_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, unit_systems); RNA_def_property_ui_text(prop, "Unit System", "The unit system to use for button display"); RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "system_rotation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rotation_units); + RNA_def_property_ui_text(prop, "Rotation Units", "Unit to use for displaying/editing rotation values"); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "scale_length", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, "Unit Scale", "Scale to use when converting between blender units and dimensions"); @@ -1335,12 +1340,6 @@ static void rna_def_unit_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_UNIT_OPT_SPLIT); RNA_def_property_ui_text(prop, "Separate Units", "Display units in pairs"); RNA_def_property_update(prop, NC_WINDOW, NULL); - - prop= RNA_def_property(srna, "rotation_units", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, rotation_units); - RNA_def_property_ui_text(prop, "Rotation Units", "Unit to use for displaying/editing rotation values"); - RNA_def_property_update(prop, NC_WINDOW, NULL); } void rna_def_render_layer_common(StructRNA *srna, int scene) diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index cea0653172f..f14b57e2b33 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -55,7 +55,12 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME); scene_update_for_newframe(G.main, scene, (1<<20) - 1); - WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); + /* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call + * scene_update_for_newframe which will loose any un-keyed changes [#24690] */ + /* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */ + + /* instead just redraw the views */ + WM_main_add_notifier(NC_WINDOW, NULL); } static void rna_Scene_update_tagged(Scene *scene) @@ -75,7 +80,7 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name #include "../../collada/collada.h" -static void rna_Scene_collada_export(Scene *scene, char *filepath) +static void rna_Scene_collada_export(Scene *scene, const char *filepath) { /* XXX not really nice, as this will bring essentially in COLLADA as dependency for * blenderplayer. For now stubbing in blc. */ diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index d6964f5d569..197a7266fea 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -176,6 +176,8 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "winy"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Height", "Region height"); + + RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw"); } static void rna_def_screen(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 8f83e0b39a4..735dd58252b 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -420,7 +420,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop= RNA_def_property(srna, "default_key_count", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "totaddkey"); - RNA_def_property_range(prop, 2, INT_MAX); + RNA_def_property_range(prop, 2, SHRT_MAX); RNA_def_property_ui_range(prop, 2, 20, 10, 3); RNA_def_property_ui_text(prop, "Keys", "How many keys to make new particles with"); @@ -467,7 +467,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush"); prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 3); RNA_def_property_ui_text(prop, "Size", "Brush size"); @@ -482,7 +482,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop= RNA_def_property(srna, "steps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "step"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 50, 10, 3); RNA_def_property_ui_text(prop, "Steps", "Brush steps"); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 6281460d3ad..47a619f661a 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -26,6 +26,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" +#include "RNA_access.h" #include "rna_internal.h" @@ -115,7 +116,7 @@ EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) Object *ob=NULL; int totitem= 0; - if (ptr->type == &RNA_Sensor) { + if (ptr->type == &RNA_Sensor || RNA_struct_is_a(ptr->type, &RNA_Sensor)) { ob = (Object *)ptr->id.data; } else { /* can't use ob from ptr->id.data because that enum is also used by operators */ @@ -606,12 +607,12 @@ static void rna_def_radar_sensor(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem axis_items[] ={ - {SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""}, - {SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""}, - {SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""}, - {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""}, - {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""}, - {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""}, + {SENS_RADAR_X_AXIS, "XAXIS", 0, "+X axis", ""}, + {SENS_RADAR_Y_AXIS, "YAXIS", 0, "+Y axis", ""}, + {SENS_RADAR_Z_AXIS, "ZAXIS", 0, "+Z axis", ""}, + {SENS_RADAR_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""}, + {SENS_RADAR_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""}, + {SENS_RADAR_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RadarSensor", "Sensor"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 681de0dc792..f56440d9c13 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -180,6 +180,19 @@ static int rna_Sequence_frame_length_get(PointerRNA *ptr) return seq_tx_get_final_right(seq, 0)-seq_tx_get_final_left(seq, 0); } +static int rna_Sequence_orx_get(PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + return seq->strip->orx; +} + +static int rna_Sequence_ory_get(PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + return seq->strip->ory; +} + + static void rna_Sequence_channel_set(PointerRNA *ptr, int value) { Sequence *seq= (Sequence*)ptr->data; @@ -1187,6 +1200,16 @@ static void rna_def_input(StructRNA *srna) RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_anim_endofs_final_set", NULL); // overlap tests RNA_def_property_ui_text(prop, "Animation End Offset", "Animation end offset (trim end)"); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + + prop= RNA_def_property(srna, "orig_width", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Orig Width", "Original image width"); + RNA_def_property_int_funcs(prop, "rna_Sequence_orx_get", NULL,NULL); + + prop= RNA_def_property(srna, "orig_height", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Orig Height", "Original image height"); + RNA_def_property_int_funcs(prop, "rna_Sequence_ory_get", NULL,NULL); } static void rna_def_image(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 45ad7700229..0697ce8d056 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1079,13 +1079,13 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_range(prop, 1.0f, FLT_MAX); RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); - - prop= RNA_def_property(srna, "grid_spacing", PROP_FLOAT, PROP_DISTANCE); + + prop= RNA_def_property(srna, "grid_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "grid"); - RNA_def_property_ui_text(prop, "Grid Spacing", "The distance between 3D View grid lines"); + RNA_def_property_ui_text(prop, "Grid Scale", "The distance between 3D View grid lines"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); - + prop= RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gridlines"); RNA_def_property_ui_text(prop, "Grid Lines", "The number of grid lines to display in perspective view"); @@ -1376,7 +1376,7 @@ static void rna_def_space_image(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceImageEditor_image_set", NULL, NULL); RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); + RNA_def_property_update(prop, NC_GEOM|ND_DATA, NULL); // is handled in image editor too prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 2e4c6e5a7b7..378d6455fe7 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -35,7 +35,7 @@ #ifdef RNA_RUNTIME -static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, char *name, int icon, int expand, int slider, int toggle, int icon_only, int event, int full_event, int emboss, int index) +static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, int icon, int expand, int slider, int toggle, int icon_only, int event, int full_event, int emboss, int index) { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); int flag= 0; @@ -56,7 +56,7 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, char *propname, char uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon); } -static PointerRNA rna_uiItemO(uiLayout *layout, char *opname, char *name, int icon, int emboss) +static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *name, int icon, int emboss) { int flag= UI_ITEM_O_RETURN_PROPS; flag |= (emboss)? 0: UI_ITEM_R_NO_BG; @@ -327,6 +327,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps, etc."); parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "show_buttons", 1, "", "Show preview buttons?"); RNA_def_pointer(func, "parent", "ID", "", "ID datablock."); RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot."); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 879378a4053..116e25030d6 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -44,13 +44,17 @@ #ifdef RNA_RUNTIME -#include "BKE_main.h" -#include "BKE_DerivedMesh.h" -#include "BKE_depsgraph.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" -#include "GPU_draw.h" + +#include "BKE_DerivedMesh.h" +#include "BKE_depsgraph.h" #include "BKE_global.h" +#include "BKE_main.h" + +#include "GPU_draw.h" + +#include "BLF_api.h" #include "MEM_guardedalloc.h" #include "MEM_CacheLimiterC-Api.h" @@ -254,6 +258,12 @@ static void rna_userdef_temp_update(Main *bmain, Scene *scene, PointerRNA *ptr) BLI_where_is_temp(btempdir, 1); } +static void rna_userdef_text_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + BLF_cache_clear(); + WM_main_add_notifier(NC_WINDOW, NULL); +} + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -1923,6 +1933,10 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TOOLTIPS); RNA_def_property_ui_text(prop, "Tooltips", "Display tooltips"); + prop= RNA_def_property(srna, "show_tooltips_python", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_TOOLTIPS_PYTHON); + RNA_def_property_ui_text(prop, "Show Python Tooltips", "Show Python references in tooltips"); + prop= RNA_def_property(srna, "show_object_info", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DRAWVIEWINFO); RNA_def_property_ui_text(prop, "Display Object Info", "Display objects name and frame number in 3D view"); @@ -2571,6 +2585,11 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_range(prop, 50, 1000); RNA_def_property_ui_text(prop, "Wait Timer (ms)", "Time in milliseconds between each frame recorded for screencast"); + prop= RNA_def_property(srna, "use_text_antialiasing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "text_render", USER_TEXT_DISABLE_AA); + RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased"); + RNA_def_property_update(prop, 0, "rna_userdef_text_update"); + #if 0 prop= RNA_def_property(srna, "verse_master", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "versemaster"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 539a46c8f84..1c490e7951e 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -652,7 +652,7 @@ static void rna_wmClipboard_set(PointerRNA *ptr, const char *value) #ifdef WITH_PYTHON static void rna_Operator_unregister(const bContext *C, StructRNA *type) { - char *idname; + const char *idname; wmOperatorType *ot= RNA_struct_blender_type_get(type); if(!ot) @@ -668,7 +668,7 @@ static void rna_Operator_unregister(const bContext *C, StructRNA *type) idname= ot->idname; WM_operatortype_remove(ot->idname); - MEM_freeN(idname); + MEM_freeN((void *)idname); /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */ RNA_struct_free(&BLENDER_RNA, type); @@ -966,7 +966,7 @@ static StructRNA* rna_MacroOperator_refine(PointerRNA *opr) return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Macro; } -static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, char *idname, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier) +static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, const char *idname, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier) { // wmWindowManager *wm = CTX_wm_manager(C); int modifier= 0; @@ -987,7 +987,7 @@ static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, char return WM_keymap_add_item(km, idname, type, value, modifier, keymodifier); } -static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, bContext *C, ReportList *reports, char* propvalue_str, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier) +static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, bContext *C, ReportList *reports, const char *propvalue_str, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier) { wmWindowManager *wm = CTX_wm_manager(C); int modifier= 0; @@ -1026,7 +1026,7 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, bContext *C, Report return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue); } -static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, char *idname, int spaceid, int regionid, int modal) +static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, int modal) { if (modal == 0) { return WM_keymap_find(keyconf, idname, spaceid, regionid); @@ -1035,12 +1035,12 @@ static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, char *idname, int spaceid, } } -static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf, char *idname, int spaceid, int regionid) +static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); } -static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *keyconf, char *idname) +static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *keyconf, const char *idname) { wmOperatorType *ot = WM_operatortype_find(idname, 0); @@ -1088,17 +1088,20 @@ static void rna_def_operator(BlenderRNA *brna) prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */ + // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->name"); RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER); prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->description"); RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); prop= RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); @@ -1143,17 +1146,20 @@ static void rna_def_macro_operator(BlenderRNA *brna) prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */ + // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_struct_name_property(srna, prop); prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->name"); RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER); prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->description"); RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); prop= RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 36dd6efc256..5aa68bc6d4e 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -34,6 +34,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" #ifdef RNA_RUNTIME @@ -50,7 +51,7 @@ static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyM WM_keymap_restore_item_to_default(C, km, kmi); } -static void rna_Operator_report(wmOperator *op, int type, char *msg) +static void rna_Operator_report(wmOperator *op, int type, const char *msg) { BKE_report(op->reports, type, msg); } @@ -92,7 +93,7 @@ static void rna_generic_op_invoke(FunctionRNA *func, int flag) } if(flag & WM_GEN_INVOKE_RETURN) { - parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); + parm= RNA_def_enum(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", ""); RNA_def_property_flag(parm, PROP_ENUM_FLAG); RNA_def_function_return(func, parm); } @@ -131,6 +132,11 @@ void RNA_api_wm(StructRNA *srna) func= RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup"); RNA_def_function_ui_description(func, "Operator popup invoke."); rna_generic_op_invoke(func, WM_GEN_INVOKE_SIZE|WM_GEN_INVOKE_RETURN); + + func= RNA_def_function(srna, "invoke_confirm", "WM_operator_confirm"); + RNA_def_function_ui_description(func, "Operator confirmation."); + rna_generic_op_invoke(func, WM_GEN_INVOKE_EVENT|WM_GEN_INVOKE_RETURN); + } void RNA_api_operator(StructRNA *srna) @@ -161,7 +167,7 @@ void RNA_api_operator(StructRNA *srna) RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); RNA_def_pointer(func, "context", "Context", "", ""); - parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name? + parm= RNA_def_enum(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", ""); // better name? RNA_def_property_flag(parm, PROP_ENUM_FLAG); RNA_def_function_return(func, parm); @@ -181,7 +187,7 @@ void RNA_api_operator(StructRNA *srna) RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_pointer(func, "event", "Event", "", ""); - parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name? + parm= RNA_def_enum(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", ""); // better name? RNA_def_property_flag(parm, PROP_ENUM_FLAG); RNA_def_function_return(func, parm); @@ -191,7 +197,7 @@ void RNA_api_operator(StructRNA *srna) RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_pointer(func, "event", "Event", "", ""); - parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name? + parm= RNA_def_enum(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", ""); // better name? RNA_def_property_flag(parm, PROP_ENUM_FLAG); RNA_def_function_return(func, parm); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 5807143f3a3..f7aa30174ac 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -98,6 +98,16 @@ static void rna_World_draw_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, wo); } +/* so camera mist limits redraw */ +static void rna_World_draw_mist_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + World *wo= ptr->id.data; + + DAG_id_flush_update(&wo->id, 0); + WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, wo); + WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL); +} + static void rna_World_stars_update(Main *bmain, Scene *scene, PointerRNA *ptr) { World *wo= ptr->id.data; @@ -275,7 +285,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "indirect_bounces", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "ao_indirect_bounces"); - RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces to use for approximate ambient occlusion"); RNA_def_property_update(prop, 0, "rna_World_update"); @@ -299,7 +309,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "falloff_strength", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aodistfac"); - RNA_def_property_ui_text(prop, "Strength", "Distance attenuation factor, the higher, the 'shorter' the shadows"); + RNA_def_property_ui_text(prop, "Strength", "Distance attenuation factor, the higher, the less influence farther away objects have influence"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE); @@ -388,14 +398,14 @@ static void rna_def_world_mist(BlenderRNA *brna) RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist, measured from the camera"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); + RNA_def_property_update(prop, 0, "rna_World_draw_mist_update"); prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "mistdist"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); RNA_def_property_ui_text(prop, "Depth", "The distance over which the mist effect fades in"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); + RNA_def_property_update(prop, 0, "rna_World_draw_mist_update"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "misthi"); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 71be58c9982..56c3bd3acb5 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -61,6 +61,7 @@ static void copyData(ModifierData *md, ModifierData *target) tamd->object = amd->object; tamd->deformflag = amd->deformflag; + tamd->multi = amd->multi; strncpy(tamd->defgrp_name, amd->defgrp_name, 32); } diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 6e6b9f43c54..07de73766f4 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -275,8 +275,13 @@ DerivedMesh *fluidsim_read_obj(char *filename) /* read no. of triangles */ gotBytes = gzread(gzf, &wri, sizeof(wri)); - if(wri!=numfaces) + if(wri!=numfaces) { printf("Fluidsim: error in reading data from file.\n"); + if(dm) + dm->release(dm); + gzclose( gzf ); + return NULL; + } // read triangles from file mface = CDDM_get_faces(dm); @@ -540,7 +545,6 @@ DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData *fluid return dm; } - #endif // DISABLE_ELBEEM DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, @@ -567,7 +571,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, // timescale not supported yet // clmd->sim_parms->timescale= timescale; - + // support reversing of baked fluid frames here if((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) { @@ -576,39 +580,9 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, } /* try to read from cache */ - if(((fss->lastgoodframe >= framenr) || (fss->lastgoodframe < 0)) && (result = fluidsim_read_cache(dm, fluidmd, framenr, useRenderParams))) - { - // fss->lastgoodframe = framenr; // set also in src/fluidsim.c + /* if the frame is there, fine, otherwise don't do anything */ + if((result = fluidsim_read_cache(dm, fluidmd, framenr, useRenderParams))) return result; - } - else - { - // display last known good frame - if(fss->lastgoodframe >= 0) - { - if((result = fluidsim_read_cache(dm, fluidmd, fss->lastgoodframe, useRenderParams))) - { - return result; - } - - // it was supposed to be a valid frame but it isn't! - fss->lastgoodframe = framenr - 1; - - - // this could be likely the case when you load an old fluidsim - if((result = fluidsim_read_cache(dm, fluidmd, fss->lastgoodframe, useRenderParams))) - { - return result; - } - } - - result = CDDM_copy(dm); - - if(result) - { - return result; - } - } return dm; #else diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index cd56bd3c8bc..f2b580aca9a 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -112,7 +112,7 @@ static CustomDataMask requiredDataMask(Object *ob, ModifierData *md) /* particles only need this if they are after a non deform modifier, and * the modifier stack will only create them in that case. */ - dataMask |= CD_MASK_ORIGSPACE; + dataMask |= CD_MASK_ORIGSPACE|CD_MASK_ORIGINDEX; dataMask |= CD_MASK_ORCO; diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 5a6470d994e..38e670f256d 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -140,10 +140,6 @@ SET(SRC intern/node_util.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_PYTHON) SET(INC ${INC} ../python ${PYTHON_INC}) ADD_DEFINITIONS(-DWITH_PYTHON) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index 4395eef0a5f..3481e7d793e 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -235,10 +235,12 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, /* write to outputs */ if(node->custom1 & SH_NODE_MAT_DIFF) { - if(node->custom1 & SH_NODE_MAT_SPEC) - out[MAT_OUT_COLOR].link= shr.combined; - else - out[MAT_OUT_COLOR].link= shr.diff; + out[MAT_OUT_COLOR].link= shr.combined; + + if(!(node->custom1 & SH_NODE_MAT_SPEC)) { + GPUNodeLink *link; + GPU_link(mat, "vec_math_sub", shr.combined, shr.spec, &out[MAT_OUT_COLOR].link, &link); + } } else if(node->custom1 & SH_NODE_MAT_SPEC) { out[MAT_OUT_COLOR].link= shr.spec; diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 40d544ac17e..466d8d3413d 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -118,7 +118,7 @@ extern "C" { // int BPY_do_spacehandlers(struct ScrArea *sa, unsigned short event, // short eventValue, unsigned short space_event); // -// void BPY_pydriver_update(void); + void BPY_reset_driver(void); float BPY_eval_driver(struct ChannelDriver *driver); // int BPY_eval_button(struct bContext *C, const char *expr, double *value); @@ -126,7 +126,7 @@ extern "C" { int BPY_eval_string(struct bContext *C, const char *expr); /* format importer hook */ - int BPY_call_importloader( char *name ); + int BPY_call_importloader(const char *name); // // void BPY_spacescript_do_pywin_draw( struct SpaceScript *sc ); // void BPY_spacescript_do_pywin_event( struct SpaceScript *sc, diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt index 7232399a329..b006e7b0be6 100644 --- a/source/blender/python/CMakeLists.txt +++ b/source/blender/python/CMakeLists.txt @@ -14,49 +14,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurainm, Campbell Barton -# # ***** END GPL LICENSE BLOCK ***** +ADD_SUBDIRECTORY(intern) ADD_SUBDIRECTORY(generic) - -SET(INC - . - ../blenlib - ../makesdna - ../makesrna - ../blenkernel - ../windowmanager - ../editors/include - ../freestyle/intern/python - ../../../intern/guardedalloc - ../../../intern/audaspace/intern - ${PYTHON_INC} -) - -SET(SRC - intern/bpy.c - intern/bpy_app.c - intern/bpy_array.c - intern/bpy_driver.c - intern/bpy_interface.c - intern/bpy_operator.c - intern/bpy_operator_wrap.c - intern/bpy_props.c - intern/bpy_rna.c - intern/bpy_rna_callback.c - intern/bpy_util.c - intern/stubs.c -) - -# only to check if buildinfo is available -IF(WITH_BUILDINFO) - ADD_DEFINITIONS(-DBUILD_DATE) -ENDIF(WITH_BUILDINFO) - -BLENDERLIB(bf_python "${SRC}" "${INC}") diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt index 2f5551d4c96..6513cf66c47 100644 --- a/source/blender/python/generic/CMakeLists.txt +++ b/source/blender/python/generic/CMakeLists.txt @@ -23,7 +23,6 @@ SET(INC ../../blenlib ../../makesdna ../../blenkernel - ../../editors/include ../../../../intern/guardedalloc ../../../../extern/glew/include ${PYTHON_INC} diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c index c64be00093c..3ae9d83cd4f 100644 --- a/source/blender/python/generic/IDProp.c +++ b/source/blender/python/generic/IDProp.c @@ -89,7 +89,7 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop ) int i; if (!seq) { - PyErr_Format( PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len); + PyErr_Format(PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len); return NULL; } @@ -219,7 +219,7 @@ static PyGetSetDef BPy_IDGroup_getseters[] = { static Py_ssize_t BPy_IDGroup_Map_Len(BPy_IDProperty *self) { if (self->prop->type != IDP_GROUP) { - PyErr_SetString( PyExc_TypeError, "len() of unsized object"); + PyErr_SetString(PyExc_TypeError, "len() of unsized object"); return -1; } @@ -232,21 +232,21 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item) char *name; if (self->prop->type != IDP_GROUP) { - PyErr_SetString( PyExc_TypeError, "unsubscriptable object"); + PyErr_SetString(PyExc_TypeError, "unsubscriptable object"); return NULL; } name= _PyUnicode_AsString(item); if (name == NULL) { - PyErr_SetString( PyExc_TypeError, "only strings are allowed as keys of ID properties"); + PyErr_SetString(PyExc_TypeError, "only strings are allowed as keys of ID properties"); return NULL; } idprop= IDP_GetPropertyFromGroup(self->prop, name); if(idprop==NULL) { - PyErr_SetString( PyExc_KeyError, "key not in subgroup dict"); + PyErr_SetString(PyExc_KeyError, "key not in subgroup dict"); return NULL; } @@ -295,7 +295,7 @@ static int idp_sequence_type(PyObject *seq) } /* note: group can be a pointer array or a group */ -char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObject *ob) +const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *group, PyObject *ob) { IDProperty *prop = NULL; IDPropertyTemplate val = {0}; @@ -352,7 +352,7 @@ char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObje case IDP_IDPARRAY: prop= IDP_NewIDPArray(name); for (i=0; i<val.array.len; i++) { - char *error; + const char *error; item = PySequence_GetItem(ob, i); error= BPy_IDProperty_Map_ValidateAndCreate("", prop, item); Py_DECREF(item); @@ -415,7 +415,7 @@ char *BPy_IDProperty_Map_ValidateAndCreate(char *name, IDProperty *group, PyObje int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) { if (prop->type != IDP_GROUP) { - PyErr_SetString( PyExc_TypeError, "unsubscriptable object"); + PyErr_SetString(PyExc_TypeError, "unsubscriptable object"); return -1; } @@ -427,21 +427,21 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) MEM_freeN(pkey); return 0; } else { - PyErr_SetString( PyExc_KeyError, "property not found in group" ); + PyErr_SetString(PyExc_KeyError, "property not found in group"); return -1; } } else { - char *err; + const char *err; if (!PyUnicode_Check(key)) { - PyErr_SetString( PyExc_TypeError, "only strings are allowed as subgroup keys" ); + PyErr_SetString(PyExc_TypeError, "only strings are allowed as subgroup keys"); return -1; } err = BPy_IDProperty_Map_ValidateAndCreate(_PyUnicode_AsString(key), prop, val); if (err) { - PyErr_SetString( PyExc_KeyError, err ); + PyErr_SetString(PyExc_KeyError, err ); return -1; } @@ -489,7 +489,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop) int i; if (!seq) { - PyErr_Format( PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_ARRAY: PyList_New(%d) failed", prop->len); + PyErr_Format(PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_ARRAY: PyList_New(%d) failed", prop->len); return NULL; } @@ -514,7 +514,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop) int i; if (!seq) { - PyErr_Format( PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len); + PyErr_Format(PyExc_RuntimeError, "BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len); return NULL; } @@ -556,7 +556,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value) char *name = _PyUnicode_AsString(value); if (!name) { - PyErr_SetString( PyExc_TypeError, "pop expected at least 1 argument, got 0" ); + PyErr_SetString(PyExc_TypeError, "pop expected at least 1 argument, got 0"); return NULL; } @@ -576,7 +576,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value) return pyform; } - PyErr_SetString( PyExc_KeyError, "item not in group" ); + PyErr_SetString(PyExc_KeyError, "item not in group"); return NULL; } @@ -693,7 +693,7 @@ static int BPy_IDGroup_Contains(BPy_IDProperty *self, PyObject *value) char *name = _PyUnicode_AsString(value); if (!name) { - PyErr_SetString( PyExc_TypeError, "expected a string"); + PyErr_SetString(PyExc_TypeError, "expected a string"); return -1; } @@ -706,7 +706,7 @@ static PyObject *BPy_IDGroup_Update(BPy_IDProperty *self, PyObject *value) Py_ssize_t i=0; if (!PyDict_Check(value)) { - PyErr_SetString( PyExc_TypeError, "expected an object derived from dict."); + PyErr_SetString(PyExc_TypeError, "expected an object derived from dict"); return NULL; } @@ -906,7 +906,7 @@ static int BPy_IDArray_Len(BPy_IDArray *self) static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index) { if (index < 0 || index >= self->prop->len) { - PyErr_SetString( PyExc_IndexError, "index out of range!"); + PyErr_SetString(PyExc_IndexError, "index out of range!"); return NULL; } @@ -922,7 +922,7 @@ static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index) break; } - PyErr_SetString( PyExc_RuntimeError, "invalid/corrupt array type!"); + PyErr_SetString(PyExc_RuntimeError, "invalid/corrupt array type!"); return NULL; } @@ -933,7 +933,7 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value) double d; if (index < 0 || index >= self->prop->len) { - PyErr_SetString( PyExc_RuntimeError, "index out of range!"); + PyErr_SetString(PyExc_RuntimeError, "index out of range!"); return -1; } @@ -1092,7 +1092,7 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self) return PyUnicode_FromString(cur->name); } } else { - PyErr_SetString( PyExc_StopIteration, "iterator at end" ); + PyErr_SetString(PyExc_StopIteration, "iterator at end"); return NULL; } } diff --git a/source/blender/python/generic/IDProp.h b/source/blender/python/generic/IDProp.h index c0a07879c1d..cd5bff4788e 100644 --- a/source/blender/python/generic/IDProp.h +++ b/source/blender/python/generic/IDProp.h @@ -56,7 +56,7 @@ int BPy_Wrap_SetMapItem(struct IDProperty *prop, PyObject *key, PyObject *val); PyObject *BPy_IDGroup_WrapData(struct ID *id, struct IDProperty *prop ); -char *BPy_IDProperty_Map_ValidateAndCreate(char *name, struct IDProperty *group, PyObject *ob); +const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, struct IDProperty *group, PyObject *ob); void IDProp_Init_Types(void); diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h index 5e40cda3114..60cca8e8ec7 100644 --- a/source/blender/python/generic/bgl.h +++ b/source/blender/python/generic/bgl.h @@ -215,19 +215,19 @@ extern PyTypeObject BGL_bufferType; #define GLsizei_def(num) int GLsizei_var(num) /* typedef unsigned char GLubyte; */ -#define GLubyte_str "b" +#define GLubyte_str "B" #define GLubyte_var(num) bgl_var##num #define GLubyte_ref(num) &bgl_var##num #define GLubyte_def(num) /* unsigned */ char GLubyte_var(num) /* typedef unsigned short GLushort; */ -#define GLushort_str "h" +#define GLushort_str "H" #define GLushort_var(num) bgl_var##num #define GLushort_ref(num) &bgl_var##num #define GLushort_def(num) /* unsigned */ short GLushort_var(num) /* typedef unsigned int GLuint; */ -#define GLuint_str "i" +#define GLuint_str "I" #define GLuint_var(num) bgl_var##num #define GLuint_ref(num) &bgl_var##num #define GLuint_def(num) /* unsigned */ int GLuint_var(num) diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c index 83cea0565cd..f1bb6b79f0f 100644 --- a/source/blender/python/generic/mathutils_color.c +++ b/source/blender/python/generic/mathutils_color.c @@ -198,7 +198,7 @@ static int Color_ass_item(ColorObject * self, int i, PyObject * value) if(i<0) i= COLOR_SIZE-i; if(i < 0 || i >= COLOR_SIZE){ - PyErr_SetString(PyExc_IndexError, "color[attribute] = x: array assignment index out of range\n"); + PyErr_SetString(PyExc_IndexError, "color[attribute] = x: array assignment index out of range"); return -1; } diff --git a/source/blender/python/generic/mathutils_euler.c b/source/blender/python/generic/mathutils_euler.c index e536bdbe9d4..9dc7cc2cc01 100644 --- a/source/blender/python/generic/mathutils_euler.c +++ b/source/blender/python/generic/mathutils_euler.c @@ -286,7 +286,7 @@ static char Euler_MakeCompatible_doc[] = static PyObject *Euler_MakeCompatible(EulerObject * self, EulerObject *value) { if(!EulerObject_Check(value)) { - PyErr_SetString(PyExc_TypeError, "euler.make_compatible(euler): expected a single euler argument."); + PyErr_SetString(PyExc_TypeError, "euler.make_compatible(euler): expected a single euler argument"); return NULL; } @@ -294,7 +294,7 @@ static PyObject *Euler_MakeCompatible(EulerObject * self, EulerObject *value) return NULL; if(self->order != value->order) { - PyErr_SetString(PyExc_ValueError, "euler.make_compatible(euler): rotation orders don't match\n"); + PyErr_SetString(PyExc_ValueError, "euler.make_compatible(euler): rotation orders don't match"); return NULL; } @@ -428,7 +428,7 @@ static int Euler_ass_item(EulerObject * self, int i, PyObject *value) if(i<0) i= EULER_SIZE-i; if(i < 0 || i >= EULER_SIZE){ - PyErr_SetString(PyExc_IndexError, "euler[attribute] = x: array assignment index out of range\n"); + PyErr_SetString(PyExc_IndexError, "euler[attribute] = x: array assignment index out of range"); return -1; } diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c index e57eb4ce83d..d41c05abb71 100644 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/generic/mathutils_geometry.c @@ -68,11 +68,11 @@ static PyObject *M_Geometry_Intersect(PyObject *UNUSED(self), PyObject* args) int clip = 1; if(!PyArg_ParseTuple(args, "O!O!O!O!O!|i", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) { - PyErr_SetString( PyExc_TypeError, "expected 5 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 5 vector types" ); return NULL; } if(vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) { - PyErr_SetString( PyExc_TypeError, "only 3D vectors for all parameters\n"); + PyErr_SetString(PyExc_TypeError, "only 3D vectors for all parameters"); return NULL; } @@ -140,11 +140,11 @@ static PyObject *M_Geometry_LineIntersect(PyObject *UNUSED(self), PyObject* args float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3]; if( !PyArg_ParseTuple( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4 ) ) { - PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 4 vector types" ); return NULL; } if( vec1->size != vec2->size || vec1->size != vec3->size || vec3->size != vec2->size) { - PyErr_SetString( PyExc_TypeError,"vectors must be of the same size\n" ); + PyErr_SetString(PyExc_TypeError,"vectors must be of the same size" ); return NULL; } @@ -192,7 +192,7 @@ static PyObject *M_Geometry_LineIntersect(PyObject *UNUSED(self), PyObject* args } } else { - PyErr_SetString( PyExc_TypeError, "2D/3D vectors only\n" ); + PyErr_SetString(PyExc_TypeError, "2D/3D vectors only" ); return NULL; } } @@ -210,15 +210,15 @@ static PyObject *M_Geometry_QuadNormal(PyObject *UNUSED(self), PyObject* args) float v1[3], v2[3], v3[3], v4[3], e1[3], e2[3], n1[3], n2[3]; if( !PyArg_ParseTuple( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4 ) ) { - PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 4 vector types" ); return NULL; } if( vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) { - PyErr_SetString( PyExc_TypeError,"vectors must be of the same size\n" ); + PyErr_SetString(PyExc_TypeError,"vectors must be of the same size" ); return NULL; } if( vec1->size != 3 ) { - PyErr_SetString( PyExc_TypeError, "only 3D vectors\n" ); + PyErr_SetString(PyExc_TypeError, "only 3D vectors" ); return NULL; } @@ -258,15 +258,15 @@ static PyObject *M_Geometry_TriangleNormal(PyObject *UNUSED(self), PyObject* arg float v1[3], v2[3], v3[3], e1[3], e2[3], n[3]; if( !PyArg_ParseTuple( args, "O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3 ) ) { - PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 3 vector types" ); return NULL; } if( vec1->size != vec2->size || vec1->size != vec3->size ) { - PyErr_SetString( PyExc_TypeError, "vectors must be of the same size\n" ); + PyErr_SetString(PyExc_TypeError, "vectors must be of the same size" ); return NULL; } if( vec1->size != 3 ) { - PyErr_SetString( PyExc_TypeError, "only 3D vectors\n" ); + PyErr_SetString(PyExc_TypeError, "only 3D vectors" ); return NULL; } @@ -297,11 +297,11 @@ static PyObject *M_Geometry_TriangleArea(PyObject *UNUSED(self), PyObject* args) if( !PyArg_ParseTuple ( args, "O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2 , &vector_Type, &vec3 ) ) { - PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n"); + PyErr_SetString(PyExc_TypeError, "expected 3 vector types"); return NULL; } if( vec1->size != vec2->size || vec1->size != vec3->size ) { - PyErr_SetString( PyExc_TypeError, "vectors must be of the same size\n" ); + PyErr_SetString(PyExc_TypeError, "vectors must be of the same size" ); return NULL; } @@ -328,7 +328,7 @@ static PyObject *M_Geometry_TriangleArea(PyObject *UNUSED(self), PyObject* args) return PyFloat_FromDouble( area_tri_v2(v1, v2, v3) ); } else { - PyErr_SetString( PyExc_TypeError, "only 2D,3D vectors are supported\n" ); + PyErr_SetString(PyExc_TypeError, "only 2D,3D vectors are supported" ); return NULL; } } @@ -352,7 +352,7 @@ static PyObject *M_Geometry_PolyFill(PyObject *UNUSED(self), PyObject * polyLine if(!PySequence_Check(polyLineSeq)) { - PyErr_SetString( PyExc_TypeError, "expected a sequence of poly lines" ); + PyErr_SetString(PyExc_TypeError, "expected a sequence of poly lines" ); return NULL; } @@ -363,7 +363,7 @@ static PyObject *M_Geometry_PolyFill(PyObject *UNUSED(self), PyObject * polyLine if (!PySequence_Check(polyLine)) { freedisplist(&dispbase); Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ - PyErr_SetString( PyExc_TypeError, "One or more of the polylines is not a sequence of mathutils.Vector's" ); + PyErr_SetString(PyExc_TypeError, "One or more of the polylines is not a sequence of mathutils.Vector's" ); return NULL; } @@ -373,7 +373,7 @@ static PyObject *M_Geometry_PolyFill(PyObject *UNUSED(self), PyObject * polyLine if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1) { freedisplist(&dispbase); Py_DECREF(polyLine); - PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a mathutils.Vector type" ); + PyErr_SetString(PyExc_TypeError, "A point in one of the polylines is not a mathutils.Vector type" ); return NULL; } #endif @@ -414,7 +414,7 @@ static PyObject *M_Geometry_PolyFill(PyObject *UNUSED(self), PyObject * polyLine if(ls_error) { freedisplist(&dispbase); /* possible some dl was allocated */ - PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a mathutils.Vector type" ); + PyErr_SetString(PyExc_TypeError, "A point in one of the polylines is not a mathutils.Vector type" ); return NULL; } else if (totpoints) { @@ -428,7 +428,7 @@ static PyObject *M_Geometry_PolyFill(PyObject *UNUSED(self), PyObject * polyLine tri_list= PyList_New(dl->parts); if( !tri_list ) { freedisplist(&dispbase); - PyErr_SetString( PyExc_RuntimeError, "geometry.PolyFill failed to make a new list" ); + PyErr_SetString(PyExc_RuntimeError, "geometry.PolyFill failed to make a new list" ); return NULL; } @@ -460,7 +460,7 @@ static PyObject *M_Geometry_LineIntersect2D(PyObject *UNUSED(self), PyObject* ar &vector_Type, &line_b1, &vector_Type, &line_b2) ) { - PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 4 vector types" ); return NULL; } @@ -560,7 +560,7 @@ static PyObject *M_Geometry_ClosestPointOnLine(PyObject *UNUSED(self), PyObject* &vector_Type, &line_1, &vector_Type, &line_2) ) { - PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 3 vector types" ); return NULL; } @@ -596,7 +596,7 @@ static PyObject *M_Geometry_PointInTriangle2D(PyObject *UNUSED(self), PyObject* &vector_Type, &tri_p2, &vector_Type, &tri_p3) ) { - PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 4 vector types" ); return NULL; } @@ -617,7 +617,7 @@ static PyObject *M_Geometry_PointInQuad2D(PyObject *UNUSED(self), PyObject* args &vector_Type, &quad_p3, &vector_Type, &quad_p4) ) { - PyErr_SetString( PyExc_TypeError, "expected 5 vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 5 vector types" ); return NULL; } @@ -636,7 +636,7 @@ static int boxPack_FromPyObject(PyObject * value, boxPack **boxarray ) /* Error checking must already be done */ if( !PyList_Check( value ) ) { - PyErr_SetString( PyExc_TypeError, "can only back a list of [x,y,x,w]" ); + PyErr_SetString(PyExc_TypeError, "can only back a list of [x,y,x,w]" ); return -1; } @@ -649,7 +649,7 @@ static int boxPack_FromPyObject(PyObject * value, boxPack **boxarray ) list_item = PyList_GET_ITEM( value, i ); if( !PyList_Check( list_item ) || PyList_Size( list_item ) < 4 ) { MEM_freeN(*boxarray); - PyErr_SetString( PyExc_TypeError, "can only back a list of [x,y,x,w]" ); + PyErr_SetString(PyExc_TypeError, "can only back a list of [x,y,x,w]" ); return -1; } @@ -660,7 +660,7 @@ static int boxPack_FromPyObject(PyObject * value, boxPack **boxarray ) if (!PyNumber_Check(item_1) || !PyNumber_Check(item_2)) { MEM_freeN(*boxarray); - PyErr_SetString( PyExc_TypeError, "can only back a list of 2d boxes [x,y,x,w]" ); + PyErr_SetString(PyExc_TypeError, "can only back a list of 2d boxes [x,y,x,w]" ); return -1; } @@ -698,7 +698,7 @@ static PyObject *M_Geometry_BoxPack2D(PyObject *UNUSED(self), PyObject * boxlist int error; if(!PyList_Check(boxlist)) { - PyErr_SetString( PyExc_TypeError, "expected a sequence of boxes [[x,y,w,h], ... ]" ); + PyErr_SetString(PyExc_TypeError, "expected a sequence of boxes [[x,y,w,h], ... ]" ); return NULL; } @@ -739,7 +739,7 @@ static PyObject *M_Geometry_BezierInterp(PyObject *UNUSED(self), PyObject* args) &vector_Type, &vec_h2, &vector_Type, &vec_k2, &resolu) || (resolu<=1) ) { - PyErr_SetString( PyExc_TypeError, "expected 4 vector types and an int greater then 1\n" ); + PyErr_SetString(PyExc_TypeError, "expected 4 vector types and an int greater then 1" ); return NULL; } @@ -789,7 +789,7 @@ static PyObject *M_Geometry_BarycentricTransform(PyObject *UNUSED(self), PyObjec vec_t2_tar->size != 3 || vec_t3_tar->size != 3) ) { - PyErr_SetString( PyExc_TypeError, "expected 7, 3D vector types\n" ); + PyErr_SetString(PyExc_TypeError, "expected 7, 3D vector types" ); return NULL; } diff --git a/source/blender/python/generic/mathutils_matrix.c b/source/blender/python/generic/mathutils_matrix.c index 34a31768b69..671e2568d39 100644 --- a/source/blender/python/generic/mathutils_matrix.c +++ b/source/blender/python/generic/mathutils_matrix.c @@ -121,7 +121,7 @@ static PyObject *Matrix_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject argSize = PyTuple_GET_SIZE(args); if(argSize > MATRIX_MAX_DIM) { //bad arg nums - PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size"); return NULL; } else if (argSize == 0) { //return empty 4D matrix return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, NULL); @@ -143,13 +143,13 @@ static PyObject *Matrix_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject if (PySequence_Check(argObject)) { //seq? if(seqSize){ //0 at first if(PySequence_Length(argObject) != seqSize){ //seq size not same - PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size"); return NULL; } } seqSize = PySequence_Length(argObject); }else{ //arg not a sequence - PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size"); return NULL; } } @@ -157,14 +157,14 @@ static PyObject *Matrix_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject for (i = 0; i < argSize; i++){ m = PyTuple_GET_ITEM(args, i); if (m == NULL) { // Failed to read sequence - PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments...\n"); + PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments"); return NULL; } for (j = 0; j < seqSize; j++) { s = PySequence_GetItem(m, j); if (s == NULL) { // Failed to read sequence - PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments...\n"); + PyErr_SetString(PyExc_RuntimeError, "mathutils.Matrix(): failed to parse arguments"); return NULL; } @@ -172,7 +172,7 @@ static PyObject *Matrix_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject Py_DECREF(s); if(scalar==-1 && PyErr_Occurred()) { // parsed item is not a number - PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix(): expects 0-4 numeric sequences of the same size"); return NULL; } @@ -211,14 +211,14 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; if(!PyArg_ParseTuple(args, "fi|O", &angle, &matSize, &vec)) { - PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(angle, size, axis): expected float int and a string or vector\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(angle, size, axis): expected float int and a string or vector"); return NULL; } if(vec && !VectorObject_Check(vec)) { axis= _PyUnicode_AsString((PyObject *)vec); if(axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') { - PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(): 3rd argument axis value must be a 3D vector or a string in 'X', 'Y', 'Z'\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.RotationMatrix(): 3rd argument axis value must be a 3D vector or a string in 'X', 'Y', 'Z'"); return NULL; } else { @@ -233,20 +233,20 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) angle-=(Py_PI*2); if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix"); return NULL; } if(matSize == 2 && (vec != NULL)) { - PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): cannot create a 2x2 rotation matrix around arbitrary axis\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): cannot create a 2x2 rotation matrix around arbitrary axis"); return NULL; } if((matSize == 3 || matSize == 4) && (axis == NULL) && (vec == NULL)) { - PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices"); return NULL; } if(vec) { if(vec->size != 3) { - PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): the vector axis must be a 3D vector\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): the vector axis must be a 3D vector"); return NULL; } @@ -289,7 +289,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } else { /* should never get here */ - PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): unknown error\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): unknown error"); return NULL; } @@ -325,11 +325,11 @@ static PyObject *C_Matrix_Translation(PyObject *cls, VectorObject * vec) 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; if(!VectorObject_Check(vec)) { - PyErr_SetString(PyExc_TypeError, "mathutils.TranslationMatrix(): expected vector\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Translation(): expected vector"); return NULL; } if(vec->size != 3 && vec->size != 4) { - PyErr_SetString(PyExc_TypeError, "mathutils.TranslationMatrix(): vector must be 3D or 4D\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Translation(): vector must be 3D or 4D"); return NULL; } @@ -344,7 +344,7 @@ static PyObject *C_Matrix_Translation(PyObject *cls, VectorObject * vec) return newMatrixObject(mat, 4, 4, Py_NEW, (PyTypeObject *)cls); } -//----------------------------------mathutils.ScaleMatrix() ------------- +//----------------------------------mathutils.Matrix.Scale() ------------- //mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. static char C_Matrix_Scale_doc[] = ".. classmethod:: Scale(factor, size, axis)\n" @@ -369,16 +369,16 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; if(!PyArg_ParseTuple(args, "fi|O!", &factor, &matSize, &vector_Type, &vec)) { - PyErr_SetString(PyExc_TypeError, "mathutils.ScaleMatrix(): expected float int and optional vector\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Scale(): expected float int and optional vector"); return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError, "mathutils.ScaleMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Scale(): can only return a 2x2 3x3 or 4x4 matrix"); return NULL; } if(vec) { if(vec->size > 2 && matSize == 2) { - PyErr_SetString(PyExc_AttributeError, "mathutils.ScaleMatrix(): please use 2D vectors when scaling in 2D\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Scale(): please use 2D vectors when scaling in 2D"); return NULL; } @@ -435,7 +435,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) //pass to matrix creation return newMatrixObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } -//----------------------------------mathutils.OrthoProjectionMatrix() --- +//----------------------------------mathutils.Matrix.OrthoProjection() --- //mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. static char C_Matrix_OrthoProjection_doc[] = ".. classmethod:: OrthoProjection(plane, size, axis)\n" @@ -460,16 +460,16 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; if(!PyArg_ParseTuple(args, "si|O!", &plane, &matSize, &vector_Type, &vec)) { - PyErr_SetString(PyExc_TypeError, "mathutils.OrthoProjectionMatrix(): expected string and int and optional vector\n"); + PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.OrthoProjection(): expected string and int and optional vector"); return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError,"mathutils.OrthoProjectionMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError,"mathutils.Matrix.OrthoProjection(): can only return a 2x2 3x3 or 4x4 matrix"); return NULL; } if(vec) { if(vec->size > 2 && matSize == 2) { - PyErr_SetString(PyExc_AttributeError, "mathutils.OrthoProjectionMatrix(): please use 2D vectors when scaling in 2D\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): please use 2D vectors when scaling in 2D"); return NULL; } @@ -492,7 +492,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) mat[4] = 1.0f; mat[8] = 1.0f; } else { - PyErr_SetString(PyExc_AttributeError, "mathutils.OrthoProjectionMatrix(): unknown plane - expected: X, Y, XY, XZ, YZ\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): unknown plane - expected: X, Y, XY, XZ, YZ"); return NULL; } } else { //arbitrary plane @@ -520,7 +520,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) mat[7] = -(vec->vec[1] * vec->vec[2]); mat[8] = 1 - (vec->vec[2] * vec->vec[2]); } else { - PyErr_SetString(PyExc_AttributeError, "mathutils.OrthoProjectionMatrix(): unknown plane - expected: 'r' expected for axis designation\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.OrthoProjection(): unknown plane - expected: 'r' expected for axis designation"); return NULL; } } @@ -562,11 +562,11 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; if(!PyArg_ParseTuple(args, "sfi", &plane, &factor, &matSize)) { - PyErr_SetString(PyExc_TypeError,"mathutils.ShearMatrix(): expected string float and int\n"); + PyErr_SetString(PyExc_TypeError,"mathutils.Matrix.Shear(): expected string float and int"); return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError,"mathutils.ShearMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError,"mathutils.Matrix.Shear(): can only return a 2x2 3x3 or 4x4 matrix"); return NULL; } @@ -597,7 +597,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) mat[4] = 1.0f; mat[8] = 1.0f; } else { - PyErr_SetString(PyExc_AttributeError, "mathutils.ShearMatrix(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n"); + PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Shear(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane"); return NULL; } if(matSize == 4) { @@ -706,7 +706,7 @@ PyObject *Matrix_toEuler(MatrixObject * self, PyObject *args) copy_m3_m4(tmat, (float (*)[4])self->contigPtr); mat= tmat; }else { - PyErr_SetString(PyExc_AttributeError, "Matrix.to_euler(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.to_euler(): inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; } @@ -884,7 +884,7 @@ PyObject *Matrix_RotationPart(MatrixObject * self) return NULL; if(self->colSize < 3 || self->rowSize < 3){ - PyErr_SetString(PyExc_AttributeError, "Matrix.rotation_part(): inappropriate matrix size\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.rotation_part(): inappropriate matrix size"); return NULL; } @@ -925,7 +925,7 @@ PyObject *Matrix_scalePart(MatrixObject * self) else if(self->colSize == 3 && self->rowSize == 3) copy_m3_m3(mat, (float (*)[3])self->contigPtr); else { - PyErr_SetString(PyExc_AttributeError, "Matrix.scale_part(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.scale_part(): inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; } /* functionality copied from editobject.c apply_obmat */ @@ -1024,7 +1024,7 @@ static PyObject *Matrix_decompose(MatrixObject * self) float size[3]; if(self->colSize != 4 || self->rowSize != 4) { - PyErr_SetString(PyExc_AttributeError, "Matrix.decompose(): inappropriate matrix size - expects 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.decompose(): inappropriate matrix size - expects 4x4 matrix"); return NULL; } @@ -1043,6 +1043,50 @@ static PyObject *Matrix_decompose(MatrixObject * self) } + +static char Matrix_Lerp_doc[] = +".. function:: lerp(other, factor)\n" +"\n" +" Returns the interpolation of two matricies.\n" +"\n" +" :arg other: value to interpolate with.\n" +" :type other: :class:`Matrix`\n" +" :arg factor: The interpolation value in [0.0, 1.0].\n" +" :type factor: float\n" +" :return: The interpolated rotation.\n" +" :rtype: :class:`Matrix`\n"; + +static PyObject *Matrix_Lerp(MatrixObject *self, PyObject *args) +{ + MatrixObject *mat2 = NULL; + float fac, mat[MATRIX_MAX_DIM*MATRIX_MAX_DIM]; + + if(!PyArg_ParseTuple(args, "O!f:lerp", &matrix_Type, &mat2, &fac)) + return NULL; + + if(self->rowSize != mat2->rowSize || self->colSize != mat2->colSize) { + PyErr_SetString(PyExc_AttributeError, "matrix.lerp(): expects both matrix objects of the same dimensions"); + return NULL; + } + + if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(mat2)) + return NULL; + + /* TODO, different sized matrix */ + if(self->rowSize==4 && self->colSize==4) { + blend_m4_m4m4((float (*)[4])mat, (float (*)[4])self->contigPtr, (float (*)[4])mat2->contigPtr, fac); + } + else if (self->rowSize==3 && self->colSize==3) { + blend_m3_m3m3((float (*)[3])mat, (float (*)[3])self->contigPtr, (float (*)[3])mat2->contigPtr, fac); + } + else { + PyErr_SetString(PyExc_AttributeError, "matrix.lerp(): only 3x3 and 4x4 matrices supported"); + return NULL; + } + + return (PyObject*)newMatrixObject(mat, self->rowSize, self->colSize, Py_NEW, Py_TYPE(self)); +} + /*---------------------------Matrix.determinant() ----------------*/ static char Matrix_Determinant_doc[] = ".. method:: determinant()\n" @@ -1149,7 +1193,7 @@ PyObject *Matrix_Identity(MatrixObject * self) return NULL; if(self->rowSize != self->colSize){ - PyErr_SetString(PyExc_AttributeError, "Matrix.identity: only square matrices are supported\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.identity: only square matrices are supported"); return NULL; } @@ -1309,27 +1353,27 @@ static int Matrix_ass_item(MatrixObject * self, int i, PyObject * ob) return -1; if(i >= self->rowSize || i < 0){ - PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: bad column\n"); + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: bad column"); return -1; } if(PySequence_Check(ob)){ size = PySequence_Length(ob); if(size != self->colSize){ - PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: bad sequence size\n"); + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: bad sequence size"); return -1; } for (x = 0; x < size; x++) { m = PySequence_GetItem(ob, x); if (m == NULL) { /*Failed to read sequence*/ - PyErr_SetString(PyExc_RuntimeError, "matrix[attribute] = x: unable to read sequence\n"); + PyErr_SetString(PyExc_RuntimeError, "matrix[attribute] = x: unable to read sequence"); return -1; } f = PyNumber_Float(m); if(f == NULL) { /*parsed item not a number*/ Py_DECREF(m); - PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: sequence argument not a number\n"); + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: sequence argument not a number"); return -1; } @@ -1345,7 +1389,7 @@ static int Matrix_ass_item(MatrixObject * self, int i, PyObject * ob) (void)BaseMath_WriteCallback(self); return 0; }else{ - PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: expects a sequence of column size\n"); + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: expects a sequence of column size"); return -1; } } @@ -1392,7 +1436,7 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * if(PySequence_Check(seq)){ size = PySequence_Length(seq); if(size != (end - begin)){ - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment\n"); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment"); return -1; } /*parse sub items*/ @@ -1409,14 +1453,14 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * sub_size = PySequence_Length(subseq); if(sub_size != self->colSize){ Py_DECREF(subseq); - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment\n"); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment"); return -1; } for (y = 0; y < sub_size; y++) { m = PySequence_GetItem(subseq, y); if (m == NULL) { /*Failed to read sequence*/ Py_DECREF(subseq); - PyErr_SetString(PyExc_RuntimeError, "matrix[begin:end] = []: unable to read sequence\n"); + PyErr_SetString(PyExc_RuntimeError, "matrix[begin:end] = []: unable to read sequence"); return -1; } @@ -1424,7 +1468,7 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * if(f == -1 && PyErr_Occurred()) { /*parsed item not a number*/ Py_DECREF(m); Py_DECREF(subseq); - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: sequence argument not a number\n"); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: sequence argument not a number"); return -1; } @@ -1433,7 +1477,7 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * } }else{ Py_DECREF(subseq); - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation\n"); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation"); return -1; } Py_DECREF(subseq); @@ -1446,7 +1490,7 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * (void)BaseMath_WriteCallback(self); return 0; }else{ - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation\n"); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation"); return -1; } } @@ -1463,7 +1507,7 @@ static PyObject *Matrix_add(PyObject * m1, PyObject * m2) mat2 = (MatrixObject*)m2; if(!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { - PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation...."); + PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation"); return NULL; } @@ -1496,7 +1540,7 @@ static PyObject *Matrix_sub(PyObject * m1, PyObject * m2) mat2 = (MatrixObject*)m2; if(!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { - PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation...."); + PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation"); return NULL; } @@ -1557,7 +1601,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) } if(mat1==NULL){ - scalar=PyFloat_AsDouble(m1); // may not be a float... + scalar=PyFloat_AsDouble(m1); // may not be a float if ((scalar == -1.0 && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX, this line annoys theeth, lets see if he finds it */ for(x = 0; x < mat2->rowSize; x++) { for(y = 0; y < mat2->colSize; y++) { @@ -1572,7 +1616,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) } else /* if(mat1) { */ { if(VectorObject_Check(m2)) { /* MATRIX*VECTOR */ - PyErr_SetString(PyExc_TypeError, "Matrix multiplication: Only 'vec * matrix' is supported, not the reverse."); + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: Only 'vec * matrix' is supported, not the reverse"); return NULL; } else { @@ -1590,7 +1634,7 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) return NULL; } - PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation\n"); + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); return NULL; } static PyObject* Matrix_inv(MatrixObject *self) @@ -1749,7 +1793,7 @@ static PyObject *Matrix_getMedianScale(MatrixObject *self, void *UNUSED(closure) else if(self->colSize == 3 && self->rowSize == 3) copy_m3_m3(mat, (float (*)[3])self->contigPtr); else { - PyErr_SetString(PyExc_AttributeError, "Matrix.median_scale: inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.median_scale: inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; } @@ -1767,7 +1811,7 @@ static PyObject *Matrix_getIsNegative(MatrixObject *self, void *UNUSED(closure)) else if(self->colSize == 3 && self->rowSize == 3) return PyBool_FromLong(is_negative_m3((float (*)[3])self->contigPtr)); else { - PyErr_SetString(PyExc_AttributeError, "Matrix.is_negative: inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + PyErr_SetString(PyExc_AttributeError, "Matrix.is_negative: inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; } } @@ -1791,6 +1835,7 @@ static struct PyMethodDef Matrix_methods[] = { {"zero", (PyCFunction) Matrix_Zero, METH_NOARGS, Matrix_Zero_doc}, {"identity", (PyCFunction) Matrix_Identity, METH_NOARGS, Matrix_Identity_doc}, {"transpose", (PyCFunction) Matrix_Transpose, METH_NOARGS, Matrix_Transpose_doc}, + {"lerp", (PyCFunction) Matrix_Lerp, METH_VARARGS, Matrix_Lerp_doc}, {"determinant", (PyCFunction) Matrix_Determinant, METH_NOARGS, Matrix_Determinant_doc}, {"invert", (PyCFunction) Matrix_Invert, METH_NOARGS, Matrix_Invert_doc}, {"translation_part", (PyCFunction) Matrix_TranslationPart, METH_NOARGS, Matrix_TranslationPart_doc}, @@ -1876,7 +1921,7 @@ self->matrix self->contiguous_ptr (reference to data.xxx) [1]------------->[3] [4] [5] - .... + self->matrix[1][1] = self->contigPtr[4] */ /*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER @@ -1914,7 +1959,7 @@ PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type, PyType }else if (type == Py_NEW){ self->contigPtr = PyMem_Malloc(rowSize * colSize * sizeof(float)); if(self->contigPtr == NULL) { /*allocation failure*/ - PyErr_SetString( PyExc_MemoryError, "matrix(): problem allocating pointer space\n"); + PyErr_SetString(PyExc_MemoryError, "matrix(): problem allocating pointer space"); return NULL; } /*pointer array points to contigous memory*/ diff --git a/source/blender/python/generic/mathutils_matrix.h b/source/blender/python/generic/mathutils_matrix.h index 21538f8168e..f1cce3a45a8 100644 --- a/source/blender/python/generic/mathutils_matrix.h +++ b/source/blender/python/generic/mathutils_matrix.h @@ -38,10 +38,9 @@ extern PyTypeObject matrix_Type; typedef struct { BASE_MATH_MEMBERS(contigPtr) - - unsigned char rowSize; - unsigned int colSize; float *matrix[MATRIX_MAX_DIM]; /* ptr to the contigPtr (accessor) */ + unsigned short rowSize; + unsigned short colSize; } MatrixObject; /*struct data contains a pointer to the actual data that the diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c index 8a42adce9a9..dec15610133 100644 --- a/source/blender/python/generic/mathutils_quat.c +++ b/source/blender/python/generic/mathutils_quat.c @@ -138,12 +138,12 @@ static char Quaternion_Cross_doc[] = " :return: The cross product.\n" " :rtype: :class:`Quaternion`\n"; -static PyObject *Quaternion_Cross(QuaternionObject * self, QuaternionObject * value) +static PyObject *Quaternion_Cross(QuaternionObject *self, QuaternionObject *value) { float quat[QUAT_SIZE]; if (!QuaternionObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "quat.cross(value): expected a quaternion argument" ); + PyErr_Format(PyExc_TypeError, "quat.cross(value): expected a quaternion argument, not %.200s", Py_TYPE(value)->tp_name); return NULL; } @@ -168,7 +168,7 @@ static char Quaternion_Dot_doc[] = static PyObject *Quaternion_Dot(QuaternionObject * self, QuaternionObject * value) { if (!QuaternionObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "quat.dot(value): expected a quaternion argument" ); + PyErr_Format(PyExc_TypeError, "quat.dot(value): expected a quaternion argument, not %.200s", Py_TYPE(value)->tp_name); return NULL; } @@ -193,7 +193,7 @@ static PyObject *Quaternion_Difference(QuaternionObject * self, QuaternionObject float quat[QUAT_SIZE]; if (!QuaternionObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "quat.difference(value): expected a quaternion argument" ); + PyErr_Format(PyExc_TypeError, "quat.difference(value): expected a quaternion argument, not %.200s", Py_TYPE(value)->tp_name); return NULL; } @@ -440,7 +440,7 @@ static PyObject *Quaternion_item(QuaternionObject * self, int i) if(i<0) i= QUAT_SIZE-i; if(i < 0 || i >= QUAT_SIZE) { - PyErr_SetString(PyExc_IndexError, "quaternion[attribute]: array index out of range\n"); + PyErr_SetString(PyExc_IndexError, "quaternion[attribute]: array index out of range"); return NULL; } @@ -456,14 +456,14 @@ static int Quaternion_ass_item(QuaternionObject * self, int i, PyObject * ob) { float scalar= (float)PyFloat_AsDouble(ob); if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ - PyErr_SetString(PyExc_TypeError, "quaternion[index] = x: index argument not a number\n"); + PyErr_SetString(PyExc_TypeError, "quaternion[index] = x: index argument not a number"); return -1; } if(i<0) i= QUAT_SIZE-i; if(i < 0 || i >= QUAT_SIZE){ - PyErr_SetString(PyExc_IndexError, "quaternion[attribute] = x: array assignment index out of range\n"); + PyErr_SetString(PyExc_IndexError, "quaternion[attribute] = x: array assignment index out of range"); return -1; } self->quat[i] = scalar; @@ -604,7 +604,7 @@ static PyObject *Quaternion_add(PyObject * q1, PyObject * q2) QuaternionObject *quat1 = NULL, *quat2 = NULL; if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { - PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation....\n"); + PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation"); return NULL; } quat1 = (QuaternionObject*)q1; @@ -625,7 +625,7 @@ static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2) QuaternionObject *quat1 = NULL, *quat2 = NULL; if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { - PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation....\n"); + PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation"); return NULL; } @@ -689,7 +689,7 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) } } - PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation\n"); + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation"); return NULL; } diff --git a/source/blender/python/generic/mathutils_vector.c b/source/blender/python/generic/mathutils_vector.c index e4027d7a80e..ee4cd154894 100644 --- a/source/blender/python/generic/mathutils_vector.c +++ b/source/blender/python/generic/mathutils_vector.c @@ -130,7 +130,7 @@ static char Vector_Resize2D_doc[] = static PyObject *Vector_Resize2D(VectorObject *self) { if(self->wrapped==Py_WRAP) { - PyErr_SetString(PyExc_TypeError, "vector.resize2D(): cannot resize wrapped data - only python vectors\n"); + PyErr_SetString(PyExc_TypeError, "vector.resize2D(): cannot resize wrapped data - only python vectors"); return NULL; } if(self->cb_user) { @@ -140,7 +140,7 @@ static PyObject *Vector_Resize2D(VectorObject *self) self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2)); if(self->vec == NULL) { - PyErr_SetString(PyExc_MemoryError, "vector.resize2D(): problem allocating pointer space\n\n"); + PyErr_SetString(PyExc_MemoryError, "vector.resize2D(): problem allocating pointer space"); return NULL; } @@ -160,7 +160,7 @@ static char Vector_Resize3D_doc[] = static PyObject *Vector_Resize3D(VectorObject *self) { if (self->wrapped==Py_WRAP) { - PyErr_SetString(PyExc_TypeError, "vector.resize3D(): cannot resize wrapped data - only python vectors\n"); + PyErr_SetString(PyExc_TypeError, "vector.resize3D(): cannot resize wrapped data - only python vectors"); return NULL; } if(self->cb_user) { @@ -170,7 +170,7 @@ static PyObject *Vector_Resize3D(VectorObject *self) self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3)); if(self->vec == NULL) { - PyErr_SetString(PyExc_MemoryError, "vector.resize3D(): problem allocating pointer space\n\n"); + PyErr_SetString(PyExc_MemoryError, "vector.resize3D(): problem allocating pointer space"); return NULL; } @@ -203,7 +203,7 @@ static PyObject *Vector_Resize4D(VectorObject *self) self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4)); if(self->vec == NULL) { - PyErr_SetString(PyExc_MemoryError, "vector.resize4D(): problem allocating pointer space\n\n"); + PyErr_SetString(PyExc_MemoryError, "vector.resize4D(): problem allocating pointer space"); return NULL; } if(self->size == 2){ @@ -294,7 +294,7 @@ static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args ) return NULL; if (self->size != 3) { - PyErr_SetString( PyExc_TypeError, "only for 3D vectors\n" ); + PyErr_SetString(PyExc_TypeError, "only for 3D vectors"); return NULL; } @@ -315,12 +315,12 @@ static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args ) track = 5; break; default: - PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + PyErr_SetString(PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis"); return NULL; } } else { - PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + PyErr_SetString(PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis"); return NULL; } } @@ -337,12 +337,12 @@ static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args ) track = 2; break; default: - PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + PyErr_SetString(PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis"); return NULL; } } else { - PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + PyErr_SetString(PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis"); return NULL; } } @@ -353,25 +353,25 @@ static PyObject *Vector_ToTrackQuat(VectorObject *self, PyObject *args ) case 'X': up = 0; break; - case 'y': + case 'Y': up = 1; break; case 'Z': up = 2; break; default: - PyErr_SetString( PyExc_ValueError, "only X, Y or Z for up axis\n" ); + PyErr_SetString(PyExc_ValueError, "only X, Y or Z for up axis"); return NULL; } } else { - PyErr_SetString( PyExc_ValueError, "only X, Y or Z for up axis\n" ); + PyErr_SetString(PyExc_ValueError, "only X, Y or Z for up axis"); return NULL; } } if (track == up) { - PyErr_SetString( PyExc_ValueError, "Can't have the same axis for track and up\n" ); + PyErr_SetString(PyExc_ValueError, "Can't have the same axis for track and up"); return NULL; } @@ -408,7 +408,7 @@ static PyObject *Vector_Reflect(VectorObject *self, VectorObject *value ) float reflect[3] = {0.0f, 0.0f, 0.0f}; if (!VectorObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "vec.reflect(value): expected a vector argument" ); + PyErr_SetString(PyExc_TypeError, "vec.reflect(value): expected a vector argument"); return NULL; } @@ -428,7 +428,7 @@ static PyObject *Vector_Reflect(VectorObject *self, VectorObject *value ) normalize_v3(mirror); reflect_v3_v3v3(reflect, vec, mirror); - return newVectorObject(reflect, self->size, Py_NEW, NULL); + return newVectorObject(reflect, self->size, Py_NEW, Py_TYPE(self)); } static char Vector_Cross_doc[] = @@ -448,19 +448,19 @@ static PyObject *Vector_Cross(VectorObject *self, VectorObject *value ) VectorObject *vecCross = NULL; if (!VectorObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "vec.cross(value): expected a vector argument" ); + PyErr_SetString(PyExc_TypeError, "vec.cross(value): expected a vector argument"); return NULL; } if(self->size != 3 || value->size != 3) { - PyErr_SetString(PyExc_AttributeError, "vec.cross(value): expects both vectors to be 3D\n"); + PyErr_SetString(PyExc_AttributeError, "vec.cross(value): expects both vectors to be 3D"); return NULL; } if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value)) return NULL; - vecCross = (VectorObject *)newVectorObject(NULL, 3, Py_NEW, NULL); + vecCross = (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self)); cross_v3_v3v3(vecCross->vec, self->vec, value->vec); return (PyObject *)vecCross; } @@ -481,12 +481,12 @@ static PyObject *Vector_Dot(VectorObject *self, VectorObject *value ) int x; if (!VectorObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "vec.dot(value): expected a vector argument" ); + PyErr_SetString(PyExc_TypeError, "vec.dot(value): expected a vector argument"); return NULL; } if(self->size != value->size) { - PyErr_SetString(PyExc_AttributeError, "vec.dot(value): expects both vectors to have the same size\n"); + PyErr_SetString(PyExc_AttributeError, "vec.dot(value): expects both vectors to have the same size"); return NULL; } @@ -523,19 +523,19 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) return NULL; if (!VectorObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "vec.angle(value): expected a vector argument" ); + PyErr_SetString(PyExc_TypeError, "vec.angle(value): expected a vector argument"); return NULL; } if(self->size != value->size) { - PyErr_SetString(PyExc_AttributeError, "vec.angle(value): expects both vectors to have the same size\n"); + PyErr_SetString(PyExc_AttributeError, "vec.angle(value): expects both vectors to have the same size"); return NULL; } if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value)) return NULL; - //since size is the same.... + //since size is the same size = self->size; for(x = 0; x < size; x++) { @@ -549,7 +549,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) return fallback; } else { - PyErr_SetString(PyExc_ValueError, "vector.angle(other): zero length vectors have no valid angle\n"); + PyErr_SetString(PyExc_ValueError, "vector.angle(other): zero length vectors have no valid angle"); return NULL; } } @@ -582,12 +582,12 @@ static PyObject *Vector_Difference(VectorObject *self, VectorObject *value ) float quat[4], vec_a[3], vec_b[3]; if (!VectorObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "vec.difference(value): expected a vector argument" ); + PyErr_SetString(PyExc_TypeError, "vec.difference(value): expected a vector argument"); return NULL; } if(self->size < 3 || value->size < 3) { - PyErr_SetString(PyExc_AttributeError, "vec.difference(value): expects both vectors to be size 3 or 4\n"); + PyErr_SetString(PyExc_AttributeError, "vec.difference(value): expects both vectors to be size 3 or 4"); return NULL; } @@ -619,12 +619,12 @@ static PyObject *Vector_Project(VectorObject *self, VectorObject *value) int x, size; if (!VectorObject_Check(value)) { - PyErr_SetString( PyExc_TypeError, "vec.project(value): expected a vector argument" ); + PyErr_SetString(PyExc_TypeError, "vec.project(value): expected a vector argument"); return NULL; } if(self->size != value->size) { - PyErr_SetString(PyExc_AttributeError, "vec.project(value): expects both vectors to have the same size\n"); + PyErr_SetString(PyExc_AttributeError, "vec.project(value): expects both vectors to have the same size"); return NULL; } @@ -632,7 +632,7 @@ static PyObject *Vector_Project(VectorObject *self, VectorObject *value) return NULL; - //since they are the same size... + //since they are the same size size = self->size; //get dot products @@ -645,7 +645,7 @@ static PyObject *Vector_Project(VectorObject *self, VectorObject *value) for(x = 0; x < size; x++) { vec[x] = (float)(dot * value->vec[x]); } - return newVectorObject(vec, size, Py_NEW, NULL); + return newVectorObject(vec, size, Py_NEW, Py_TYPE(self)); } static char Vector_Lerp_doc[] = @@ -670,7 +670,7 @@ static PyObject *Vector_Lerp(VectorObject *self, PyObject *args) return NULL; if(self->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, "vector.lerp(): expects (2) vector objects of the same size"); + PyErr_SetString(PyExc_AttributeError, "vector.lerp(): expects both vector objects to have the same size"); return NULL; } @@ -682,7 +682,7 @@ static PyObject *Vector_Lerp(VectorObject *self, PyObject *args) for(x = 0; x < self->size; x++) { vec[x] = (ifac * self->vec[x]) + (fac * vec2->vec[x]); } - return newVectorObject(vec, self->size, Py_NEW, NULL); + return newVectorObject(vec, self->size, Py_NEW, Py_TYPE(self)); } /*---------------------------- Vector.rotate(angle, axis) ----------------------*/ @@ -709,7 +709,7 @@ static PyObject *Vector_Rotate(VectorObject *self, PyObject *args) } if(self->size != 3 || axis_vec->size != 3) { - PyErr_SetString(PyExc_AttributeError, "vec.rotate(angle, axis): expects both vectors to be 3D\n"); + PyErr_SetString(PyExc_AttributeError, "vec.rotate(angle, axis): expects both vectors to be 3D"); return NULL; } @@ -772,7 +772,7 @@ static PyObject *Vector_item(VectorObject *self, int i) if(i<0) i= self->size-i; if(i < 0 || i >= self->size) { - PyErr_SetString(PyExc_IndexError,"vector[index]: out of range\n"); + PyErr_SetString(PyExc_IndexError,"vector[index]: out of range"); return NULL; } @@ -788,14 +788,14 @@ static int Vector_ass_item(VectorObject *self, int i, PyObject * ob) { float scalar; if((scalar=PyFloat_AsDouble(ob))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ - PyErr_SetString(PyExc_TypeError, "vector[index] = x: index argument not a number\n"); + PyErr_SetString(PyExc_TypeError, "vector[index] = x: index argument not a number"); return -1; } if(i<0) i= self->size-i; if(i < 0 || i >= self->size){ - PyErr_SetString(PyExc_IndexError, "vector[index] = x: assignment index out of range\n"); + PyErr_SetString(PyExc_IndexError, "vector[index] = x: assignment index out of range"); return -1; } self->vec[i] = scalar; @@ -846,20 +846,20 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, size = PySequence_Length(seq); if(size != (end - begin)){ - PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: size mismatch in slice assignment\n"); + PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: size mismatch in slice assignment"); return -1; } for (i = 0; i < size; i++) { v = PySequence_GetItem(seq, i); if (v == NULL) { /* Failed to read sequence */ - PyErr_SetString(PyExc_RuntimeError, "vector[begin:end] = []: unable to read sequence\n"); + PyErr_SetString(PyExc_RuntimeError, "vector[begin:end] = []: unable to read sequence"); return -1; } if((scalar=PyFloat_AsDouble(v)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ Py_DECREF(v); - PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: sequence argument not a number\n"); + PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: sequence argument not a number"); return -1; } @@ -900,16 +900,16 @@ static PyObject *Vector_add(PyObject * v1, PyObject * v2) /*VECTOR + VECTOR*/ if(vec1->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, "Vector addition: vectors must have the same dimensions for this operation\n"); + PyErr_SetString(PyExc_AttributeError, "Vector addition: vectors must have the same dimensions for this operation"); return NULL; } for(i = 0; i < vec1->size; i++) { vec[i] = vec1->vec[i] + vec2->vec[i]; } - return newVectorObject(vec, vec1->size, Py_NEW, NULL); + return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } - PyErr_SetString(PyExc_AttributeError, "Vector addition: arguments not valid for this operation....\n"); + PyErr_SetString(PyExc_AttributeError, "Vector addition: arguments not valid for this operation"); return NULL; } @@ -921,14 +921,14 @@ static PyObject *Vector_iadd(PyObject * v1, PyObject * v2) VectorObject *vec1 = NULL, *vec2 = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, "Vector addition: arguments not valid for this operation....\n"); + PyErr_SetString(PyExc_AttributeError, "Vector addition: arguments not valid for this operation"); return NULL; } vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; if(vec1->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, "Vector addition: vectors must have the same dimensions for this operation\n"); + PyErr_SetString(PyExc_AttributeError, "Vector addition: vectors must have the same dimensions for this operation"); return NULL; } @@ -953,7 +953,7 @@ static PyObject *Vector_sub(PyObject * v1, PyObject * v2) VectorObject *vec1 = NULL, *vec2 = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, "Vector subtraction: arguments not valid for this operation....\n"); + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: arguments not valid for this operation"); return NULL; } vec1 = (VectorObject*)v1; @@ -963,14 +963,14 @@ static PyObject *Vector_sub(PyObject * v1, PyObject * v2) return NULL; if(vec1->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, "Vector subtraction: vectors must have the same dimensions for this operation\n"); + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: vectors must have the same dimensions for this operation"); return NULL; } for(i = 0; i < vec1->size; i++) { vec[i] = vec1->vec[i] - vec2->vec[i]; } - return newVectorObject(vec, vec1->size, Py_NEW, NULL); + return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /*------------------------obj -= obj------------------------------ @@ -981,14 +981,14 @@ static PyObject *Vector_isub(PyObject * v1, PyObject * v2) VectorObject *vec1 = NULL, *vec2 = NULL; if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, "Vector subtraction: arguments not valid for this operation....\n"); + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: arguments not valid for this operation"); return NULL; } vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; if(vec1->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, "Vector subtraction: vectors must have the same dimensions for this operation\n"); + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: vectors must have the same dimensions for this operation"); return NULL; } @@ -1070,7 +1070,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2) double dot = 0.0f; if(vec1->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, "Vector multiplication: vectors must have the same dimensions for this operation\n"); + PyErr_SetString(PyExc_AttributeError, "Vector multiplication: vectors must have the same dimensions for this operation"); return NULL; } @@ -1100,14 +1100,14 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2) return NULL; } - return newVectorObject(tvec, vec1->size, Py_NEW, NULL); + return newVectorObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); } else if (QuaternionObject_Check(v2)) { /* VEC * QUAT */ QuaternionObject *quat2 = (QuaternionObject*)v2; float tvec[3]; if(vec1->size != 3) { - PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported\n"); + PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported"); return NULL; } if(!BaseMath_ReadCallback(quat2)) { @@ -1115,7 +1115,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, NULL); + return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); } else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ int i; @@ -1124,11 +1124,11 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2) for(i = 0; i < vec1->size; i++) { vec[i] = vec1->vec[i] * scalar; } - return newVectorObject(vec, vec1->size, Py_NEW, NULL); + return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(vec1)); } - PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation\n"); + PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation"); return NULL; } @@ -1159,7 +1159,7 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2) QuaternionObject *quat2 = (QuaternionObject*)v2; if(vec->size != 3) { - PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported\n"); + PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported"); return NULL; } @@ -1172,7 +1172,7 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2) mul_vn_fl(vec->vec, vec->size, scalar); } else { - PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation\n"); + PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation"); return NULL; } @@ -1190,7 +1190,7 @@ static PyObject *Vector_div(PyObject * v1, PyObject * v2) VectorObject *vec1 = NULL; if(!VectorObject_Check(v1)) { /* not a vector */ - PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float"); return NULL; } vec1 = (VectorObject*)v1; /* vector */ @@ -1199,19 +1199,19 @@ static PyObject *Vector_div(PyObject * v1, PyObject * v2) return NULL; if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ - PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float"); return NULL; } if(scalar==0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error.\n"); + PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error"); return NULL; } for(i = 0; i < vec1->size; i++) { vec[i] = vec1->vec[i] / scalar; } - return newVectorObject(vec, vec1->size, Py_NEW, NULL); + return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(v1)); } /*------------------------obj /= obj------------------------------ @@ -1226,12 +1226,12 @@ static PyObject *Vector_idiv(PyObject * v1, PyObject * v2) return NULL; if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ - PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float"); return NULL; } if(scalar==0.0) { - PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error.\n"); + PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error"); return NULL; } for(i = 0; i < vec1->size; i++) { @@ -1527,7 +1527,7 @@ static int Vector_setLength(VectorObject *self, PyObject * value ) } if (param < 0.0f) { - PyErr_SetString( PyExc_TypeError, "cannot set a vectors length to a negative value" ); + PyErr_SetString(PyExc_TypeError, "cannot set a vectors length to a negative value"); return -1; } if (param == 0.0f) { @@ -1580,7 +1580,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) { axis_from = swizzleClosure & SWIZZLE_AXIS; if(axis_from >= self->size) { - PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis."); + PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis"); return NULL; } @@ -1627,7 +1627,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject * value, void *closure axis_to = swizzleClosure & SWIZZLE_AXIS; if (axis_to >= self->size) { - PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis.\n"); + PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis"); return -1; } swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; @@ -1646,7 +1646,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject * value, void *closure } if(axis_from != size_from) { - PyErr_SetString(PyExc_AttributeError, "Error: vector size does not match swizzle.\n"); + PyErr_SetString(PyExc_AttributeError, "Error: vector size does not match swizzle"); return -1; } diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt new file mode 100644 index 00000000000..09cff5990c8 --- /dev/null +++ b/source/blender/python/intern/CMakeLists.txt @@ -0,0 +1,60 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# The Original Code is Copyright (C) 2006, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Jacques Beaurainm, Campbell Barton +# +# ***** END GPL LICENSE BLOCK ***** + +SET(INC + ../ + ../../blenlib + ../../makesdna + ../../makesrna + ../../blenkernel + ../../windowmanager + ../../editors/include + ../../freestyle/intern/python + ../../../../intern/guardedalloc + ../../../../intern/audaspace/intern + ${PYTHON_INC} +) + +SET(SRC + bpy.c + bpy_app.c + bpy_driver.c + bpy_interface.c + bpy_operator.c + bpy_operator_wrap.c + bpy_props.c + bpy_rna.c + bpy_rna_array.c + bpy_rna_callback.c + bpy_util.c + stubs.c +) + +# only to check if buildinfo is available +IF(WITH_BUILDINFO) + ADD_DEFINITIONS(-DBUILD_DATE) +ENDIF(WITH_BUILDINFO) + +BLENDERLIB(bf_python "${SRC}" "${INC}") diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index b7a277c76b0..8977c82dc7c 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -159,15 +159,34 @@ static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closur return PyC_UnicodeFromByte(btempdir); } -PyGetSetDef bpy_app_debug_getset= {"debug", bpy_app_debug_get, bpy_app_debug_set, "Boolean, set when blender is running in debug mode (started with -d)", NULL}; -PyGetSetDef bpy_app_tempdir_getset= {"tempdir", bpy_app_tempdir_get, NULL, "String, the temp directory used by blender (read-only)", NULL}; +static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure)) +{ + if (bpy_pydriver_Dict == NULL) + if (bpy_pydriver_create_dict() != 0) { + PyErr_SetString(PyExc_RuntimeError, "bpy.app.driver_namespace failed to create dictionary"); + return NULL; + } + + Py_INCREF(bpy_pydriver_Dict); + return bpy_pydriver_Dict; +} + + +PyGetSetDef bpy_app_getsets[]= { + {"debug", bpy_app_debug_get, bpy_app_debug_set, "Boolean, set when blender is running in debug mode (started with -d)", NULL}, + {"tempdir", bpy_app_tempdir_get, NULL, "String, the temp directory used by blender (read-only)", NULL}, + {"driver_namespace", bpy_app_driver_dict_get, NULL, "Dictionary for drivers namespace, editable in-place, reset on file load (read-only)", NULL}, + {NULL, NULL, NULL, NULL, NULL} +}; static void py_struct_seq_getset_init(void) { /* tricky dynamic members, not to py-spec! */ - - PyDict_SetItemString(BlenderAppType.tp_dict, bpy_app_debug_getset.name, PyDescr_NewGetSet(&BlenderAppType, &bpy_app_debug_getset)); - PyDict_SetItemString(BlenderAppType.tp_dict, bpy_app_tempdir_getset.name, PyDescr_NewGetSet(&BlenderAppType, &bpy_app_tempdir_getset)); + PyGetSetDef *getset; + + for(getset= bpy_app_getsets; getset->name; getset++) { + PyDict_SetItemString(BlenderAppType.tp_dict, getset->name, PyDescr_NewGetSet(&BlenderAppType, getset)); + } } /* end dynamic bpy.app */ diff --git a/source/blender/python/intern/bpy_app.h b/source/blender/python/intern/bpy_app.h index 1da5004ee85..02cadc66f48 100644 --- a/source/blender/python/intern/bpy_app.h +++ b/source/blender/python/intern/bpy_app.h @@ -28,4 +28,8 @@ PyObject *BPY_app_struct( void ); +/* bpy_driver.c */ +int bpy_pydriver_create_dict(void); +extern PyObject *bpy_pydriver_Dict; + #endif diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index e5719a84fdd..6de341311be 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -40,7 +40,7 @@ PyObject *bpy_pydriver_Dict = NULL; /* For faster execution we keep a special dictionary for pydrivers, with * the needed modules and aliases. */ -static int bpy_pydriver_create_dict(void) +int bpy_pydriver_create_dict(void) { PyObject *d, *mod; @@ -103,7 +103,7 @@ static int bpy_pydriver_create_dict(void) * reloading the Blender text module "pydrivers.py", if available, so * updates in it reach pydriver evaluation. */ -void BPY_pydriver_update(void) +void BPY_reset_driver(void) { PyGILState_STATE gilstate; int use_gil= 1; // (PyThreadState_Get()==NULL); @@ -126,12 +126,6 @@ void BPY_pydriver_update(void) /* error return function for BPY_eval_pydriver */ static float pydriver_error(ChannelDriver *driver) { - if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */ - PyDict_Clear(bpy_pydriver_Dict); - Py_DECREF(bpy_pydriver_Dict); - bpy_pydriver_Dict = NULL; - } - driver->flag |= DRIVER_FLAG_INVALID; /* py expression failed */ fprintf(stderr, "\nError in Driver: The following Python expression failed:\n\t'%s'\n\n", driver->expression); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index a894fa60237..3478edb3809 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -302,7 +302,7 @@ void BPY_end_python( void ) /* Can run a file or text block */ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struct ReportList *reports) { - PyObject *py_dict, *py_result= NULL; + PyObject *py_dict= NULL, *py_result= NULL; PyGILState_STATE gilstate; if (fn==NULL && text==NULL) { @@ -373,8 +373,25 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc } else { Py_DECREF( py_result ); } - - PyDict_SetItemString(PyThreadState_GET()->interp->modules, "__main__", Py_None); + +/* super annoying, undo _PyModule_Clear() */ +#define PYMODULE_CLEAR_WORKAROUND + + if(py_dict) { +#ifdef PYMODULE_CLEAR_WORKAROUND + PyObject *py_dict_back= PyDict_Copy(py_dict); + Py_INCREF(py_dict); +#endif + /* normal */ + PyDict_SetItemString(PyThreadState_GET()->interp->modules, "__main__", Py_None); +#ifdef PYMODULE_CLEAR_WORKAROUND + PyDict_Clear(py_dict); + PyDict_Update(py_dict, py_dict_back); + Py_DECREF(py_dict); + Py_DECREF(py_dict_back); +#endif +#undef PYMODULE_CLEAR_WORKAROUND + } bpy_context_clear(C, &gilstate); diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index e78e79fd6a8..ea8d39806db 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -150,12 +150,13 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) { const char *msg= CTX_wm_operator_poll_msg_get(C); - PyErr_Format( PyExc_SystemError, "Operator bpy.ops.%.200s.poll() %s", opname, msg ? msg : "failed, context is incorrect"); + PyErr_Format(PyExc_SystemError, "Operator bpy.ops.%.200s.poll() %.200s", opname, msg ? msg : "failed, context is incorrect"); CTX_wm_operator_poll_msg_set(C, NULL); /* better set to NULL else it could be used again */ error_val= -1; } else { WM_operator_properties_create_ptr(&ptr, ot); + WM_operator_properties_sanitize(&ptr, 0); if(kw && PyDict_Size(kw)) error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: "); @@ -239,7 +240,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format( PyExc_SystemError, "_bpy.ops.as_string: operator \"%s\"could not be found", opname); + PyErr_Format(PyExc_SystemError, "_bpy.ops.as_string: operator \"%.200s\"could not be found", opname); return NULL; } @@ -306,6 +307,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value) /* XXX - should call WM_operator_properties_free */ WM_operator_properties_create_ptr(&ptr, ot); + WM_operator_properties_sanitize(&ptr, 0); pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr); diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 25351342402..6cf5e8e40c3 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -140,7 +140,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw) return NULL; \ } \ if(RNA_def_property_free_identifier(srna, id) == -1) { \ - PyErr_Format(PyExc_TypeError, #_func"(): '%s' is defined as a non-dynamic type.", id); \ + PyErr_Format(PyExc_TypeError, #_func"(): '%s' is defined as a non-dynamic type", id); \ return NULL; \ } \ if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, #_func"(options={...}):")) \ @@ -149,7 +149,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw) #define BPY_PROPDEF_SUBTYPE_CHECK(_func, _subtype) \ BPY_PROPDEF_CHECK(_func) \ if(pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \ - PyErr_Format(PyExc_TypeError, #_func"(subtype='%s'): invalid subtype.", pysubtype); \ + PyErr_Format(PyExc_TypeError, #_func"(subtype='%s'): invalid subtype", pysubtype); \ return NULL; \ } \ @@ -410,7 +410,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_subtype_number_items) if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) { - PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit."); + PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit"); return NULL; } @@ -762,7 +762,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw return NULL; /* self's type was compatible but error getting the srna */ } else if(srna==NULL) { - PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type."); + PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type"); return NULL; } else { @@ -774,7 +774,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw return NULL; if(RNA_def_property_free_identifier(srna, id) != 1) { - PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property.", id); + PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id); return NULL; } } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 2bffd7f6b88..ab1d0d1ab94 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -681,7 +681,7 @@ static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObj } else { if(PySet_GET_SIZE(value)) { - PyErr_Format(PyExc_TypeError, "%.200s: empty enum \"%.200s\" could not have any values assigned.", error_prefix, RNA_property_identifier(prop)); + PyErr_Format(PyExc_TypeError, "%.200s: empty enum \"%.200s\" could not have any values assigned", error_prefix, RNA_property_identifier(prop)); ret= -1; } else { @@ -861,7 +861,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha if (strcmp(arg_name, "rna_type")==0) continue; if (kw==NULL) { - PyErr_Format( PyExc_TypeError, "%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); + PyErr_Format(PyExc_TypeError, "%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); error_val= -1; break; } @@ -870,7 +870,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha if (item == NULL) { if(all_args) { - PyErr_Format( PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); + PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); error_val = -1; /* pyrna_py_to_prop sets the error */ break; } @@ -894,7 +894,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha arg_name= NULL; } - PyErr_Format( PyExc_TypeError, "%.200s: keyword \"%.200s\" unrecognized", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); + PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" unrecognized", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); error_val = -1; } @@ -910,7 +910,7 @@ static PyObject *pyrna_func_to_py(BPy_DummyPointerRNA *pyrna, FunctionRNA *func) PyObject *ret; if(func==NULL) { - PyErr_Format( PyExc_RuntimeError, "%.200s: type attempted to get NULL function", RNA_struct_identifier(pyrna->ptr.type)); + PyErr_Format(PyExc_RuntimeError, "%.200s: type attempted to get NULL function", RNA_struct_identifier(pyrna->ptr.type)); return NULL; } @@ -948,7 +948,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb } else /* continue... */ #endif if (!PySequence_Check(value)) { - PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment to %.200s.%.200s expected a sequence instead of %.200s instance.", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment to %.200s.%.200s expected a sequence instead of %.200s instance", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); return -1; } /* done getting the length */ @@ -1156,8 +1156,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb else { /* data==NULL, assign to RNA */ if(value == Py_None) { - PointerRNA valueptr; - memset(&valueptr, 0, sizeof(valueptr)); + PointerRNA valueptr= {{0}}; RNA_property_pointer_set(ptr, prop, valueptr); } else if(RNA_struct_is_a(param->ptr.type, ptype)) { @@ -1536,7 +1535,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject } } else { - PyErr_Format(PyExc_TypeError, "bpy_prop_collection[key]: invalid key, must be a string or an int instead of %.200s instance.", Py_TYPE(key)->tp_name); + PyErr_Format(PyExc_TypeError, "bpy_prop_collection[key]: invalid key, must be a string or an int instead of %.200s instance", Py_TYPE(key)->tp_name); return NULL; } } @@ -1585,7 +1584,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in int ret= 0; if(value_orig == NULL) { - PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct."); + PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice] = value: deleting with list types is not supported by bpy_struct"); return -1; } @@ -1595,7 +1594,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, PropertyRNA *prop, in if(PySequence_Fast_GET_SIZE(value) != stop-start) { Py_DECREF(value); - PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice] = value: resizing bpy_struct arrays isn't supported."); + PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice] = value: resizing bpy_struct arrays isn't supported"); return -1; } @@ -1811,12 +1810,12 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value) char *name = _PyUnicode_AsString(value); if (!name) { - PyErr_SetString( PyExc_TypeError, "bpy_struct.__contains__: expected a string"); + PyErr_SetString(PyExc_TypeError, "bpy_struct.__contains__: expected a string"); return -1; } if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString( PyExc_TypeError, "bpy_struct: this type doesnt support IDProperties"); + PyErr_SetString(PyExc_TypeError, "bpy_struct: this type doesnt support IDProperties"); return -1; } @@ -1874,26 +1873,26 @@ static PyObject *pyrna_struct_subscript( BPy_StructRNA *self, PyObject *key ) char *name= _PyUnicode_AsString(key); if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString( PyExc_TypeError, "this type doesn't support IDProperties"); + PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties"); return NULL; } if(name==NULL) { - PyErr_SetString( PyExc_TypeError, "bpy_struct[key]: only strings are allowed as keys of ID properties"); + PyErr_SetString(PyExc_TypeError, "bpy_struct[key]: only strings are allowed as keys of ID properties"); return NULL; } group= RNA_struct_idprops(&self->ptr, 0); if(group==NULL) { - PyErr_Format( PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name); + PyErr_Format(PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name); return NULL; } idprop= IDP_GetPropertyFromGroup(group, name); if(idprop==NULL) { - PyErr_Format( PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name); + PyErr_Format(PyExc_KeyError, "bpy_struct[key]: key \"%s\" not found", name); return NULL; } @@ -1933,7 +1932,7 @@ static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self) IDProperty *group; if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString( PyExc_TypeError, "bpy_struct.keys(): this type doesn't support IDProperties"); + PyErr_SetString(PyExc_TypeError, "bpy_struct.keys(): this type doesn't support IDProperties"); return NULL; } @@ -1960,7 +1959,7 @@ static PyObject *pyrna_struct_items(BPy_PropertyRNA *self) IDProperty *group; if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString( PyExc_TypeError, "bpy_struct.items(): this type doesn't support IDProperties"); + PyErr_SetString(PyExc_TypeError, "bpy_struct.items(): this type doesn't support IDProperties"); return NULL; } @@ -1987,7 +1986,7 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self) IDProperty *group; if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString( PyExc_TypeError, "bpy_struct.values(): this type doesn't support IDProperties"); + PyErr_SetString(PyExc_TypeError, "bpy_struct.values(): this type doesn't support IDProperties"); return NULL; } @@ -2033,7 +2032,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi } if (prop==NULL) { - PyErr_Format( PyExc_TypeError, "%.200s property \"%s\" not found", error_prefix, path); + PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not found", error_prefix, path); return -1; } @@ -2054,7 +2053,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi else { int array_len= RNA_property_array_length(&r_ptr, prop); if((*index) < -1 || (*index) >= array_len) { - PyErr_Format( PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len); + PyErr_Format(PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len); return -1; } } @@ -2066,7 +2065,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi *path_full= RNA_path_from_ID_to_property(&r_ptr, prop); if (*path_full==NULL) { - PyErr_Format( PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path); + PyErr_Format(PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path); return -1; } } @@ -2122,7 +2121,7 @@ static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *arg if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) return NULL; - result= PyBool_FromLong(insert_keyframe((ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0)); + result= PyBool_FromLong(insert_keyframe(/*ReportList*/NULL, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0)); MEM_freeN(path_full); return result; @@ -2156,7 +2155,7 @@ static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *arg if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_delete()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) return NULL; - result= PyBool_FromLong(delete_keyframe((ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0)); + result= PyBool_FromLong(delete_keyframe(/*ReportList*/NULL, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0)); MEM_freeN(path_full); return result; @@ -2587,7 +2586,7 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA *self, PyObject *pyname ) else if (self->ptr.type == &RNA_Context) { bContext *C = self->ptr.data; if(C==NULL) { - PyErr_Format( PyExc_AttributeError, "bpy_struct: Context is 'NULL', can't get \"%.200s\" from context", name); + PyErr_Format(PyExc_AttributeError, "bpy_struct: Context is 'NULL', can't get \"%.200s\" from context", name); ret= NULL; } else { @@ -2642,7 +2641,7 @@ static PyObject *pyrna_struct_getattro( BPy_StructRNA *self, PyObject *pyname ) } else { #if 0 - PyErr_Format( PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" not found", name); + PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" not found", name); ret = NULL; #endif /* Include this incase this instance is a subtype of a python class @@ -2714,7 +2713,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb char *attr_str= _PyUnicode_AsString(attr); int ret= RNA_def_property_free_identifier(srna, attr_str); if (ret == -1) { - PyErr_Format(PyExc_TypeError, "struct_meta_idprop.detattr(): '%s' not a dynamic property.", attr_str); + PyErr_Format(PyExc_TypeError, "struct_meta_idprop.detattr(): '%s' not a dynamic property", attr_str); return -1; } } @@ -2734,7 +2733,7 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec } else if (name[0] != '_' && (prop= RNA_struct_find_property(&self->ptr, name))) { if (!RNA_property_editable_flag(&self->ptr, prop)) { - PyErr_Format( PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only", RNA_property_identifier(prop), RNA_struct_identifier(self->ptr.type) ); + PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only", RNA_property_identifier(prop), RNA_struct_identifier(self->ptr.type) ); return -1; } } @@ -2856,7 +2855,7 @@ static int pyrna_prop_collection_setattro( BPy_PropertyRNA *self, PyObject *pyna } } - PyErr_Format( PyExc_AttributeError, "bpy_prop_collection: attribute \"%.200s\" not found", name); + PyErr_Format(PyExc_AttributeError, "bpy_prop_collection: attribute \"%.200s\" not found", name); return -1; } @@ -2867,7 +2866,7 @@ static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self) RNA_property_collection_add(&self->ptr, self->prop, &r_ptr); if(!r_ptr.data) { - PyErr_SetString( PyExc_TypeError, "bpy_prop_collection.add(): not supported for this collection"); + PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.add(): not supported for this collection"); return NULL; } else { @@ -2880,12 +2879,12 @@ static PyObject *pyrna_prop_collection_idprop_remove(BPy_PropertyRNA *self, PyOb int key= PyLong_AsLong(value); if (key==-1 && PyErr_Occurred()) { - PyErr_SetString( PyExc_TypeError, "bpy_prop_collection.remove(): expected one int argument"); + PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.remove(): expected one int argument"); return NULL; } if(!RNA_property_collection_remove(&self->ptr, self->prop, key)) { - PyErr_SetString( PyExc_TypeError, "bpy_prop_collection.remove() not supported for this collection"); + PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.remove() not supported for this collection"); return NULL; } @@ -2897,12 +2896,12 @@ static PyObject *pyrna_prop_collection_idprop_move(BPy_PropertyRNA *self, PyObje int key=0, pos=0; if (!PyArg_ParseTuple(args, "ii", &key, &pos)) { - PyErr_SetString( PyExc_TypeError, "bpy_prop_collection.move(): expected two ints as arguments"); + PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.move(): expected two ints as arguments"); return NULL; } if(!RNA_property_collection_move(&self->ptr, self->prop, key, pos)) { - PyErr_SetString( PyExc_TypeError, "bpy_prop_collection.move() not supported for this collection"); + PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.move() not supported for this collection"); return NULL; } @@ -3033,7 +3032,7 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args) /* mostly copied from BPy_IDGroup_Map_GetItem */ if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString( PyExc_TypeError, "this type doesn't support IDProperties"); + PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties"); return NULL; } @@ -3115,7 +3114,7 @@ static int foreach_parse_args( *raw_type= PROP_RAW_UNSET; if(!PyArg_ParseTuple(args, "sO", attr, seq) || (!PySequence_Check(*seq) && PyObject_CheckBuffer(*seq))) { - PyErr_SetString( PyExc_TypeError, "foreach_get(attr, sequence) expects a string and a sequence" ); + PyErr_SetString(PyExc_TypeError, "foreach_get(attr, sequence) expects a string and a sequence"); return -1; } @@ -3139,7 +3138,7 @@ static int foreach_parse_args( /* rna_access.c - rna_raw_access(...) uses this same method */ if(target_tot != (*tot)) { - PyErr_Format( PyExc_TypeError, "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d", *tot, target_tot); + PyErr_Format(PyExc_TypeError, "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d", *tot, target_tot); return -1; } #endif @@ -3148,7 +3147,7 @@ static int foreach_parse_args( /* check 'attr_tot' otherwise we dont know if any values were set * this isnt ideal because it means running on an empty list may fail silently when its not compatible. */ if (*size == 0 && *attr_tot != 0) { - PyErr_SetString( PyExc_AttributeError, "attribute does not support foreach method" ); + PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method"); return -1; } return 0; @@ -3442,7 +3441,7 @@ static PyObject * pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject return (PyObject *)ret; } else { - PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): type '%.200s' is not a subtype of bpy_struct.", type->tp_name); + PyErr_Format(PyExc_TypeError, "bpy_struct.__new__(type): type '%.200s' is not a subtype of bpy_struct", type->tp_name); return NULL; } } @@ -3466,7 +3465,7 @@ static PyObject * pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *U return (PyObject *)ret; } else { - PyErr_Format(PyExc_TypeError, "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop.", type->tp_name); + PyErr_Format(PyExc_TypeError, "bpy_prop.__new__(type): type '%.200s' is not a subtype of bpy_prop", type->tp_name); return NULL; } } @@ -4517,7 +4516,7 @@ PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr ) } if( !pyrna ) { - PyErr_SetString( PyExc_MemoryError, "couldn't create bpy_struct object" ); + PyErr_SetString(PyExc_MemoryError, "couldn't create bpy_struct object"); return NULL; } @@ -4557,7 +4556,7 @@ PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop ) } if( !pyrna ) { - PyErr_SetString( PyExc_MemoryError, "couldn't create BPy_rna object" ); + PyErr_SetString(PyExc_MemoryError, "couldn't create BPy_rna object"); return NULL; } @@ -4945,7 +4944,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun if (base_class) { if (!PyObject_IsSubclass(py_class, base_class)) { - PyErr_Format( PyExc_TypeError, "expected %.200s subclass of class \"%.200s\"", class_type, py_class_name); + PyErr_Format(PyExc_TypeError, "expected %.200s subclass of class \"%.200s\"", class_type, py_class_name); return -1; } } @@ -4967,7 +4966,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun if (item==NULL) { if ((flag & FUNC_REGISTER_OPTIONAL)==0) { - PyErr_Format( PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, RNA_function_identifier(func)); + PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, RNA_function_identifier(func)); return -1; } @@ -4977,14 +4976,14 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun Py_DECREF(item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */ if(flag & FUNC_NO_SELF) { if (PyMethod_Check(item)==0) { - PyErr_Format( PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); + PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); return -1; } item= ((PyMethodObject *)item)->im_func; } else { if (PyFunction_Check(item)==0) { - PyErr_Format( PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a function, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); + PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a function, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); return -1; } } @@ -5002,7 +5001,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun func_arg_count++; if (arg_count != func_arg_count) { - PyErr_Format( PyExc_AttributeError, "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d", class_type, py_class_name, RNA_function_identifier(func), func_arg_count, arg_count); + PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d", class_type, py_class_name, RNA_function_identifier(func), func_arg_count, arg_count); return -1; } } @@ -5044,7 +5043,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun #undef BPY_REPLACEMENT_STRING if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) { - PyErr_Format( PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, identifier); + PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, identifier); return -1; } @@ -5187,14 +5186,14 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par else { PyErr_Print(); PyErr_Clear(); - PyErr_Format(PyExc_TypeError, "could not find function %.200s in %.200s to execute callback.", RNA_function_identifier(func), RNA_struct_identifier(ptr->type)); + PyErr_Format(PyExc_TypeError, "could not find function %.200s in %.200s to execute callback", RNA_function_identifier(func), RNA_struct_identifier(ptr->type)); err= -1; } } else { /* the error may be alredy set if the class instance couldnt be created */ if(err != -1) { - PyErr_Format(PyExc_RuntimeError, "could not create instance of %.200s to call callback function %.200s.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func)); + PyErr_Format(PyExc_RuntimeError, "could not create instance of %.200s to call callback function %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func)); err= -1; } } @@ -5204,7 +5203,7 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par } else { if(ret_len==0 && ret != Py_None) { - PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return None, got a %.200s type instead.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), Py_TYPE(ret)->tp_name); + PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return None, got a %.200s type instead", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), Py_TYPE(ret)->tp_name); err= -1; } else if(ret_len==1) { @@ -5213,11 +5212,11 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par else if (ret_len > 1) { if(PyTuple_Check(ret)==0) { - PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d, got a %.200s type instead.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len, Py_TYPE(ret)->tp_name); + PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d, got a %.200s type instead", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len, Py_TYPE(ret)->tp_name); err= -1; } else if (PyTuple_GET_SIZE(ret) != ret_len) { - PyErr_Format(PyExc_RuntimeError, "class %.200s, function %.200s to returned %d items, expected %d.", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), PyTuple_GET_SIZE(ret), ret_len); + PyErr_Format(PyExc_RuntimeError, "class %.200s, function %.200s to returned %d items, expected %d", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), PyTuple_GET_SIZE(ret), ret_len); err= -1; } else { @@ -5244,6 +5243,20 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par } if(err != 0) { + ReportList *reports; + /* alert the user, else they wont know unless they see the console. */ + if (!is_static && ptr->data && RNA_struct_is_a(ptr->type, &RNA_Operator)) { + wmOperator *op= ptr->data; + reports= op->reports; + } + else { + /* wont alert users but they can view in 'info' space */ + reports= CTX_wm_reports(C); + } + + BPy_errors_to_report(reports); + + /* also print in the console for py */ PyErr_Print(); PyErr_Clear(); } @@ -5355,7 +5368,7 @@ static PyObject *pyrna_basetype_register(PyObject *UNUSED(self), PyObject *py_cl const char *identifier; if(PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "bl_rna")) { - PyErr_SetString(PyExc_AttributeError, "bpy.types.register(...): already registered as a subclass."); + PyErr_SetString(PyExc_AttributeError, "bpy.types.register(...): already registered as a subclass"); return NULL; } @@ -5367,7 +5380,7 @@ static PyObject *pyrna_basetype_register(PyObject *UNUSED(self), PyObject *py_cl /* fails in cases, cant use this check but would like to :| */ /* if(RNA_struct_py_type_get(srna)) { - PyErr_Format(PyExc_ValueError, "bpy.types.register(...): %.200s's parent class %.200s is alredy registered, this is not allowed.", ((PyTypeObject*)py_class)->tp_name, RNA_struct_identifier(srna)); + PyErr_Format(PyExc_ValueError, "bpy.types.register(...): %.200s's parent class %.200s is alredy registered, this is not allowed", ((PyTypeObject*)py_class)->tp_name, RNA_struct_identifier(srna)); return NULL; } */ @@ -5376,7 +5389,7 @@ static PyObject *pyrna_basetype_register(PyObject *UNUSED(self), PyObject *py_cl reg= RNA_struct_register(srna); if(!reg) { - PyErr_Format(PyExc_ValueError, "bpy.types.register(...): expected a subclass of a registerable rna type (%.200s does not support registration).", RNA_struct_identifier(srna)); + PyErr_Format(PyExc_ValueError, "bpy.types.register(...): expected a subclass of a registerable rna type (%.200s does not support registration)", RNA_struct_identifier(srna)); return NULL; } @@ -5450,7 +5463,7 @@ static PyObject *pyrna_basetype_unregister(PyObject *UNUSED(self), PyObject *py_ /*if(PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "bl_rna")==NULL) { PWM_cursor_wait(0); - PyErr_SetString(PyExc_ValueError, "bpy.types.unregister(): not a registered as a subclass."); + PyErr_SetString(PyExc_ValueError, "bpy.types.unregister(): not a registered as a subclass"); return NULL; }*/ @@ -5462,7 +5475,7 @@ static PyObject *pyrna_basetype_unregister(PyObject *UNUSED(self), PyObject *py_ unreg= RNA_struct_unregister(srna); if(!unreg) { - PyErr_SetString(PyExc_ValueError, "bpy.types.unregister(...): expected a Type subclassed from a registerable rna type (no unregister supported)."); + PyErr_SetString(PyExc_ValueError, "bpy.types.unregister(...): expected a Type subclassed from a registerable rna type (no unregister supported)"); return NULL; } @@ -5489,7 +5502,7 @@ static PyObject *pyrna_basetype_unregister(PyObject *UNUSED(self), PyObject *py_ RNA_PROP_END; if(prop_identifier) { - PyErr_Format(PyExc_SystemError, "bpy.types.unregister(...): Cant unregister %s because %s.%s pointer property is using this.", RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); + PyErr_Format(PyExc_SystemError, "bpy.types.unregister(...): Cant unregister %s because %s.%s pointer property is using this", RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); return NULL; } } diff --git a/source/blender/python/intern/bpy_array.c b/source/blender/python/intern/bpy_rna_array.c index d219757b777..d219757b777 100644 --- a/source/blender/python/intern/bpy_array.c +++ b/source/blender/python/intern/bpy_rna_array.c diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 81d6e0cd4da..633ee070d9a 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -111,7 +111,7 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args) handle= PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID); if(handle==NULL) { - PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed."); + PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed"); return NULL; } diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 1a2d7b297b6..a5535b7cd39 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -43,7 +43,7 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c if (base_class) { if (!PyObject_IsSubclass(class, base_class)) { PyObject *name= PyObject_GetAttrString(base_class, "__name__"); - PyErr_Format( PyExc_AttributeError, "expected %s subclass of class \"%s\"", class_type, name ? _PyUnicode_AsString(name):"<UNKNOWN>"); + PyErr_Format(PyExc_AttributeError, "expected %s subclass of class \"%s\"", class_type, name ? _PyUnicode_AsString(name):"<UNKNOWN>"); Py_XDECREF(name); return -1; } @@ -57,7 +57,7 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c if (item==NULL) { if ((class_attrs->flag & BPY_CLASS_ATTR_OPTIONAL)==0) { - PyErr_Format( PyExc_AttributeError, "expected %s class to have an \"%s\" attribute", class_type, class_attrs->name); + PyErr_Format(PyExc_AttributeError, "expected %s class to have an \"%s\" attribute", class_type, class_attrs->name); return -1; } @@ -73,22 +73,22 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c switch(class_attrs->type) { case 's': if (PyUnicode_Check(item)==0) { - PyErr_Format( PyExc_AttributeError, "expected %s class \"%s\" attribute to be a string", class_type, class_attrs->name); + PyErr_Format(PyExc_AttributeError, "expected %s class \"%s\" attribute to be a string", class_type, class_attrs->name); return -1; } if(class_attrs->len != -1 && class_attrs->len < PyUnicode_GetSize(item)) { - PyErr_Format( PyExc_AttributeError, "expected %s class \"%s\" attribute string to be shorter then %d", class_type, class_attrs->name, class_attrs->len); + PyErr_Format(PyExc_AttributeError, "expected %s class \"%s\" attribute string to be shorter then %d", class_type, class_attrs->name, class_attrs->len); return -1; } break; case 'l': if (PyList_Check(item)==0) { - PyErr_Format( PyExc_AttributeError, "expected %s class \"%s\" attribute to be a list", class_type, class_attrs->name); + PyErr_Format(PyExc_AttributeError, "expected %s class \"%s\" attribute to be a list", class_type, class_attrs->name); return -1; } if(class_attrs->len != -1 && class_attrs->len < PyList_GET_SIZE(item)) { - PyErr_Format( PyExc_AttributeError, "expected %s class \"%s\" attribute list to be shorter then %d", class_type, class_attrs->name, class_attrs->len); + PyErr_Format(PyExc_AttributeError, "expected %s class \"%s\" attribute list to be shorter then %d", class_type, class_attrs->name, class_attrs->len); return -1; } break; @@ -99,7 +99,7 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c fitem= item; /* py 3.x */ if (PyFunction_Check(fitem)==0) { - PyErr_Format( PyExc_AttributeError, "expected %s class \"%s\" attribute to be a function", class_type, class_attrs->name); + PyErr_Format(PyExc_AttributeError, "expected %s class \"%s\" attribute to be a function", class_type, class_attrs->name); return -1; } if (class_attrs->arg_count >= 0) { /* -1 if we dont care*/ @@ -108,7 +108,7 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c Py_DECREF(py_arg_count); if (arg_count != class_attrs->arg_count) { - PyErr_Format( PyExc_AttributeError, "expected %s class \"%s\" function to have %d args", class_type, class_attrs->name, class_attrs->arg_count); + PyErr_Format(PyExc_AttributeError, "expected %s class \"%s\" function to have %d args", class_type, class_attrs->name, class_attrs->arg_count); return -1; } } @@ -215,7 +215,7 @@ int PyC_AsArray(void *array, PyObject *value, int length, PyTypeObject *type, ch if(value_len != length) { Py_DECREF(value); - PyErr_Format(PyExc_TypeError, "%s: invalid sequence length. expected %d, got %d.", error_prefix, length, value_len); + PyErr_Format(PyExc_TypeError, "%.200s: invalid sequence length. expected %d, got %d", error_prefix, length, value_len); return -1; } @@ -240,14 +240,14 @@ int PyC_AsArray(void *array, PyObject *value, int length, PyTypeObject *type, ch } else { Py_DECREF(value_fast); - PyErr_Format(PyExc_TypeError, "%s: internal error %s is invalid.", error_prefix, type->tp_name); + PyErr_Format(PyExc_TypeError, "%s: internal error %s is invalid", error_prefix, type->tp_name); return -1; } Py_DECREF(value_fast); if(PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "%s: one or more items could not be used as a %s.", error_prefix, type->tp_name); + PyErr_Format(PyExc_TypeError, "%s: one or more items could not be used as a %s", error_prefix, type->tp_name); return -1; } diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c index d6dc5059342..ee124e2c06f 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -29,7 +29,7 @@ /* python, will come back */ //void BPY_run_python_script() {} //void BPY_start_python() {} -void BPY_call_importloader() {} +void BPY_call_importloader(const char *filepath) {(void)filepath;} //void BPY_free_compiled_text() {} void BPY_pyconstraint_eval() {} void BPY_pyconstraint_target() {} diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index f067d717a7c..06cfb82e904 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -79,7 +79,7 @@ void quicktime_exit(void) } -int anim_is_quicktime (char *name) +int anim_is_quicktime (const char *name) { NSAutoreleasePool *pool; diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c index 08196553a79..cec5a1735fc 100644 --- a/source/blender/quicktime/apple/quicktime_import.c +++ b/source/blender/quicktime/apple/quicktime_import.c @@ -170,7 +170,7 @@ char *get_valid_qtname(char *name) #endif /* _WIN32 */ -int anim_is_quicktime (char *name) +int anim_is_quicktime (const char *name) { FSSpec theFSSpec; char theFullPath[255]; diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h index 150aa07b1c2..bfc71b65127 100644 --- a/source/blender/quicktime/quicktime_import.h +++ b/source/blender/quicktime/quicktime_import.h @@ -62,7 +62,7 @@ char *get_valid_qtname(char *name); // quicktime movie import functions -int anim_is_quicktime (char *name); +int anim_is_quicktime (const char *name); int startquicktime (struct anim *anim); void free_anim_quicktime (struct anim *anim); ImBuf *qtime_fetchibuf (struct anim *anim, int position); diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index b65aefeb162..0be9796fabd 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -78,10 +78,6 @@ SET(SRC intern/source/zbuf.c ) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_IMAGE_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_IMAGE_OPENEXR) diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 265788830bc..58b3cec82c9 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -145,7 +145,8 @@ typedef struct RenderStats { int totface, totvert, totstrand, tothalo, totlamp, totpart; short curfield, curblur, curpart, partsdone, convertdone; double starttime, lastframetime; - char *infostr, *statstr, scenename[32]; + const char *infostr, *statstr; + char scenename[32]; } RenderStats; @@ -288,15 +289,15 @@ typedef struct RenderEngine { ListBase fullresult; } RenderEngine; -void RE_layer_load_from_file(RenderLayer *layer, struct ReportList *reports, char *filename); -void RE_result_load_from_file(RenderResult *result, struct ReportList *reports, char *filename); +void RE_layer_load_from_file(RenderLayer *layer, struct ReportList *reports, const char *filename); +void RE_result_load_from_file(RenderResult *result, struct ReportList *reports, const char *filename); struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h); void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result); void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result); int RE_engine_test_break(RenderEngine *engine); -void RE_engine_update_stats(RenderEngine *engine, char *stats, char *info); +void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info); void RE_engines_init(void); void RE_engines_exit(void); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index a908133a7ce..76befcaeb12 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2786,7 +2786,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) float len, *data, *fp, *orco=NULL, *orcobase= NULL; float n[3], mat[4][4]; int nr, startvert, startvlak, a, b; - int frontside, need_orco=0, totmat; + int need_orco=0, totmat; cu= ob->data; if(ob->type==OB_FONT && cu->str==NULL) return; @@ -2844,15 +2844,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, data); - /* flip normal if face is backfacing, also used in face loop below */ - if(ver->co[2] < 0.0) { - VECCOPY(ver->n, n); - ver->flag = 1; - } - else { - ver->n[0]= -n[0]; ver->n[1]= -n[1]; ver->n[2]= -n[2]; - ver->flag = 0; - } + negate_v3_v3(ver->n, n); mul_m4_v3(mat, ver->co); @@ -2873,12 +2865,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) vlr->v3= RE_findOrAddVert(obr, startvert+index[2]); vlr->v4= NULL; - if(vlr->v1->flag) { - VECCOPY(vlr->n, n); - } - else { - vlr->n[0]= -n[0]; vlr->n[1]= -n[1]; vlr->n[2]= -n[2]; - } + negate_v3_v3(vlr->n, n); vlr->mat= matar[ dl->col ]; vlr->flag= 0; @@ -2917,8 +2904,6 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for(a=0; a<dl->parts; a++) { - frontside= (a >= dl->nr/2); - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) break; @@ -2929,25 +2914,16 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for(; b<dl->nr; b++) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); - vlr->v1= RE_findOrAddVert(obr, p2); - vlr->v2= RE_findOrAddVert(obr, p1); - vlr->v3= RE_findOrAddVert(obr, p3); - vlr->v4= RE_findOrAddVert(obr, p4); - vlr->ec= ME_V2V3+ME_V3V4; + vlr->v1= RE_findOrAddVert(obr, p1); + vlr->v2= RE_findOrAddVert(obr, p2); + vlr->v3= RE_findOrAddVert(obr, p4); + vlr->v4= RE_findOrAddVert(obr, p3); + vlr->ec= ME_V4V1+ME_V3V4; if(a==0) vlr->ec+= ME_V1V2; vlr->flag= dl->rt; - /* this is not really scientific: the vertices - * 2, 3 en 4 seem to give better vertexnormals than 1 2 3: - * front and backside treated different!! - */ - - if(frontside) - normal_tri_v3( vlr->n,vlr->v2->co, vlr->v3->co, vlr->v4->co); - else - normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co); - + normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= matar[ dl->col ]; p4= p3; @@ -2975,15 +2951,6 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for(a=startvert; a<obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); len= normalize_v3(ver->n); - if(len==0.0) ver->flag= 1; /* flag abuse, its only used in zbuf now */ - else ver->flag= 0; - } - for(a= startvlak; a<obr->totvlak; a++) { - vlr= RE_findOrAddVlak(obr, a); - if(vlr->v1->flag) VECCOPY(vlr->v1->n, vlr->n); - if(vlr->v2->flag) VECCOPY(vlr->v2->n, vlr->n); - if(vlr->v3->flag) VECCOPY(vlr->v3->n, vlr->n); - if(vlr->v4->flag) VECCOPY(vlr->v4->n, vlr->n); } } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 0bd8858d9d4..46377bc4831 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -930,7 +930,7 @@ static void renderresult_add_names(RenderResult *rr) } /* called for reading temp files, and for external engines */ -static int read_render_result_from_file(char *filename, RenderResult *rr) +static int read_render_result_from_file(const char *filename, RenderResult *rr) { RenderLayer *rl; RenderPass *rpass; @@ -2548,6 +2548,7 @@ static void do_render_seq(Render * re) struct ImBuf *ibuf; RenderResult *rr; /* don't assign re->result here as it might change during give_ibuf_seq */ int cfra = re->r.cfra; + SeqRenderData context; re->i.cfra= cfra; @@ -2558,7 +2559,11 @@ static void do_render_seq(Render * re) recurs_depth++; - ibuf= give_ibuf_seq(re->main, re->scene, re->result->rectx, re->result->recty, cfra, 0, 100.0); + context = seq_new_render_data(re->main, re->scene, + re->result->rectx, re->result->recty, + 100); + + ibuf = give_ibuf_seq(context, cfra, 0); recurs_depth--; @@ -2931,19 +2936,19 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr if(render_initialize_from_main(re, bmain, scene, srl, lay, 0, 0)) { MEM_reset_peak_memory(); do_render_all_options(re); - } - if(write_still) { - if(BKE_imtype_is_movie(scene->r.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, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE); - - /* reports only used for Movie */ - do_write_image_or_movie(re, scene, NULL, NULL, name); + if(write_still && !G.afbreek) { + if(BKE_imtype_is_movie(scene->r.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, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE); + + /* reports only used for Movie */ + do_write_image_or_movie(re, scene, NULL, NULL, name); + } } } @@ -3324,7 +3329,7 @@ int RE_engine_test_break(RenderEngine *engine) return re->test_break(re->tbh); } -void RE_engine_update_stats(RenderEngine *engine, char *stats, char *info) +void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info) { Render *re= engine->re; @@ -3337,7 +3342,7 @@ void RE_engine_update_stats(RenderEngine *engine, char *stats, char *info) /* loads in image into a result, size must match * x/y offsets are only used on a partial copy when dimensions dont match */ -void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, char *filename) +void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char *filename) { ImBuf *ibuf = IMB_loadiffname(filename, IB_rect); @@ -3377,7 +3382,7 @@ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, char *file } } -void RE_result_load_from_file(RenderResult *result, ReportList *reports, char *filename) +void RE_result_load_from_file(RenderResult *result, ReportList *reports, const char *filename) { if(!read_render_result_from_file(filename, result)) { BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 17ec48c8422..d2e9765c722 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -468,7 +468,9 @@ void makeraytree(Render *re) max[i] += 0.01f; sub[i] = max[i]-min[i]; } - re->maxdist = sqrt( sub[0]*sub[0] + sub[1]*sub[1] + sub[2]*sub[2] ); + + re->maxdist= sub[0]*sub[0] + sub[1]*sub[1] + sub[2]*sub[2]; + if(re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist); re->i.infostr= "Raytree finished"; re->stats_draw(re->sdh, &re->i); diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 814c4413525..5eb91845dc2 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1415,10 +1415,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } if(i_noshad>0.0f) { if(passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) { - if(ma->mode & MA_SHADOW_TRA) - add_to_diffuse(shr->diff, shi, is, i_noshad*shadfac[0]*lacol[0], i_noshad*shadfac[1]*lacol[1], i_noshad*shadfac[2]*lacol[2]); - else - add_to_diffuse(shr->diff, shi, is, i_noshad*lacol[0], i_noshad*lacol[1], i_noshad*lacol[2]); + add_to_diffuse(shr->diff, shi, is, i_noshad*lacol[0], i_noshad*lacol[1], i_noshad*lacol[2]); } else VECCOPY(shr->diff, shr->shad); @@ -1649,12 +1646,14 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if(R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { if(((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) { - /* AO was calculated for scanline already */ - if(shi->depth || shi->volume_depth) - ambient_occlusion(shi); - VECCOPY(shr->ao, shi->ao); - VECCOPY(shr->env, shi->env); // XXX multiply - VECCOPY(shr->indirect, shi->indirect); // XXX multiply + if(R.r.mode & R_SHADOW) { + /* AO was calculated for scanline already */ + if(shi->depth || shi->volume_depth) + ambient_occlusion(shi); + VECCOPY(shr->ao, shi->ao); + VECCOPY(shr->env, shi->env); // XXX multiply + VECCOPY(shr->indirect, shi->indirect); // XXX multiply + } } } @@ -1770,18 +1769,20 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) /* from now stuff everything in shr->combined: ambient, AO, radio, ramps, exposure */ if(!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) { - /* add AO in combined? */ - if(R.wrld.mode & WO_AMB_OCC) - if(shi->combinedflag & SCE_PASS_AO) - ambient_occlusion_apply(shi, shr); - - if(R.wrld.mode & WO_ENV_LIGHT) - if(shi->combinedflag & SCE_PASS_ENVIRONMENT) - environment_lighting_apply(shi, shr); - - if(R.wrld.mode & WO_INDIRECT_LIGHT) - if(shi->combinedflag & SCE_PASS_INDIRECT) - indirect_lighting_apply(shi, shr); + if(R.r.mode & R_SHADOW) { + /* add AO in combined? */ + if(R.wrld.mode & WO_AMB_OCC) + if(shi->combinedflag & SCE_PASS_AO) + ambient_occlusion_apply(shi, shr); + + if(R.wrld.mode & WO_ENV_LIGHT) + if(shi->combinedflag & SCE_PASS_ENVIRONMENT) + environment_lighting_apply(shi, shr); + + if(R.wrld.mode & WO_INDIRECT_LIGHT) + if(shi->combinedflag & SCE_PASS_INDIRECT) + indirect_lighting_apply(shi, shr); + } shr->combined[0]+= shi->ambr; shr->combined[1]+= shi->ambg; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 843f05f3766..7bc1a0611f0 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -2689,10 +2689,19 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f case TEXCO_ANGMAP: /* only works with texture being "real" */ /* use saacos(), fixes bug [#22398], float precission caused lo[2] to be slightly less then -1.0 */ - fact= (1.0/M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1])); - tempvec[0]= lo[0]*fact; - tempvec[1]= lo[1]*fact; - tempvec[2]= 0.0; + if(lo[0] || lo[1]) { /* check for zero case [#24807] */ + fact= (1.0/M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1])); + tempvec[0]= lo[0]*fact; + tempvec[1]= lo[1]*fact; + tempvec[2]= 0.0; + } + else { + /* this value has no angle, the vector is directly along the view. + * avoide divide by zero and use a dummy value. */ + tempvec[0]= 1.0f; + tempvec[1]= 0.0; + tempvec[2]= 0.0; + } co= tempvec; break; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 914092f6c41..ac4aba3e4de 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -39,6 +39,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" #include "BKE_modifier.h" @@ -262,11 +263,12 @@ static void init_frame_smoke(VoxelData *vd) return; } -static void cache_voxeldata(struct Render *re,Tex *tex) +static void cache_voxeldata(struct Render *re, Tex *tex) { VoxelData *vd = tex->vd; FILE *fp; int curframe; + char path[FILE_MAX]; if (!vd) return; @@ -285,6 +287,8 @@ static void cache_voxeldata(struct Render *re,Tex *tex) else curframe = re->r.cfra; + BLI_strncpy(path, vd->source_path, FILE_MAX); + switch(vd->file_format) { case TEX_VD_IMAGE_SEQUENCE: load_frame_image_sequence(vd, tex); @@ -293,8 +297,9 @@ static void cache_voxeldata(struct Render *re,Tex *tex) init_frame_smoke(vd); return; case TEX_VD_BLENDERVOXEL: - if (!BLI_exists(vd->source_path)) return; - fp = fopen(vd->source_path,"rb"); + BLI_path_abs(path, G.main->name); + if (!BLI_exists(path)) return; + fp = fopen(path,"rb"); if (!fp) return; if(read_voxeldata_header(fp, vd)) @@ -304,8 +309,9 @@ static void cache_voxeldata(struct Render *re,Tex *tex) return; case TEX_VD_RAW_8BIT: - if (!BLI_exists(vd->source_path)) return; - fp = fopen(vd->source_path,"rb"); + BLI_path_abs(path, G.main->name); + if (!BLI_exists(path)) return; + fp = fopen(path,"rb"); if (!fp) return; if (load_frame_raw8(vd, fp, curframe)) @@ -355,7 +361,7 @@ int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres) add_v3_v3(co, offset); /* co is now in the range 0.0, 1.0 */ - switch (tex->extend) { + switch (vd->extend) { case TEX_CLIP: { if ((co[0] < 0.f || co[0] > 1.f) || (co[1] < 0.f || co[1] > 1.f) || (co[2] < 0.f || co[2] > 1.f)) { diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 6c93334fd0a..e47d85cd462 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -93,10 +93,6 @@ IF(WITH_GAMEENGINE) ADD_DEFINITIONS(-DWITH_GAMEENGINE) ENDIF(WITH_GAMEENGINE) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_COCOA) LIST(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/intern/wm_apple.c") ENDIF(WITH_COCOA) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 5d856036180..405db630932 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -83,7 +83,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type); /* files */ int WM_read_homefile (struct bContext *C, struct wmOperator *op); int WM_write_homefile (struct bContext *C, struct wmOperator *op); -void WM_read_file (struct bContext *C, char *name, struct ReportList *reports); +void WM_read_file (struct bContext *C, const char *name, struct ReportList *reports); int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy); void WM_read_autosavefile(struct bContext *C); void WM_autosave_init (struct wmWindowManager *wm); @@ -103,8 +103,8 @@ void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle); void WM_cursor_warp (struct wmWindow *win, int x, int y); /* keyconfig and keymap */ -wmKeyConfig *WM_keyconfig_new (struct wmWindowManager *wm, char *idname); -wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, char *idname); +wmKeyConfig *WM_keyconfig_new (struct wmWindowManager *wm, const char *idname); +wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname); void WM_keyconfig_remove (struct wmWindowManager *wm, struct wmKeyConfig *keyconf); void WM_keyconfig_free (struct wmKeyConfig *keyconf); void WM_keyconfig_userdef(void); @@ -114,7 +114,7 @@ void WM_keymap_free (struct wmKeyMap *keymap); wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, char *idname, int type, int val, int modifier, int keymodifier); -wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, char *idname, int type, +wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier); wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, char *idname, int type, int val, int modifier, int keymodifier); @@ -122,11 +122,11 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, char *idname, int type void WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len); -wmKeyMap *WM_keymap_list_find(ListBase *lb, char *idname, int spaceid, int regionid); -wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, char *idname, int spaceid, int regionid); -wmKeyMap *WM_keymap_find_all(const struct bContext *C, char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_find_all(const struct bContext *C, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap); -wmKeyMap *WM_keymap_guess_opname(const struct bContext *C, char *opname); +wmKeyMap *WM_keymap_guess_opname(const struct bContext *C, const char *opname); int WM_keymap_user_init(struct wmWindowManager *wm, struct wmKeyMap *keymap); wmKeyMap *WM_keymap_copy_to_user(struct wmKeyMap *keymap); void WM_keymap_restore_to_default(struct wmKeyMap *keymap); @@ -137,10 +137,10 @@ wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id); int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2); int WM_userdef_event_map(int kmitype); -wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, struct EnumPropertyItem *items); -wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, char *idname); +wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, struct EnumPropertyItem *items); +wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname); wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value); -void WM_modalkeymap_assign(struct wmKeyMap *km, char *opname); +void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname); const char *WM_key_event_string(short type); int WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, int hotkey, struct wmKeyMap **keymap_r); @@ -213,7 +213,7 @@ void WM_operatortype_append_ptr (void (*opfunc)(struct wmOperatorType*, void *) void WM_operatortype_append_macro_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); int WM_operatortype_remove(const char *idname); -struct wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag); +struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, int flag); struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); @@ -225,7 +225,7 @@ int WM_operator_name_call (struct bContext *C, const char *opstring, int conte int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports); void WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */ -void WM_operator_properties_sanitize(struct PointerRNA *ptr, int val); /* make props context sensitive or not */ +void WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context); /* make props context sensitive or not */ void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring); void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot); void WM_operator_properties_free(struct PointerRNA *ptr); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index cae875a9b06..e8bb86d7237 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -386,9 +386,9 @@ typedef struct wmTimer { typedef struct wmOperatorType { struct wmOperatorType *next, *prev; - char *name; /* text for ui, undo */ - char *idname; /* unique identifier */ - char *description; /* tooltips and python docs */ + const char *name; /* text for ui, undo */ + const char *idname; /* unique identifier */ + const char *description; /* tooltips and python docs */ /* this callback executes the operator without any interactive input, * parameters may be provided through operator properties. cannot use diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 18b1e7239ed..0b2d35eb8bb 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -167,7 +167,7 @@ void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy) } -static char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event) +static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event) { wmEventHandler *handler= handlers->first; for(; handler; handler= handler->next) { @@ -183,12 +183,12 @@ static char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEve } /* return active operator name when mouse is in box */ -static char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) +static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) { wmWindow *win= CTX_wm_window(C); ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); - char *name; + const char *name; name= dropbox_active(C, &win->handlers, drag, event); if(name) return name; @@ -218,7 +218,7 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event) strcpy(drag->opname, "Paste name"); } else { - char *opname= wm_dropbox_active(C, drag, event); + const char *opname= wm_dropbox_active(C, drag, event); if(opname) { BLI_strncpy(drag->opname, opname, FILE_MAX); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5e5d236a0f9..39467381a66 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -620,7 +620,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) } } - if(screen->do_draw_gesture) + /* always draw, not only when screen tagged */ + if(win->gesture.first) wm_gesture_draw(win); if(wm->paintcursors.first) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index c30152c05eb..6aec8659533 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -426,7 +426,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop WM_event_remove_timer(wm, NULL, reports->reporttimer); /* Records time since last report was added */ - reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02); + reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.05); rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo"); reports->reporttimer->customdata = rti; @@ -438,7 +438,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop */ static int wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot) { - return (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER); + return wm && (wm->op_undo_depth == 0) && (ot->flag & OPTYPE_REGISTER); } static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) @@ -751,6 +751,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA case WM_OP_EXEC_REGION_CHANNELS: case WM_OP_INVOKE_REGION_CHANNELS: type = RGN_TYPE_CHANNELS; + break; case WM_OP_EXEC_REGION_PREVIEW: case WM_OP_INVOKE_REGION_PREVIEW: @@ -831,7 +832,6 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe */ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports) { - wmWindowManager *wm= CTX_wm_manager(C); int retval= OPERATOR_CANCELLED; #if 0 @@ -855,7 +855,7 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA /* keep the reports around if needed later */ if ( (retval & OPERATOR_RUNNING_MODAL) || - ((retval & OPERATOR_FINISHED) && wm_operator_register_check(wm, ot)) + ((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot)) ) { reports->flag |= RPT_FREE; /* let blender manage freeing */ } @@ -1722,7 +1722,11 @@ void wm_event_do_handlers(bContext *C) } action |= wm_handlers_do(C, event, &ar->handlers); - + + /* fileread case (python), [#29489] */ + if(CTX_wm_window(C)==NULL) + return; + doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y)); if(action & WM_HANDLER_BREAK) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e6d750ce8c1..d2c1a2dc0dc 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -262,7 +262,7 @@ static void wm_init_userdef(bContext *C) if(U.tempdir[0]) BLI_where_is_temp(btempdir, 1); } -void WM_read_file(bContext *C, char *name, ReportList *reports) +void WM_read_file(bContext *C, const char *name, ReportList *reports) { int retval; @@ -319,6 +319,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ + BPY_reset_driver(); BPY_load_user_modules(C); #endif CTX_wm_window_set(C, NULL); /* exits queues */ @@ -353,7 +354,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) tstr[0] = '\0'; from_memory = 1; if (op) { - BKE_report(op->reports, RPT_INFO, "Config directory with startup.blend file found."); + BKE_report(op->reports, RPT_INFO, "Config directory with startup.blend file not found."); } } } @@ -410,6 +411,9 @@ int WM_read_homefile(bContext *C, wmOperator *op) if(CTX_py_init_get(C)) { /* sync addons, these may have changed from the defaults */ BPY_eval_string(C, "__import__('bpy').utils.addon_reset_all()"); + + BPY_reset_driver(); + BPY_load_user_modules(C); } #endif diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 855317b9f76..f75a1c0fb7f 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -146,6 +146,8 @@ void WM_init(bContext *C, int argc, char **argv) #ifdef WITH_PYTHON BPY_set_context(C); /* necessary evil */ BPY_start_python(argc, argv); + + BPY_reset_driver(); BPY_load_user_modules(C); #else (void)argc; /* unused */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 628c2aa1922..a005da43a9a 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -75,7 +75,7 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties keymap_properties_set(kmi); } -wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, char *idname) +wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname) { wmKeyConfig *keyconf; @@ -86,7 +86,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, char *idname) return keyconf; } -wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, char *idname) +wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname) { wmKeyConfig *keyconf = WM_keyconfig_new(wm, idname); @@ -222,7 +222,7 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, char *idname, int type, in } /* always add item */ -wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, char *idname, int type, int val, int modifier, int keymodifier) +wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) { wmKeyMapItem *kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); @@ -265,7 +265,7 @@ void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) space/region ids are same as DNA_space_types.h */ /* gets free'd in wm.c */ -wmKeyMap *WM_keymap_list_find(ListBase *lb, char *idname, int spaceid, int regionid) +wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid) { wmKeyMap *km; @@ -277,7 +277,7 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, char *idname, int spaceid, int regio return NULL; } -wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, char *idname, int spaceid, int regionid) +wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); @@ -292,7 +292,7 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, char *idname, int spaceid, int re return km; } -wmKeyMap *WM_keymap_find_all(const bContext *C, char *idname, int spaceid, int regionid) +wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, int regionid) { wmWindowManager *wm = CTX_wm_manager(C); wmKeyConfig *keyconf; @@ -323,7 +323,7 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, char *idname, int spaceid, int r /* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */ -wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items) +wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPropertyItem *items) { wmKeyMap *km= WM_keymap_find(keyconf, idname, 0, 0); km->flag |= KEYMAP_MODAL; @@ -332,7 +332,7 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, char *idname, EnumPropertyIte return km; } -wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, char *idname) +wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname) { wmKeyMap *km; @@ -362,7 +362,7 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif return kmi; } -void WM_modalkeymap_assign(wmKeyMap *km, char *opname) +void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) { wmOperatorType *ot= WM_operatortype_find(opname, 0); @@ -757,7 +757,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id) /* Guess an appropriate keymap from the operator name */ /* Needs to be kept up to date with Keymap and Operator naming */ -wmKeyMap *WM_keymap_guess_opname(const bContext *C, char *opname) +wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) { wmKeyMap *km=NULL; SpaceLink *sl = CTX_wm_space_data(C); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4a0aaecfbf9..74eaeed0ac0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -317,7 +317,7 @@ static int wm_macro_cancel(bContext *C, wmOperator *op) } /* Names have to be static for now */ -wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag) +wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, int flag) { wmOperatorType *ot; @@ -585,12 +585,12 @@ void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, con } -void WM_operator_properties_sanitize(PointerRNA *ptr, int val) +void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context) { RNA_STRUCT_BEGIN(ptr, prop) { switch(RNA_property_type(prop)) { case PROP_ENUM: - if (val) + if (no_context) RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); else RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); @@ -602,7 +602,7 @@ void WM_operator_properties_sanitize(PointerRNA *ptr, int val) /* recurse into operator properties */ if (RNA_struct_is_a(ptype, &RNA_OperatorProperties)) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - WM_operator_properties_sanitize(&opptr, val); + WM_operator_properties_sanitize(&opptr, no_context); } break; } @@ -654,7 +654,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) /* generic enum search invoke popup */ -static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, char *str, uiSearchItems *items) +static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, const char *str, uiSearchItems *items) { wmOperatorType *ot = (wmOperatorType *)arg_ot; PropertyRNA *prop= ot->prop; @@ -869,7 +869,7 @@ int WM_operator_winactive(bContext *C) return 1; } -/* op->invoke */ +/* op->exec */ static void redo_cb(bContext *C, void *arg_op, int UNUSED(event)) { wmOperator *lastop= arg_op; @@ -1281,7 +1281,7 @@ static void operator_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); } -static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), char *str, uiSearchItems *items) +static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { wmOperatorType *ot = WM_operatortype_first(); @@ -2041,7 +2041,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot) /* *********************** */ #if defined(WIN32) static int console= 1; -void WM_toggle_console(bContext *C, short show) +void WM_toggle_console(bContext *UNUSED(C), short show) { if(show) { ShowWindow(GetConsoleWindow(),SW_SHOW); @@ -2053,7 +2053,7 @@ void WM_toggle_console(bContext *C, short show) } } -static int wm_toggle_console_op(bContext *C, wmOperator *op) +static int wm_toggle_console_op(bContext *C, wmOperator *UNUSED(op)) { if(console) { WM_toggle_console(C, 0); @@ -3124,7 +3124,7 @@ void wm_operatortype_free(void) wm_operatortype_free_macro(ot); if(ot->ext.srna) /* python operator, allocs own string */ - MEM_freeN(ot->idname); + MEM_freeN((void *)ot->idname); } BLI_freelistN(&global_ops); @@ -3426,12 +3426,10 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* Generic itemf's for operators that take library args */ static EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), int *free, ID *id, int local) { - EnumPropertyItem *item= NULL, item_tmp; + EnumPropertyItem item_tmp= {0}, *item= NULL; int totitem= 0; int i= 0; - memset(&item_tmp, 0, sizeof(item_tmp)); - for( ; id; id= id->next) { if(local==FALSE || id->lib==NULL) { item_tmp.identifier= item_tmp.name= id->name+2; diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index b3c9aede6b5..d1aee8c9d16 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -43,17 +43,17 @@ ADD_CUSTOM_COMMAND( DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ) -IF(WIN32) +IF(WIN32 AND NOT UNIX) ADD_EXECUTABLE(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc) -ELSE(WIN32) +ELSE(WIN32 AND NOT UNIX) ADD_EXECUTABLE(blenderplayer ${CMAKE_CURRENT_BINARY_DIR}/dna.c) -ENDIF(WIN32) +ENDIF(WIN32 AND NOT UNIX) ADD_DEPENDENCIES(blenderplayer makesdna) FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS) -SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} gp_common gp_ghost blenkernel_blc) +SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} ge_player_common ge_player_ghost blenkernel_blc) IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc) @@ -62,53 +62,53 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(UNIX) # Sort libraries SET(BLENDER_SORTED_LIBS - gp_ghost - gp_common + ge_player_ghost + ge_player_common bf_intern_string bf_intern_ghost bf_rna bf_blenkernel bf_blenloader bf_blenpluginapi - bf_blroutines + ge_blen_routines bf_editor_datafiles - bf_converter - bf_ketsji - bf_bullet - bf_dummy - bf_common - bf_logic - bf_rasterizer - bf_oglrasterizer - bf_expressions - bf_scenegraph + ge_converter + ge_logic_ketsji + ge_phys_bullet + ge_phys_dummy + ge_phys_common + ge_logic + ge_rasterizer + ge_oglrasterizer + ge_logic_expressions + ge_scenegraph bf_ikplugin bf_intern_itasc bf_intern_ik bf_intern_smoke bf_modifiers bf_intern_moto - bf_kernel + bf_gen_system bf_nodes bf_gpu bf_imbuf bf_avi - kx_network - bf_ngnetwork - bf_loopbacknetwork + ge_logic_network + ge_logic_ngnetwork + ge_logic_loopbacknetwork extern_bullet bf_intern_guardedalloc bf_intern_memutil bf_python bf_python_ext bf_blenlib - bf_cineon - bf_openexr + bf_imbuf_cineon + bf_imbuf_openexr extern_openjpeg - bf_dds + bf_imbuf_dds bf_readblenfile bf_dna - bf_videotex + ge_videotex bf_blenfont bf_intern_audaspace blenkernel_blc diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index e1683fe972e..23046734cda 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -139,6 +139,7 @@ void WM_menutype_free(void){} void WM_menutype_freelink(struct MenuType* mt){} int WM_menutype_add(struct MenuType *mt) {return 0;} int WM_operator_props_dialog_popup (struct bContext *C, struct wmOperator *op, int width, int height){return 0;} +int WM_operator_confirm(struct bContext *C, struct wmOperator *op, struct wmEvent *event){return 0;} struct MenuType *WM_menutype_find(const char *idname, int quiet){return (struct MenuType *) NULL;} void WM_operator_stack_clear(struct bContext *C) {} @@ -216,6 +217,7 @@ char *ED_info_stats_string(struct Scene *scene){return (char *) NULL;} void ED_area_tag_redraw(struct ScrArea *sa){} void ED_area_tag_refresh(struct ScrArea *sa){} void ED_area_newspace(struct bContext *C, struct ScrArea *sa, int type){} +void ED_region_tag_redraw(struct ARegion *ar){} void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op){} void WM_cursor_wait (int val) {} void ED_node_texture_default(struct Tex *tx){} @@ -314,7 +316,7 @@ void uiTemplateHeader(struct uiLayout *layout, struct bContext *C, int menus){} void uiTemplateID(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *unlinkop){} struct uiLayout *uiTemplateModifier(struct uiLayout *layout, struct PointerRNA *ptr){return (struct uiLayout *) NULL;} struct uiLayout *uiTemplateConstraint(struct uiLayout *layout, struct PointerRNA *ptr){return (struct uiLayout *) NULL;} -void uiTemplatePreview(struct uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot){} +void uiTemplatePreview(struct uiLayout *layout, struct ID *id, int show_buttons, struct ID *parent, struct MTex *slot){} void uiTemplateIDPreview(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop, int rows, int cols){} void uiTemplateCurveMapping(struct uiLayout *layout, struct CurveMapping *cumap, int type, int compact){} void uiTemplateColorRamp(struct uiLayout *layout, struct ColorBand *coba, int expand){} @@ -361,6 +363,7 @@ int WM_operator_props_popup(struct bContext *C, struct wmOperator *op, struct wm void WM_operator_properties_free(struct PointerRNA *ptr){} void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring){} void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot){} +void WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context){}; void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType*, void*), void *userdata){} void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType*, void*), void *userdata){} void WM_operator_bl_idname(char *to, const char *from){} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index e42f707a38e..98e8d649b10 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -43,10 +43,6 @@ INCLUDE_DIRECTORIES( ../blender/windowmanager ) -IF(WIN32) - INCLUDE_DIRECTORIES(${PTHREADS_INC}) -ENDIF(WIN32) - IF(WITH_QUICKTIME) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) @@ -97,14 +93,14 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") # Setup the exe sources and buildinfo SET(EXESRC creator.c) -IF(WIN32) +IF(WIN32 AND NOT UNIX) LIST(APPEND EXESRC ../icons/winblender.rc) -ENDIF(WIN32) +ENDIF(WIN32 AND NOT UNIX) IF(WITH_BUILDINFO) - STRING(REPLACE " " "\ " BUILDINFO_CFLAGS ${CMAKE_C_FLAGS}) - STRING(REPLACE " " "\ " BUILDINFO_CXXFLAGS ${CMAKE_CXX_FLAGS}) - STRING(REPLACE " " "\ " BUILDINFO_LINKFLAGS ${PLATFORM_LINKFLAGS}) + STRING(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}") + STRING(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}") + STRING(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}") ADD_DEFINITIONS( -DBUILD_DATE="${BUILD_DATE}" -DBUILD_TIME="${BUILD_TIME}" @@ -255,53 +251,7 @@ IF(WITH_INSTALL) # end "make install" - ENDIF(UNIX AND NOT APPLE) - - IF(APPLE) - SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) - SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) - SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist) - - ADD_CUSTOM_COMMAND( - TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/ - COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/ - COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/ - COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO} - COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION} - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION} - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ - COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ - ) - - IF(WITH_INTERNATIONAL) - ADD_CUSTOM_COMMAND( - TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ - ) - ENDIF(WITH_INTERNATIONAL) - - IF(WITH_PYTHON) - SET(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip") - ADD_CUSTOM_COMMAND( - TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/ - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/ - COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/ - COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;" - ) - ENDIF(WITH_PYTHON) - - ADD_CUSTOM_COMMAND( - TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;" - ) - ENDIF(APPLE) - - IF(WIN32) + ELSEIF(WIN32) # notice 'xcopy /Y /H' on .bfont.ttf, this is needed when building over samba ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD @@ -354,6 +304,8 @@ IF(WITH_INSTALL) POST_BUILD MAIN_DEPENDENCY blender COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" + COMMAND if \"$(ConfigurationName)\" == \"\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\" + COMMAND if \"$(ConfigurationName)\" == \"\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\" COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\" COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\" COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\" @@ -452,7 +404,50 @@ IF(WITH_INSTALL) ENDIF(NOT CMAKE_CL_64) ENDIF(WITH_SDL) - ENDIF(WIN32) + ELSEIF(APPLE) + SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) + SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) + SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist) + + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/ + COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/ + COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/ + COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO} + COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION} + COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION} + COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ + COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ + ) + + IF(WITH_INTERNATIONAL) + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ + COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/ + ) + ENDIF(WITH_INTERNATIONAL) + + IF(WITH_PYTHON) + SET(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip") + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/ + COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/ + COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/ + COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;" + ) + ENDIF(WITH_PYTHON) + + ADD_CUSTOM_COMMAND( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;" + COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;" + COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;" + ) + ENDIF(UNIX AND NOT APPLE) + ENDIF(WITH_INSTALL) ADD_DEPENDENCIES(blender makesdna) @@ -526,44 +521,44 @@ ENDIF(WITH_MOD_FLUID) bf_blenpluginapi bf_imbuf bf_avi - bf_cineon - bf_openexr - bf_dds + bf_imbuf_cineon + bf_imbuf_openexr + bf_imbuf_dds bf_readblenfile bf_collada bf_intern_bsp bf_intern_bop - bf_kernel + bf_gen_system bf_intern_decimate bf_intern_elbeem bf_intern_ik bf_intern_memutil bf_intern_guardedalloc bf_intern_ctr - bf_blroutines - bf_converter - bf_dummy - bf_bullet + ge_blen_routines + ge_converter + ge_phys_dummy + ge_phys_bullet bf_intern_smoke extern_minilzo extern_lzma - bf_ketsji - bf_common - bf_logic - bf_rasterizer - bf_oglrasterizer - bf_expressions - bf_scenegraph - kx_network - bf_kernel + ge_logic_ketsji + ge_phys_common + ge_logic + ge_rasterizer + ge_oglrasterizer + ge_logic_expressions + ge_scenegraph + ge_logic_network + bf_gen_system bf_python # duplicate for BPY_eval_driver - bf_ngnetwork + ge_logic_ngnetwork extern_bullet - bf_loopbacknetwork + ge_logic_loopbacknetwork bf_intern_moto extern_glew extern_openjpeg - bf_videotex + ge_videotex bf_rna bf_dna bf_blenfont diff --git a/source/creator/creator.c b/source/creator/creator.c index ed7dce0ebe1..a83cfc62e14 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -909,6 +909,16 @@ static int load_file(int UNUSED(argc), char **argv, void *data) pointcache works */ if (retval!=0) { wmWindowManager *wm= CTX_wm_manager(C); + + /* special case, 2.4x files */ + if(wm==NULL && CTX_data_main(C)->wm.first==NULL) { + extern void wm_add_default(bContext *C); + + /* wm_add_default() needs the screen to be set. */ + CTX_wm_screen_set(C, CTX_data_main(C)->screen.first); + wm_add_default(C); + } + CTX_wm_manager_set(C, NULL); /* remove wm to force check */ WM_check(C); G.relbase_valid = 1; @@ -918,6 +928,7 @@ static int load_file(int UNUSED(argc), char **argv, void *data) /* WM_read_file() runs normally but since we're in background mode do here */ #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ + BPY_reset_driver(); BPY_load_user_modules(C); #endif diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 1f895ad0abc..63382e1f325 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -54,4 +54,4 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -BLENDERLIB(bf_blroutines "${SRC}" "${INC}") +BLENDERLIB(ge_blen_routines "${SRC}" "${INC}") diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 91dc2692384..ff70ad3bf7b 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -35,4 +35,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] -env.BlenderLib ( 'bf_bloutines', sources, Split(incs), defs, libtype=['core','player'], priority=[300,35] , cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_blen_routines', sources, Split(incs), defs, libtype=['core','player'], priority=[300,35] , cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 9e0b4242f28..4e64bcf8b11 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -92,4 +92,4 @@ IF(WITH_BULLET) ADD_DEFINITIONS(-DUSE_BULLET) ENDIF(WITH_BULLET) -BLENDERLIB(bf_converter "${SRC}" "${INC}") +BLENDERLIB(ge_converter "${SRC}" "${INC}") diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 05b0e75b070..723b849f4c7 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -777,8 +777,8 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) mat3_to_compatible_eul(blenderObject->rot, blenderObject->rot, tmat); - insert_keyframe(&blenderObject->id, NULL, NULL, "location", -1, frameNumber, INSERTKEY_FAST); - insert_keyframe(&blenderObject->id, NULL, NULL, "rotation_euler", -1, frameNumber, INSERTKEY_FAST); + insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "location", -1, frameNumber, INSERTKEY_FAST); + insert_keyframe(NULL, &blenderObject->id, NULL, NULL, "rotation_euler", -1, frameNumber, INSERTKEY_FAST); #if 0 const MT_Point3& position = gameObj->NodeGetWorldPosition(); diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index f6cf2331a43..9d88018d805 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -37,4 +37,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: if env['WITH_BF_BULLET']: defs.append('USE_BULLET') -env.BlenderLib ( 'bf_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,40], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_converter', sources, Split(incs), defs, libtype=['core','player'], priority=[305,40], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index ad446d1085e..5ab7c6eeae2 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -61,4 +61,4 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -BLENDERLIB(bf_expressions "${SRC}" "${INC}") +BLENDERLIB(ge_logic_expressions "${SRC}" "${INC}") diff --git a/source/gameengine/Expressions/KX_Python.h b/source/gameengine/Expressions/KX_Python.h index 62353f04e50..234b70770f6 100644 --- a/source/gameengine/Expressions/KX_Python.h +++ b/source/gameengine/Expressions/KX_Python.h @@ -66,5 +66,15 @@ #endif #endif +#ifdef __APPLE__ +#undef isalnum +#undef isalpha +#undef islower +#undef isspace +#undef isupper +#undef tolower +#undef toupper +#endif + #endif // KX_PYTHON_H diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript index dea652dabb4..b1e34aa358b 100644 --- a/source/gameengine/Expressions/SConscript +++ b/source/gameengine/Expressions/SConscript @@ -14,4 +14,4 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') -env.BlenderLib ( 'bf_expressions', sources, Split(incs), defs, libtype=['core','player'], priority = [360,80], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_logic_expressions', sources, Split(incs), defs, libtype=['core','player'], priority = [360,80], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index b346df2b340..1f0850d6970 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -90,4 +90,4 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -BLENDERLIB(bf_logic "${SRC}" "${INC}") +BLENDERLIB(ge_logic "${SRC}" "${INC}") diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index 04990e10d06..a8d3ee65f4c 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -26,4 +26,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') incs += ' #/intern/guardedalloc' -env.BlenderLib ( 'bf_logic', sources, Split(incs), defs, libtype=['core','player'], priority=[330,65], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_logic', sources, Split(incs), defs, libtype=['core','player'], priority=[330,65], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index 39667a27c7d..3ed2490aadd 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -76,4 +76,4 @@ ENDIF(WITH_PYTHON) ADD_DEFINITIONS(-DGLEW_STATIC) -BLENDERLIB_NOLIST(gp_common "${SRC}" "${INC}") +BLENDERLIB_NOLIST(ge_player_common "${SRC}" "${INC}") diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index 60cb437b10f..86fb66974db 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -67,4 +67,4 @@ if env['WITH_BF_PYTHON']: incs += Split(env['BF_PNG_INC']) incs += Split(env['BF_ZLIB_INC']) -env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = defs, libtype=['player'], priority=[5], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib (libname='ge_player_common', sources=source_files, includes=incs, defines = defs, libtype=['player'], priority=[5], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 824b11d77f8..8810e875810 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -76,4 +76,4 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -BLENDERLIB_NOLIST(gp_ghost "${SRC}" "${INC}") +BLENDERLIB_NOLIST(ge_player_ghost "${SRC}" "${INC}") diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index eb3d50a49bd..7c8f1c6f4f0 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -50,4 +50,4 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') -env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = defs, libtype=['player'],priority=[0], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib (libname='ge_player_ghost', sources=source_files, includes = incs, defines = defs, libtype=['player'],priority=[0], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 1ca71e678e8..7b5a70f0676 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -147,4 +147,4 @@ IF(WITH_BULLET) LIST(APPEND INC ../../../source/gameengine/Physics/Bullet ) ENDIF(WITH_BULLET) -BLENDERLIB(bf_ketsji "${SRC}" "${INC}") +BLENDERLIB(ge_logic_ketsji "${SRC}" "${INC}") diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt index 5099534c0ad..ce9a7492ba1 100644 --- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt +++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt @@ -49,4 +49,4 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -BLENDERLIB(kx_network "${SRC}" "${INC}") +BLENDERLIB(ge_logic_network "${SRC}" "${INC}") diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 46a92365302..1711ba7f64f 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -706,6 +706,7 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at } self->m_camdata.m_perspective= param; + self->InvalidateProjectionMatrix(); return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 60dc3be7d6e..7cbdd3bba66 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -31,6 +31,7 @@ #include "KX_PyMath.h" #include "PHY_IPhysicsController.h" #include "PHY_IMotionState.h" +#include "DNA_sensor_types.h" /** * RadarSensor constructor. Creates a near-sensor derived class, with a cone collision shape. @@ -95,42 +96,42 @@ void KX_RadarSensor::SynchronizeTransform() // depends on the radar 'axis' switch (m_axis) { - case 0: // +X Axis + case SENS_RADAR_X_AXIS: // +X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); trans.rotate(rotquatje); trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); break; }; - case 1: // +Y Axis + case SENS_RADAR_Y_AXIS: // +Y Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); trans.rotate(rotquatje); trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); break; }; - case 2: // +Z Axis + case SENS_RADAR_Z_AXIS: // +Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); trans.rotate(rotquatje); trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); break; }; - case 3: // -X Axis + case SENS_RADAR_NEG_X_AXIS: // -X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90)); trans.rotate(rotquatje); trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); break; }; - case 4: // -Y Axis + case SENS_RADAR_NEG_Y_AXIS: // -Y Axis { //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); //trans.rotate(rotquatje); trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); break; }; - case 5: // -Z Axis + case SENS_RADAR_NEG_Z_AXIS: // -Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90)); trans.rotate(rotquatje); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 001c7a290d7..2434c031a6a 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -42,6 +42,7 @@ #include "PHY_IPhysicsEnvironment.h" #include "KX_IPhysicsController.h" #include "PHY_IPhysicsController.h" +#include "DNA_sensor_types.h" #include <stdio.h> @@ -198,42 +199,42 @@ bool KX_RaySensor::Evaluate() m_reset = false; switch (m_axis) { - case 1: // X + case SENS_RAY_X_AXIS: // X { todir[0] = invmat[0][0]; todir[1] = invmat[0][1]; todir[2] = invmat[0][2]; break; } - case 0: // Y + case SENS_RAY_Y_AXIS: // Y { todir[0] = invmat[1][0]; todir[1] = invmat[1][1]; todir[2] = invmat[1][2]; break; } - case 2: // Z + case SENS_RAY_Z_AXIS: // Z { todir[0] = invmat[2][0]; todir[1] = invmat[2][1]; todir[2] = invmat[2][2]; break; } - case 3: // -X + case SENS_RAY_NEG_X_AXIS: // -X { todir[0] = -invmat[0][0]; todir[1] = -invmat[0][1]; todir[2] = -invmat[0][2]; break; } - case 4: // -Y + case SENS_RAY_NEG_Y_AXIS: // -Y { todir[0] = -invmat[1][0]; todir[1] = -invmat[1][1]; todir[2] = -invmat[1][2]; break; } - case 5: // -Z + case SENS_RAY_NEG_Z_AXIS: // -Z { todir[0] = -invmat[2][0]; todir[1] = -invmat[2][1]; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c48112dbcb7..0605650bb09 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1722,6 +1722,11 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene if(sg) { if(sg->GetSGClientInfo() == from) { sg->SetSGClientInfo(to); + + /* Make sure to grab the children too since they might not be tied to a game object */ + NodeList children = sg->GetSGChildren(); + for (int i=0; i<children.size(); i++) + children[i]->SetSGClientInfo(to); } #ifdef USE_BULLET SGControllerList::iterator contit; diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 5f7cf9edcd8..3e86080a2f8 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -46,4 +46,4 @@ if env['WITH_BF_BULLET']: defs.append('USE_BULLET') incs += ' #source/gameengine/Physics/Bullet' -env.BlenderLib ( 'bf_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320,45], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_logic_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320,45], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt index 3dde84d29c1..b46f6696efd 100644 --- a/source/gameengine/Network/CMakeLists.txt +++ b/source/gameengine/Network/CMakeLists.txt @@ -37,4 +37,4 @@ SET(SRC NG_NetworkScene.cpp ) -BLENDERLIB(bf_ngnetwork "${SRC}" "${INC}") +BLENDERLIB(ge_logic_ngnetwork "${SRC}" "${INC}") diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt index eae2971ce6a..9467b59310f 100644 --- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt +++ b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt @@ -35,4 +35,4 @@ SET(SRC NG_LoopBackNetworkDeviceInterface.cpp ) -BLENDERLIB(bf_loopbacknetwork "${SRC}" "${INC}") +BLENDERLIB(ge_logic_loopbacknetwork "${SRC}" "${INC}") diff --git a/source/gameengine/Network/LoopBackNetwork/SConscript b/source/gameengine/Network/LoopBackNetwork/SConscript index dd23e1327eb..af76065cc94 100644 --- a/source/gameengine/Network/LoopBackNetwork/SConscript +++ b/source/gameengine/Network/LoopBackNetwork/SConscript @@ -5,4 +5,4 @@ sources = 'NG_LoopBackNetworkDeviceInterface.cpp' incs = '. #source/kernel/gen_system #intern/string #source/gameengine/Network' -env.BlenderLib ( 'bf_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['core','player'], priority=[400,135] ) +env.BlenderLib ( 'ge_logic_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['core','player'], priority=[400,135] ) diff --git a/source/gameengine/Network/SConscript b/source/gameengine/Network/SConscript index 3cf1747d013..1b63592d0a4 100644 --- a/source/gameengine/Network/SConscript +++ b/source/gameengine/Network/SConscript @@ -11,4 +11,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') incs += ' #intern/guardedalloc' -env.BlenderLib ( 'bf_ngnetwork', sources, Split(incs), defs, libtype=['core','player'], priority=[400,130] ) +env.BlenderLib ( 'ge_logic_ngnetwork', sources, Split(incs), defs, libtype=['core','player'], priority=[400,130] ) diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index 1954d58df3e..89f2649cfc1 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -57,4 +57,4 @@ IF(WITH_BULLET) ADD_DEFINITIONS(-DUSE_BULLET) ENDIF(WITH_BULLET) -BLENDERLIB(bf_bullet "${SRC}" "${INC}") +BLENDERLIB(ge_phys_bullet "${SRC}" "${INC}") diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index 272d0003c1a..f8f0f8afaea 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -32,4 +32,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: if env['WITH_BF_BULLET']: defs.append('USE_BULLET') -env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,50], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_phys_bullet', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,50], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Physics/Dummy/CMakeLists.txt b/source/gameengine/Physics/Dummy/CMakeLists.txt index 501fbcd94de..387fa9e7f8d 100644 --- a/source/gameengine/Physics/Dummy/CMakeLists.txt +++ b/source/gameengine/Physics/Dummy/CMakeLists.txt @@ -33,4 +33,4 @@ SET(SRC DummyPhysicsEnvironment.cpp ) -BLENDERLIB(bf_dummy "${SRC}" "${INC}") +BLENDERLIB(ge_phys_dummy "${SRC}" "${INC}") diff --git a/source/gameengine/Physics/Dummy/SConscript b/source/gameengine/Physics/Dummy/SConscript index 496092133c3..13d1a893823 100644 --- a/source/gameengine/Physics/Dummy/SConscript +++ b/source/gameengine/Physics/Dummy/SConscript @@ -11,4 +11,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') incs += ' #intern/guardedalloc' -env.BlenderLib ( 'bf_dummy', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,60] ) +env.BlenderLib ( 'ge_phys_dummy', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[350,60] ) diff --git a/source/gameengine/Physics/common/CMakeLists.txt b/source/gameengine/Physics/common/CMakeLists.txt index f67de0f77d0..0710ba3e2c6 100644 --- a/source/gameengine/Physics/common/CMakeLists.txt +++ b/source/gameengine/Physics/common/CMakeLists.txt @@ -38,4 +38,4 @@ SET(SRC PHY_IVehicle.cpp ) -BLENDERLIB(bf_common "${SRC}" "${INC}") +BLENDERLIB(ge_phys_common "${SRC}" "${INC}") diff --git a/source/gameengine/Physics/common/SConscript b/source/gameengine/Physics/common/SConscript index 38bb7a11309..abff3e33121 100644 --- a/source/gameengine/Physics/common/SConscript +++ b/source/gameengine/Physics/common/SConscript @@ -11,4 +11,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') incs += ' #intern/guardedalloc' -env.BlenderLib ( 'bf_physics_common', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[360,55], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_phys_common', Split(sources), Split(incs), defs, libtype=['core','player'], priority=[360,55], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 9bbf7e144d5..88399f9ca9d 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -53,4 +53,4 @@ SET(SRC ADD_DEFINITIONS(-DGLEW_STATIC) -BLENDERLIB(bf_rasterizer "${SRC}" "${INC}") +BLENDERLIB(ge_rasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index a89faae3c73..36ccd79527b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -48,4 +48,4 @@ SET(SRC ADD_DEFINITIONS(-DGLEW_STATIC) -BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}") +BLENDERLIB(ge_oglrasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 8ad6a8b28a2..791478cae38 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -13,4 +13,4 @@ incs += ' #intern/guardedalloc #source/blender/blenlib' if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') -env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), defines = defs, libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_oglrasterizer', Split(sources), Split(incs), defines = defs, libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index 045714e80ac..bff2a7e2084 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -15,4 +15,4 @@ if env['WITH_BF_PYTHON']: if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') -env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), defs, libtype=['core','player'], priority=[350,70], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_rasterizer', sources, Split(incs), defs, libtype=['core','player'], priority=[350,70], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/SceneGraph/CMakeLists.txt b/source/gameengine/SceneGraph/CMakeLists.txt index d1b207b6efa..1ba1f8175cd 100644 --- a/source/gameengine/SceneGraph/CMakeLists.txt +++ b/source/gameengine/SceneGraph/CMakeLists.txt @@ -38,4 +38,4 @@ SET(SRC SG_Tree.cpp ) -BLENDERLIB(bf_scenegraph "${SRC}" "${INC}") +BLENDERLIB(ge_scenegraph "${SRC}" "${INC}") diff --git a/source/gameengine/SceneGraph/SConscript b/source/gameengine/SceneGraph/SConscript index 992a10befa2..b4738bd20b4 100644 --- a/source/gameengine/SceneGraph/SConscript +++ b/source/gameengine/SceneGraph/SConscript @@ -12,4 +12,4 @@ if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') incs += ' #intern/guardedalloc' -env.BlenderLib ( 'bf_scenegraph', sources, Split(incs), defs, libtype=['core','player'], priority=[325,85], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_scenegraph', sources, Split(incs), defs, libtype=['core','player'], priority=[325,85], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index 1bde0bc8a40..3ad74ef7860 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -78,4 +78,4 @@ IF(WITH_PYTHON) ADD_DEFINITIONS(-DWITH_PYTHON) ENDIF(WITH_PYTHON) -BLENDERLIB(bf_videotex "${SRC}" "${INC}") +BLENDERLIB(ge_videotex "${SRC}" "${INC}") diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index 8a5e3726aa7..2cd143d2deb 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -27,4 +27,4 @@ if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') incs += ' ' + env['BF_FFMPEG_INC'] + ' ' + env['BF_PTHREADS_INC'] -env.BlenderLib ( 'bf_videotex', sources, Split(incs), defs, libtype=['core','player'], priority=[340,205], cxx_compileflags=env['BGE_CXXFLAGS']) +env.BlenderLib ( 'ge_videotex', sources, Split(incs), defs, libtype=['core','player'], priority=[340,205], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/kernel/CMakeLists.txt b/source/kernel/CMakeLists.txt index 1665a3c1525..8705dbcdc24 100644 --- a/source/kernel/CMakeLists.txt +++ b/source/kernel/CMakeLists.txt @@ -35,9 +35,8 @@ SET(INC SET(SRC gen_messaging/intern/messaging.c gen_system/GEN_HashedPtr.cpp - gen_system/GEN_Matrix4x4.cpp gen_system/SYS_SingletonSystem.cpp gen_system/SYS_System.cpp ) -BLENDERLIB(bf_kernel "${SRC}" "${INC}") +BLENDERLIB(bf_gen_system "${SRC}" "${INC}") diff --git a/source/kernel/SConscript b/source/kernel/SConscript index 3110f46cfad..8dd0fd36e8a 100644 --- a/source/kernel/SConscript +++ b/source/kernel/SConscript @@ -2,9 +2,9 @@ Import ('env') sources = 'gen_messaging/intern/messaging.c gen_system/GEN_HashedPtr.cpp' -sources += ' gen_system/GEN_Matrix4x4.cpp gen_system/SYS_SingletonSystem.cpp' +sources += ' gen_system/SYS_SingletonSystem.cpp' sources += ' gen_system/SYS_System.cpp' incs = 'gen_messaging gen_system #/intern/string #/intern/moto/include #/source/blender/blenloader ' -env.BlenderLib ( 'bf_kernel', Split(sources), Split(incs), [], libtype = ['core','player'], priority = [400,100] ) +env.BlenderLib ( 'bf_gen_system', Split(sources), Split(incs), [], libtype = ['core','player'], priority = [400,100] ) diff --git a/source/kernel/gen_system/GEN_DataCache.h b/source/kernel/gen_system/GEN_DataCache.h deleted file mode 100644 index 96ceafc232d..00000000000 --- a/source/kernel/gen_system/GEN_DataCache.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef __GEN_DATACACHE_H -#define __GEN_DATACACHE_H - -#include "STR_HashedString.h" -#include "GEN_Map.h" - -template <class T> -class GEN_DataCache -{ - GEN_Map<STR_HashedString,T*> m_dataCache; - virtual T* LoadData(const STR_String& name)=0; - virtual void FreeCacheObjects()=0; - -public: - GEN_DataCache() {}; - virtual ~GEN_DataCache() {}; - - T* GetData(const STR_String& paramname) - { - T* result=NULL; - - T** resultptr = m_dataCache[paramname]; - if (resultptr) - { - result = *resultptr; - } - - else - { - result = LoadData(paramname); - if (result) - { - m_dataCache.insert(paramname,result); - } - } - - return result; - } - - virtual void ClearCache() - { - FreeCacheObjects(); - m_dataCache.clear(); - } -}; - -#endif //__GEN_DATACACHE_H - diff --git a/source/kernel/gen_system/GEN_Matrix4x4.cpp b/source/kernel/gen_system/GEN_Matrix4x4.cpp deleted file mode 100644 index 72926ce9c39..00000000000 --- a/source/kernel/gen_system/GEN_Matrix4x4.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/** - * $Id$ - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "GEN_Matrix4x4.h" - -GEN_Matrix4x4::GEN_Matrix4x4() -{ - Identity(); -} - - - -GEN_Matrix4x4::GEN_Matrix4x4(const float value[4][4]) -{ - for (int i=0;i<4;i++) - { - for (int j=0;j<4;j++) - m_V[i][j] = value[i][j]; - } -} - - - -GEN_Matrix4x4::GEN_Matrix4x4(const double value[16]) -{ - for (int i=0;i<16;i++) - m_Vflat[i] = value[i]; -} - - - -GEN_Matrix4x4::GEN_Matrix4x4(const GEN_Matrix4x4& other) -{ - SetMatrix(other); -} - - - -GEN_Matrix4x4::GEN_Matrix4x4(const MT_Point3& orig, - const MT_Vector3& dir, - const MT_Vector3 up) -{ - MT_Vector3 z = -(dir.normalized()); - MT_Vector3 x = (up.cross(z)).normalized(); - MT_Vector3 y = (z.cross(x)); - - m_V[0][0] = x.x(); - m_V[0][1] = y.x(); - m_V[0][2] = z.x(); - m_V[0][3] = 0.0f; - - m_V[1][0] = x.y(); - m_V[1][1] = y.y(); - m_V[1][2] = z.y(); - m_V[1][3] = 0.0f; - - m_V[2][0] = x.z(); - m_V[2][1] = y.z(); - m_V[2][2] = z.z(); - m_V[2][3] = 0.0f; - - m_V[3][0] = orig.x();//0.0f; - m_V[3][1] = orig.y();//0.0f; - m_V[3][2] = orig.z();//0.0f; - m_V[3][3] = 1.0f; - - //Translate(-orig); -} - - - -MT_Vector3 GEN_Matrix4x4::GetRight() const -{ - return MT_Vector3(m_V[0][0], m_V[0][1], m_V[0][2]); -} - - - -MT_Vector3 GEN_Matrix4x4::GetUp() const -{ - return MT_Vector3(m_V[1][0], m_V[1][1], m_V[1][2]); -} - - - -MT_Vector3 GEN_Matrix4x4::GetDir() const -{ - return MT_Vector3(m_V[2][0], m_V[2][1], m_V[2][2]); -} - - - -MT_Point3 GEN_Matrix4x4::GetPos() const -{ - return MT_Point3(m_V[3][0], m_V[3][1], m_V[3][2]); -} - - - -void GEN_Matrix4x4::Identity() -{ - for (int i=0; i<4; i++) - { - for (int j=0; j<4; j++) - m_V[i][j] = (i==j?1.0f:0.0f); - } -} - - - -void GEN_Matrix4x4::SetMatrix(const GEN_Matrix4x4& other) -{ - for (int i=0; i<16; i++) - m_Vflat[i] = other.m_Vflat[i]; -} - - - -double* GEN_Matrix4x4::getPointer() -{ - return &m_V[0][0]; -} - - - -const double* GEN_Matrix4x4::getPointer() const -{ - return &m_V[0][0]; -} - - - -void GEN_Matrix4x4::setElem(int pos,double newvalue) -{ - m_Vflat[pos] = newvalue; -} - - - - - -GEN_Matrix4x4 GEN_Matrix4x4::Perspective(MT_Scalar inLeft, -MT_Scalar inRight, -MT_Scalar inBottom, -MT_Scalar inTop, -MT_Scalar inNear, -MT_Scalar inFar) -{ - - GEN_Matrix4x4 mat; - - // Column 0 - mat(0, 0) = -(2.0*inNear) / (inRight-inLeft); - mat(1, 0) = 0; - mat(2, 0) = 0; - mat(3, 0) = 0; - - // Column 1 - mat(0, 1) = 0; - mat(1, 1) = (2.0*inNear) / (inTop-inBottom); - mat(2, 1) = 0; - mat(3, 1) = 0; - - // Column 2 - mat(0, 2) = (inRight+inLeft) / (inRight-inLeft); - mat(1, 2) = (inTop+inBottom) / (inTop-inBottom); - mat(2, 2) = -(inFar+inNear) / (inFar-inNear); - mat(3, 2) = -1; - - // Column 3 - mat(0, 3) = 0; - mat(1, 3) = 0; - mat(2, 3) = -(2.0*inFar*inNear) / (inFar-inNear); - mat(3, 3) = 0; - - return mat; -} diff --git a/source/kernel/gen_system/GEN_Matrix4x4.h b/source/kernel/gen_system/GEN_Matrix4x4.h deleted file mode 100644 index dede10fd459..00000000000 --- a/source/kernel/gen_system/GEN_Matrix4x4.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef GEN_MATRIX4X4 -#define GEN_MATRIX4X4 - -#include "MT_Point3.h" - -class GEN_Matrix4x4 -{ -public: - // creators. - GEN_Matrix4x4(); - GEN_Matrix4x4(const float value[4][4]); - GEN_Matrix4x4(const double value[16]); - GEN_Matrix4x4(const GEN_Matrix4x4 & other); - GEN_Matrix4x4(const MT_Point3& orig, - const MT_Vector3& dir, - const MT_Vector3 up); - - void Identity(); - void SetMatrix(const GEN_Matrix4x4 & other); - double* getPointer(); - const double* getPointer() const; - void setElem(int pos,double newvalue); - - - MT_Vector3 GetRight() const; - MT_Vector3 GetUp() const; - MT_Vector3 GetDir() const; - MT_Point3 GetPos() const; - void SetPos(const MT_Vector3 & v); - - double& operator () (int row,int col) { return m_V[col][row]; } - - static GEN_Matrix4x4 Perspective(MT_Scalar inLeft, - MT_Scalar inRight, - MT_Scalar inBottom, - MT_Scalar inTop, - MT_Scalar inNear, - MT_Scalar inFar); -protected: - union - { - double m_V[4][4]; - double m_Vflat[16]; - }; -}; - -#endif //GEN_MATRIX4X4 - diff --git a/source/kernel/gen_system/GEN_SmartPtr.h b/source/kernel/gen_system/GEN_SmartPtr.h deleted file mode 100644 index e1c378d6867..00000000000 --- a/source/kernel/gen_system/GEN_SmartPtr.h +++ /dev/null @@ -1,233 +0,0 @@ -#ifndef NAN_INCLUDED_GEN_SmartPtr_h -#define NAN_INCLUDED_GEN_SmartPtr_h - -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - * @author Laurence - */ - -#include <stdlib.h> // for NULL ! - -/** - * @section GEN_SmartPtr - * This class defines a smart pointer similar to that defined in - * the Standard Template Library but without the painful get() - * semantics to access the internal c style pointer. - * - * It is often useful to explicitely decalre ownership of memory - * allocated on the heap within class or function scope. This - * class helps you to encapsulate this ownership within a value - * type. When an instance of this class goes out of scope it - * makes sure that any memory associated with it's internal pointer - * is deleted. It can help to inform users of an aggregate class - * that it owns instances of it's members and these instances - * should not be shared. This is not reliably enforcable in C++ - * but this class attempts to make the 1-1 relationship clear. - * - * @section Example usage - * - * class foo { - * ...constructors accessors etc. - * int x[1000]; - * } - * - * class bar { - * public : - * static - * bar * - * New( - * ) { - * GEN_SmartPtr<foo> afoo = new foo(); - * GEN_SmartPtr<bar> that = new bar(); - * - * if (foo == NULL || that == NULL) return NULL; - * - * that->m_foo = afoo.Release(); - * return that.Release(); - * } - * - * ~bar() { - * // smart ptr takes care of deletion - * } - * private : - * GEN_SmartPtr<foo> m_foo; - * } - * - * You my also safely construct vectors of GEN_SmartPtrs and - * have the vector own stuff you put into it. - * - * e.g. - * { - * std::vector<GEN_SmartPtr<foo> > foo_vector; - * foo_vector.push_back( new foo()); - * foo_vector.push_back( new foo()); - * - * foo_vector[0]->bla(); - * } // foo_vector out of scope => heap memory freed for both foos - * - * @warning this class should only be used for objects created - * on the heap via the new function. It will not behave correctly - * if you pass ptrs to objects created with new[] nor with - * objects declared on the stack. Doing this is likely to crash - * the program or lead to memory leaks. - */ - -template - < class T > -class GEN_SmartPtr { - -public : - - /** - * Construction from reference - this class - * always assumes ownership from the rhs. - */ - - GEN_SmartPtr( - const GEN_SmartPtr &rhs - ){ - m_val = rhs.Release(); - } - - /** - * Construction from ptr - this class always - * assumes that it now owns the memory associated with the - * ptr. - */ - - GEN_SmartPtr( - T* val - ) : - m_val (val) - { - } - - /** - * Defalut constructor - */ - - GEN_SmartPtr( - ) : - m_val (NULL) - { - } - - /** - * Type conversion from this class to the type - * of a pointer to the template parameter. - * This means you can pass an instance of this class - * to a function expecting a ptr of type T. - */ - - operator T * () const { - return m_val; - } - - /** - * Return a reference to the internal ptr class. - * Use with care when you now that the internal ptr - * is not NULL! - */ - - T & - Ref( - ) const { - return *m_val; - } - - /** - * Assignment operator - ownership is transfered from rhs to lhs. - * There is an intenional side-effect of function of transferring - * ownership from the const parameter rhs. This is to insure - * the 1-1 relationship. - * The object associated with this instance is deleted if it - * is not the same as that contained in the rhs. - */ - - GEN_SmartPtr & operator=( - const GEN_SmartPtr &rhs - ) { - if (this->m_val != rhs.m_val) { - delete this->m_val; - } - - this->m_val = rhs.Release(); - return *this; - } - - /** - * Overload the operator -> so that it's possible to access - * all the normal methods of the internal ptr. - */ - - T * operator->() const { - return m_val; - } - - /** - * Caller takes ownership of the object - the object will not - * be deleted when the ptr goes out of scope. - */ - - T * - Release( - ) const { - T* temp = m_val; - (const_cast<GEN_SmartPtr *>(this))->m_val = NULL; - return temp; - } - - /** - * Force destruction of the internal object. - */ - - void - Delete( - ) { - delete (m_val); - m_val = NULL; - } - - /** - * Destructor - deletes object if it exists - */ - - ~GEN_SmartPtr( - ) { - delete (m_val); - } - -private : - - /// The ptr owned by this class. - T * m_val; -}; - -#endif - diff --git a/source/kernel/gen_system/SYS_SingletonSystem.cpp b/source/kernel/gen_system/SYS_SingletonSystem.cpp index 0b5cfe7273a..52bd3d87470 100644 --- a/source/kernel/gen_system/SYS_SingletonSystem.cpp +++ b/source/kernel/gen_system/SYS_SingletonSystem.cpp @@ -29,7 +29,7 @@ * Used by SYS_System */ #include "SYS_SingletonSystem.h" -#include "GEN_DataCache.h" +// #include "GEN_DataCache.h" SYS_SingletonSystem* SYS_SingletonSystem::_instance = 0; diff --git a/source/kernel/gen_system/SYS_SingletonSystem.h b/source/kernel/gen_system/SYS_SingletonSystem.h index 889838454e7..874f3fa9793 100644 --- a/source/kernel/gen_system/SYS_SingletonSystem.h +++ b/source/kernel/gen_system/SYS_SingletonSystem.h @@ -33,7 +33,6 @@ #include "GEN_Map.h" #include "STR_HashedString.h" -#include "GEN_DataCache.h" class SYS_SingletonSystem { |