diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-01-09 18:07:14 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-01-09 18:07:14 +0300 |
commit | 0ec378f3fea3be9235b5bc8cb976d6126ae808f5 (patch) | |
tree | 5266bf2dff77d453046265892380e441cb4643be /source | |
parent | ddcb91fc213cb9d9f87558f88a4831cd4c8e2791 (diff) | |
parent | 99e203dbd46237c204fa697374e21769473955f5 (diff) |
Merged changes in the trunk up to revision 34193.
Conflicts resolved:
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/space_nla/nla_channels.c
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_scene.c
API changes resolved:
source/blender/freestyle/intern/system/PythonInterpreter.h
Diffstat (limited to 'source')
514 files changed, 5338 insertions, 4094 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index d1dcf7aa9b3..ce68df5c8b6 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -159,7 +159,6 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len) if (!font->glyph_cache) return; - i= 0; pen_x= 0; pen_y= 0; has_kerning= FT_HAS_KERNING(font->face); diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 21bf73b56d9..8a929e1ebf7 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -38,7 +38,7 @@ #include "DNA_listBase.h" #include "DNA_vec_types.h" -#include "BKE_utildefines.h" + #include "BLI_blenlib.h" #include "BLI_linklist.h" /* linknode */ @@ -46,7 +46,7 @@ #ifdef __APPLE__ -#include "BKE_utildefines.h" + #endif #define DOMAIN_NAME "blender" diff --git a/source/blender/blenkernel/BKE_array_mallocn.h b/source/blender/blenkernel/BKE_array_mallocn.h new file mode 100644 index 00000000000..c2ced0e5c27 --- /dev/null +++ b/source/blender/blenkernel/BKE_array_mallocn.h @@ -0,0 +1,82 @@ +/* + * $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 BKE_ARRAY_MALLOCN_H +#define BKE_ARRAY_MALLOCN_H + +/*little array macro library. example of usage: + +int *arr = NULL; +V_DECLARE(arr); +int i; + +for (i=0; i<10; i++) { + V_GROW(arr); + arr[i] = something; +} +V_FREE(arr); + +arrays are buffered, using double-buffering (so on each reallocation, +the array size is doubled). supposedly this should give good Big Oh +behaviour, though it may not be the best in practice. +*/ + +#define V_DECLARE(vec) int _##vec##_count=0; void *_##vec##_tmp + +/*in the future, I plan on having V_DECLARE allocate stack memory it'll + use at first, and switch over to heap when it needs more. that'll mess + up cases where you'd want to use this API to build a dynamic list for + non-local use, so all such cases should use this macro.*/ +#define V_DYNDECLARE(vec) V_DECLARE(vec) + +/*this returns the entire size of the array, including any buffering.*/ +#define V_SIZE(vec) ((signed int)((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec))) + +/*this returns the logical size of the array, not including buffering.*/ +#define V_COUNT(vec) _##vec##_count + +/*grow the array by one. zeroes the new elements.*/ +#define V_GROW(vec) \ + V_SIZE(vec) > _##vec##_count ? _##vec##_count++ : \ + ((_##vec##_tmp = MEM_callocN(sizeof(*vec)*(_##vec##_count*2+2), #vec " " __FILE__ " ")),\ + (void)(vec && memcpy(_##vec##_tmp, vec, sizeof(*vec) * _##vec##_count)),\ + (void)(vec && (MEM_freeN(vec),1)),\ + (vec = _##vec##_tmp),\ + _##vec##_count++) + +#define V_FREE(vec) if (vec) MEM_freeN(vec); + +/*resets the logical size of an array to zero, but doesn't + free the memory.*/ +#define V_RESET(vec) _##vec##_count=0 + +/*set the count of the array*/ +#define V_SETCOUNT(vec, count) _##vec##_count = (count) + +#endif // BKE_ARRAY_MALLOCN_H diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 886a11b126e..a5c5cadc4f6 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,6 +51,11 @@ struct Main; #define BLENDER_MINSUBVERSION 0 int BKE_read_file(struct bContext *C, const char *filepath, struct ReportList *reports); + +#define BKE_READ_FILE_FAIL 0 /* no load */ +#define BKE_READ_FILE_OK 1 /* OK */ +#define BKE_READ_FILE_OK_USERPREFS 2 /* OK, and with new user settings */ + 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); diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index 18db68a93af..44ca3842fd9 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -38,6 +38,7 @@ #define BKE_BMESH_H #include "DNA_listBase.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_mempool.h" #include "BLI_memarena.h" diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 5afab9af9b3..deb10ef6d35 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -56,6 +56,9 @@ int brush_texture_delete(struct Brush *brush); int brush_clone_image_set_nr(struct Brush *brush, int nr); int brush_clone_image_delete(struct Brush *brush); +/* jitter */ +void brush_jitter_pos(struct Brush *brush, float *pos, float *jitterpos); + /* brush curve */ void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset); float brush_curve_strength_clamp(struct Brush *br, float p, const float len); diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h index 553e62ba578..ad59cd9c0a8 100644 --- a/source/blender/blenkernel/BKE_exotic.h +++ b/source/blender/blenkernel/BKE_exotic.h @@ -42,6 +42,13 @@ struct Scene; */ int BKE_read_exotic(struct Scene *scene, const char *name); +/* return codes */ +#define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */ +#define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */ +#define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */ +#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */ +#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */ + void write_dxf(struct Scene *scene, char *str); void write_stl(struct Scene *scene, char *str); diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 4ed06c30a9c..416b89ef36e 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -66,7 +66,7 @@ struct KeyBlock *key_get_keyblock(struct Key *key, int index); struct KeyBlock *key_get_named_keyblock(struct Key *key, const char name[]); char *key_get_curValue_rnaPath(struct Key *key, struct KeyBlock *kb); // needed for the GE -void do_rel_key(int start, int end, int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, int mode); +void do_rel_key(const int start, int end, const int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, const int mode); /* conversion functions */ void key_to_mesh(struct KeyBlock *kb, struct Mesh *me); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 534427c9da3..f956749dc9d 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -65,7 +65,10 @@ int set_listbasepointers(struct Main *main, struct ListBase **lb); void free_libblock(struct ListBase *lb, void *idv); void free_libblock_us(struct ListBase *lb, void *idv); void free_main(struct Main *mainvar); -void tag_main(struct Main *mainvar, int tag); + +void tag_main_idcode(struct Main *mainvar, const short type, const short tag); +void tag_main_lb(struct ListBase *lb, const short tag); +void tag_main(struct Main *mainvar, const short tag); void rename_id(struct ID *id, const char *name); void name_uiprefix_id(char *name, struct ID *id); diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 5bdea166cce..f924905bfde 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -56,6 +56,7 @@ struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); +void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd, diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index f3548888168..c7f76c033c8 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -89,7 +89,7 @@ struct SoftBody; /* temp structure for read/write */ typedef struct PTCacheData { - int index; + uint32_t index; float loc[3]; float vel[3]; float rot[4]; @@ -270,6 +270,9 @@ void BKE_ptcache_update_info(PTCacheID *pid); /* Size of cache data type. */ int BKE_ptcache_data_size(int data_type); +/* Is point with indes in memory cache */ +int BKE_ptcache_mem_index_find(struct PTCacheMem *pm, int index); + /* Memory cache read/write helpers. */ void BKE_ptcache_mem_pointers_init(struct PTCacheMem *pm); void BKE_ptcache_mem_pointers_incr(struct PTCacheMem *pm); diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 605a50e078b..aa421305d5c 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -27,68 +27,12 @@ * ***** END GPL LICENSE BLOCK ***** */ +/* This file shold contain blender format spesific macros + * generic defines should go in BLI_utildefines.h */ + #ifndef BKE_UTILDEFINES_H #define BKE_UTILDEFINES_H -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -/* Macro to convert a value to string in the preprocessor - * STRINGIFY_ARG: gives the defined name in the string - * STRINGIFY: gives the defined value. */ -#define STRINGIFY_ARG(x) #x -#define STRINGIFY(x) STRINGIFY_ARG(x) - -/* useful for debugging */ -#define AT __FILE__ ":" STRINGIFY(__LINE__) - - -#ifdef __GNUC__ -# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) -#else -# define UNUSED(x) UNUSED_ ## x -#endif - - -/* BKE_assert(), default only to print - * for aborting need to define WITH_ASSERT_ABORT */ -#if !defined NDEBUG -# ifdef WITH_ASSERT_ABORT -# define _dummy_abort abort -# else -# define _dummy_abort() (void)0 -# endif -# ifdef __GNUC__ /* just want to check if __func__ is available */ -# define BKE_assert(a) \ -do { \ - if (0 == (a)) { \ - fprintf(stderr, \ - "BKE_assert failed: %s, %s(), %d at \'%s\'\n", \ - __FILE__, __func__, __LINE__, STRINGIFY(a)); \ - _dummy_abort(); \ - } \ -} while (0) -# else -# define BKE_assert(a) \ -do { \ - if (0 == (a)) { \ - fprintf(stderr, \ - "BKE_assert failed: %s, %d at \'%s\'\n", \ - __FILE__, __LINE__, STRINGIFY(a)); \ - _dummy_abort(); \ - } \ -} while (0) -# endif -#else -# define BKE_assert(a) (void)0 -#endif - - /* these values need to be hardcoded in structs, dna does not recognize defines */ /* also defined in DNA_space_types.h */ #ifndef FILE_MAXDIR @@ -97,94 +41,6 @@ do { \ #define FILE_MAX 240 #endif -#define ELEM(a, b, c) ( (a)==(b) || (a)==(c) ) -#define ELEM3(a, b, c, d) ( ELEM(a, b, c) || (a)==(d) ) -#define ELEM4(a, b, c, d, e) ( ELEM(a, b, c) || ELEM(a, d, e) ) -#define ELEM5(a, b, c, d, e, f) ( ELEM(a, b, c) || ELEM3(a, d, e, f) ) -#define ELEM6(a, b, c, d, e, f, g) ( ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) -#define ELEM7(a, b, c, d, e, f, g, h) ( ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) -#define ELEM8(a, b, c, d, e, f, g, h, i) ( ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) -#define ELEM9(a, b, c, d, e, f, g, h, i, j) ( ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) -#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) ( ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) ) -#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) ( ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) ) - -/* shift around elements */ -#define SHIFT3(type, a, b, c) { type tmp; tmp = a; a = c; c = b; b = tmp; } -#define SHIFT4(type, a, b, c, d) { type tmp; tmp = a; a = d; d = c; c = b; b = tmp; } - -/* min/max */ -#define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) -#define MIN3(x,y,z) MIN2( MIN2((x),(y)) , (z) ) -#define MIN4(x,y,z,a) MIN2( MIN2((x),(y)) , MIN2((z),(a)) ) - -#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) -#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) ) -#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) ) - -#define INIT_MINMAX(min, max) { (min)[0]= (min)[1]= (min)[2]= 1.0e30f; (max)[0]= (max)[1]= (max)[2]= -1.0e30f; } - -#define INIT_MINMAX2(min, max) { (min)[0]= (min)[1]= 1.0e30f; (max)[0]= (max)[1]= -1.0e30f; } - -#define DO_MIN(vec, min) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \ - if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \ - if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; } \ - -#define DO_MAX(vec, max) { if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ - if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \ - if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \ - -#define DO_MINMAX(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \ - if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \ - if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \ - if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ - if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \ - if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \ - -#define DO_MINMAX2(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \ - if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \ - if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ - if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; } - -/* some math and copy defines */ - -#ifndef SWAP -#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } -#endif - -#define ABS(a) ( (a)<0 ? (-(a)) : (a) ) - -#define AVG2(x, y) ( 0.5 * ((x) + (y)) ) - -#define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f)) -#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f)) - -#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);} -#define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);} -#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);} -#define LONGCOPY(a, b, c) {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);} - - -#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);} -#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);} -#define VECSUB2D(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);} -#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);} -#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);} -#define QUATADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac); *(v1+3)= *(v2+3) + *(v3+3)*(fac);} - -#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] ) - - -/* some misc stuff.... */ -#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c) -#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a)) -#define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);} - -#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1) - -#define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0))) -#define IN_RANGE(a, b, c) ((b < c)? ((b<a && a<c)? 1:0) : ((c<a && a<b)? 1:0)) -#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0)) - /* this weirdo pops up in two places ... */ #if !defined(WIN32) #ifndef O_BINARY @@ -203,12 +59,6 @@ do { \ #define ID_NEW(a) if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid -#define FORM MAKE_ID('F','O','R','M') - -#define BLEN MAKE_ID('B','L','E','N') -#define DER_ MAKE_ID('D','E','R','_') -#define V100 MAKE_ID('V','1','0','0') - #define DATA MAKE_ID('D','A','T','A') #define GLOB MAKE_ID('G','L','O','B') #define IMAG MAKE_ID('I','M','A','G') @@ -220,28 +70,6 @@ do { \ #define ENDB MAKE_ID('E','N','D','B') - -/* This one rotates the bytes in an int64, int (32) and short (16) */ -#define SWITCH_INT64(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } - -#define SWITCH_INT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } - -#define SWITCH_SHORT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } - - /* Bit operations */ #define BTST(a,b) ( ( (a) & 1<<(b) )!=0 ) #define BNTST(a,b) ( ( (a) & 1<<(b) )==0 ) @@ -251,76 +79,6 @@ do { \ /* bit-row */ #define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) ) - -#ifdef GS -#undef GS -#endif -#define GS(a) (*((short *)(a))) - -/* Warning-free macros for storing ints in pointers. Use these _only_ - * for storing an int in a pointer, not a pointer in an int (64bit)! */ -#define SET_INT_IN_POINTER(i) ((void*)(intptr_t)(i)) -#define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) - -/*little array macro library. example of usage: - -int *arr = NULL; -V_DECLARE(arr); -int i; - -for (i=0; i<10; i++) { - V_GROW(arr); - arr[i] = something; -} -V_FREE(arr); - -arrays are buffered, using double-buffering (so on each reallocation, -the array size is doubled). supposedly this should give good Big Oh -behaviour, though it may not be the best in practice. -*/ - -#define V_DECLARE(vec) int _##vec##_count=0; void *_##vec##_tmp - -/*in the future, I plan on having V_DECLARE allocate stack memory it'll - use at first, and switch over to heap when it needs more. that'll mess - up cases where you'd want to use this API to build a dynamic list for - non-local use, so all such cases should use this macro.*/ -#define V_DYNDECLARE(vec) V_DECLARE(vec) - -/*this returns the entire size of the array, including any buffering.*/ -#define V_SIZE(vec) ((signed int)((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec))) - -/*this returns the logical size of the array, not including buffering.*/ -#define V_COUNT(vec) _##vec##_count - -/*grow the array by one. zeroes the new elements.*/ -#define V_GROW(vec) \ - V_SIZE(vec) > _##vec##_count ? _##vec##_count++ : \ - ((_##vec##_tmp = MEM_callocN(sizeof(*vec)*(_##vec##_count*2+2), #vec " " __FILE__ " ")),\ - (void)(vec && memcpy(_##vec##_tmp, vec, sizeof(*vec) * _##vec##_count)),\ - (void)(vec && (MEM_freeN(vec),1)),\ - (vec = _##vec##_tmp),\ - _##vec##_count++) - -#define V_FREE(vec) if (vec) MEM_freeN(vec); - -/*resets the logical size of an array to zero, but doesn't - free the memory.*/ -#define V_RESET(vec) _##vec##_count=0 - -/*set the count of the array*/ -#define V_SETCOUNT(vec, count) _##vec##_count = (count) - -/*little macro so inline keyword works*/ -#if defined(_MSC_VER) -#define BM_INLINE static __forceinline -#elif defined(__GNUC__) -#define BM_INLINE static inline __attribute((always_inline)) -#else -/* #warning "MSC/GNUC defines not found, inline non-functional" */ -#define BM_INLINE static -#endif - #define BMEMSET(mem, val, size) {unsigned int _i; char *_c = (char*) mem; for (_i=0; _i<size; _i++) *_c++ = val;} -#endif +#endif // BKE_UTILDEFINES_H diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index b869bb51864..44427c43fc4 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -146,6 +146,7 @@ set(SRC BKE_anim.h BKE_animsys.h BKE_armature.h + BKE_array_mallocn.h BKE_blender.h BKE_bmesh.h BKE_bmeshCustomData.h diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index 341eb38b388..e80d4827155 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -38,10 +38,12 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_edgehash.h" +#include "BLI_utildefines.h" + #include "BKE_mesh.h" #include "BKE_cdderivedmesh.h" -#include "BLI_edgehash.h" //XXX #include "BIF_editmesh.h" //XXX #include "editmesh.h" #include "bmesh_private.h" diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 036cd4a23e2..cd9429982dc 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -33,7 +33,7 @@ */ #include "MEM_guardedalloc.h" - +#include "BLI_utildefines.h" #include "bmesh_private.h" diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index de3eb94beac..9463d22e3be 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -33,8 +33,9 @@ */ #include <limits.h> -#include "MEM_guardedalloc.h" +#include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BKE_bmesh.h" /** * MISC utility functions. diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 444bc10d562..0c8352ad8b0 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -38,8 +38,10 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "BKE_bmesh.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_bmesh.h" /*split this all into a seperate bevel.c file in src*/ diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 1cd5ae381c4..35ba8caedb0 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1521,7 +1521,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - if (seam && seamEdges < 2) + if (seamEdges < 2 || seamEdges != v->numEdges) seam = 0; if (!v->numEdges) { @@ -1949,7 +1949,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { } } - if (seam && seamEdges < 2) + if (seamEdges < 2 || seamEdges != v->numEdges) seam = 0; if (!v->numEdges) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3d87b77dec9..bee0b476f9f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_memarena.h" #include "BLI_pbvh.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" @@ -52,7 +53,7 @@ #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BLO_sys_types.h" // for intptr_t support @@ -1283,7 +1284,7 @@ static void *emDM_getFaceDataArray(DerivedMesh *dm, int type) EditFace *efa; char *data, *emdata; void *datalayer; - int index, offset, size; + int index, size; datalayer = DM_get_face_data_layer(dm, type); if(datalayer) @@ -1295,7 +1296,7 @@ static void *emDM_getFaceDataArray(DerivedMesh *dm, int type) index = CustomData_get_layer_index(&em->fdata, type); if(index != -1) { - offset = em->fdata.layers[index].offset; + /* int offset = em->fdata.layers[index].offset; */ /* UNUSED */ size = CustomData_sizeof(type); DM_add_face_layer(dm, type, CD_CALLOC, NULL); @@ -2601,15 +2602,8 @@ void DM_add_tangent_layer(DerivedMesh *dm) /* write tangent to layer */ for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) { len= (mf->v4)? 4 : 3; - - if(mtface) { - uv1= tf->uv[0]; - uv2= tf->uv[1]; - uv3= tf->uv[2]; - uv4= tf->uv[3]; - } - else { - uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; + + if(mtface == NULL) { map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index fdd51dd207f..08b57ba18a3 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -39,6 +39,11 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_anim.h" @@ -48,15 +53,11 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" + #include "BKE_idprop.h" #include "BIK_api.h" -#include "BLI_blenlib.h" -#include "BLI_ghash.h" -#include "BLI_math.h" - #include "RNA_access.h" /* *********************** NOTE ON POSE AND ACTION ********************** diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index c372855b3eb..8cac3860e79 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -39,6 +39,7 @@ #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 49d3ca833dd..fcce85b026e 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,8 +36,8 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BKE_library.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_material_types.h" @@ -50,6 +50,7 @@ #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_library.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -923,10 +924,11 @@ void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp) /* sanity check */ if ELEM(NULL, ks, ksp) return; - + /* free RNA-path info */ - MEM_freeN(ksp->rna_path); - + if(ksp->rna_path) + MEM_freeN(ksp->rna_path); + /* free path itself */ BLI_freelinkN(&ks->paths, ksp); } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 6b21e45ddd9..1a219939b77 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -36,6 +36,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -63,7 +64,7 @@ #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" + #include "BIK_api.h" #include "BKE_sketch.h" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b782d3a92a9..1d616c77f04 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -58,6 +58,7 @@ #include "BLI_bpath.h" #include "BLI_dynstr.h" #include "BLI_path_util.h" +#include "BLI_utildefines.h" #include "IMB_imbuf.h" @@ -81,7 +82,7 @@ #include "BLO_readfile.h" #include "BLO_writefile.h" -#include "BKE_utildefines.h" // O_BINARY FALSE +#include "BKE_utildefines.h" #include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie @@ -346,12 +347,6 @@ void BKE_userdef_free(void) BLI_freelistN(&U.addons); } -/* returns: - 0: no load file - 1: OK - 2: OK, and with new user settings -*/ - int BKE_read_file(bContext *C, const char *dir, ReportList *reports) { BlendFileData *bfd; @@ -459,7 +454,7 @@ static int read_undosave(bContext *C, UndoElem *uel) G.fileflags |= G_FILE_NO_UI; if(UNDO_DISK) - success= BKE_read_file(C, uel->str, NULL); + success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); else success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 1bde0639055..228827bab68 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -41,11 +41,13 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" +#include "BLI_utildefines.h" + #include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_boids.h" #include "BKE_particle.h" -#include "BKE_utildefines.h" + #include "BKE_modifier.h" #include "RNA_enum_types.h" diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 649b3e3ad9b..a78d2ecaaa2 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_brush.h" #include "BKE_colortools.h" diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 882295b931c..db7b9b276a2 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -23,7 +23,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ @@ -34,9 +34,11 @@ #include "DNA_meshdata_types.h" -#include "BKE_DerivedMesh.h" -#include "BKE_utildefines.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" + +#include "BKE_DerivedMesh.h" + #include "BLI_math.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 8030a3655ad..8bb336d1c4d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -36,17 +36,18 @@ #include <string.h> #include "BIF_gl.h" -#include "BKE_cdderivedmesh.h" -#include "BKE_global.h" -#include "BKE_mesh.h" -#include "BKE_paint.h" -#include "BKE_utildefines.h" - #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_pbvh.h" +#include "BLI_utildefines.h" + +#include "BKE_cdderivedmesh.h" +#include "BKE_global.h" +#include "BKE_mesh.h" +#include "BKE_paint.h" + #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -189,7 +190,7 @@ static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; - Mesh *me= (ob)? ob->data: NULL; + Mesh *me= ob->data; if(ob->sculpt->modifiers_active) return 0; @@ -1644,7 +1645,7 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me)) DerivedMesh *CDDM_from_curve(Object *ob) { - return CDDM_from_curve_customDB(ob, &((Curve *)ob->data)->disp); + return CDDM_from_curve_customDB(ob, &ob->disp); } DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b283120249e..39cb1346eb7 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -34,6 +34,7 @@ #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_cloth.h" @@ -41,7 +42,7 @@ #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" + #ifdef _WIN32 void tstart ( void ) @@ -163,7 +164,6 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps BVHTree *bvhtree; Cloth *cloth; ClothVertex *verts; - MFace *mfaces; float co[12]; if(!clmd) @@ -175,7 +175,6 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps return NULL; verts = cloth->verts; - mfaces = cloth->mfaces; // in the moment, return zero if no faces there if(!cloth->numverts) @@ -430,7 +429,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, PointCache *cache; PTCacheID pid; float timescale; - int framedelta, framenr, startframe, endframe; + int framenr, startframe, endframe; int cache_result; clmd->scene= scene; /* nice to pass on later :) */ @@ -486,11 +485,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, framenr= endframe; } - if(cache->flag & PTCACHE_SIMULATION_VALID) - framedelta= framenr - cache->simframe; - else - framedelta= -1; - /* initialize simulation data if it didn't exist already */ if(!do_init_cloth(ob, clmd, dm, framenr)) return result; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index b2d587151b1..e7dff52db62 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" @@ -49,7 +50,7 @@ #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" + #include "BKE_DerivedMesh.h" #ifdef USE_BULLET #include "Bullet-C-Api.h" diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 1b3d100c3f8..7cf6b21e2f1 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -41,13 +41,14 @@ #include "DNA_color_types.h" #include "DNA_curve_types.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + #include "BKE_colortools.h" #include "BKE_curve.h" #include "BKE_fcurve.h" -#include "BKE_utildefines.h" -#include "BLI_blenlib.h" -#include "BLI_math.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -1011,6 +1012,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) int savedlines, saveline; float rgb[3], ycc[3], luma; int ycc_mode=-1; + const short is_float = (ibuf->rect_float != NULL); + + if (ibuf->rect==NULL && ibuf->rect_float==NULL) return; if (scopes->ok == 1 ) return; @@ -1018,6 +1022,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) /* hmmmm */ if (!(ELEM(ibuf->channels, 3, 4))) return; + scopes->hist.channels = 3; scopes->hist.x_resolution = 256; @@ -1072,9 +1077,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); - if (ibuf->rect_float) + if (is_float) rf = ibuf->rect_float; - else if (ibuf->rect) + else rc = (unsigned char *)ibuf->rect; for (y = 0; y < ibuf->y; y++) { @@ -1083,13 +1088,13 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) } else saveline=0; for (x = 0; x < ibuf->x; x++) { - if (ibuf->rect_float) { + if (is_float) { if (use_color_management) linearrgb_to_srgb_v3_v3(rgb, rf); else copy_v3_v3(rgb, rf); } - else if (ibuf->rect) { + else { for (c=0; c<3; c++) rgb[c] = rc[c] * INV_255; } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b0932533ea6..c497132fa99 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -39,6 +39,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" @@ -52,7 +53,7 @@ #include "DNA_scene_types.h" #include "DNA_text_types.h" -#include "BKE_utildefines.h" + #include "BKE_action.h" #include "BKE_anim.h" /* for the curve calculation part */ #include "BKE_armature.h" @@ -2033,7 +2034,7 @@ static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targ #endif /* Now, run the actual 'constraint' function, which should only access the matrices */ - BPY_pyconstraint_eval(data, cob, targets); + BPY_pyconstraint_exec(data, cob, targets); #endif /* WITH_PYTHON */ } diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 9740c969ec7..09321ddea81 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -427,8 +427,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res memset(result, 0, sizeof(bContextDataResult)); #ifdef WITH_PYTHON if(CTX_py_dict_get(C)) { - return BPY_context_get(C, member, result); -// if (BPY_context_get(C, member, result)) + return BPY_context_member_get(C, member, result); +// if (BPY_context_member_get(C, member, result)) // return 1; } #endif diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 6368c139baf..13a53629d9b 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -35,8 +35,10 @@ #include <stdlib.h> #include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_material_types.h" @@ -57,7 +59,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" // VECCOPY + #include "ED_curve.h" @@ -1266,10 +1268,10 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); dl= bevdisp.first; } else { - dl= bevcu->disp.first; + dl= cu->bevobj->disp.first; if(dl==0) { makeDispListCurveTypes(scene, cu->bevobj, 0); - dl= bevcu->disp.first; + dl= cu->bevobj->disp.first; } } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f7606a344c9..134b0e10280 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -46,6 +46,7 @@ #include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_mempool.h" +#include "BLI_utildefines.h" #include "BKE_customdata.h" #include "BKE_customdata_file.h" diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 5954ac1b022..6fb79a0df28 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -28,10 +28,11 @@ #include "BLI_fileops.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_customdata_file.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + /************************* File Format Definitions ***************************/ diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1904e63c2ba..61865f5579c 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -29,7 +29,11 @@ #include <string.h> #include <math.h> +#include "MEM_guardedalloc.h" + #include "BLI_winstuff.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "DNA_anim_types.h" #include "DNA_camera_types.h" @@ -41,10 +45,6 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include "MEM_guardedalloc.h" - -#include "BLI_ghash.h" - #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_effect.h" @@ -61,6 +61,7 @@ #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_utildefines.h" #include "depsgraph_private.h" @@ -2264,7 +2265,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) oblay= (node)? node->lay: ob->lay; if(oblay & lay) { - if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) + if(ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) ob->recalc |= OB_RECALC_DATA; if(ob->dup_group) ob->dup_group->id.flag |= LIB_DOIT; @@ -2274,7 +2275,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) for(group= bmain->group.first; group; group= group->id.next) { if(group->id.flag & LIB_DOIT) { for(go= group->gobject.first; go; go= go->next) { - if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) + if(ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) go->ob->recalc |= OB_RECALC_DATA; if(go->ob->proxy_from) go->ob->recalc |= OB_RECALC_OB; @@ -2330,23 +2331,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) idtype= GS(id->name); if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) { - int first_ob= 1; for(obt=bmain->object.first; obt; obt= obt->id.next) { if(!(ob && obt == ob) && obt->data == id) { - - /* try to avoid displist recalculation for linked curves */ - if (!first_ob && ELEM(obt->type, OB_CURVE, OB_SURF)) { - /* if curve object has got derivedFinal it means this - object has got constructive modifiers and object - should be recalculated anyhow */ - if (!obt->derivedFinal) - continue; - } - obt->recalc |= OB_RECALC_DATA; BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); - - first_ob= 0; } } } @@ -2463,6 +2451,9 @@ void DAG_id_tag_update(ID *id, short flag) } } } + else { + BKE_assert(!"invalid flag for this 'idtype'"); + } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a6957d6ead1..674836ac859 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -35,7 +35,6 @@ #include "MEM_guardedalloc.h" - #include "DNA_curve_types.h" #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" @@ -46,6 +45,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_scanfill.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_displist.h" @@ -138,7 +138,7 @@ void copy_displist(ListBase *lbn, ListBase *lb) { DispList *dln, *dl; - lbn->first= lbn->last= 0; + freedisplist(lbn); dl= lb->first; while(dl) { @@ -150,7 +150,10 @@ void copy_displist(ListBase *lbn, ListBase *lb) dln->index= MEM_dupallocN(dl->index); dln->col1= MEM_dupallocN(dl->col1); dln->col2= MEM_dupallocN(dl->col2); - + + if(dl->bevelSplitFlag) + dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag); + dl= dl->next; } } @@ -622,7 +625,6 @@ void shadeDispList(Scene *scene, Base *base) Object *ob= base->object; DispList *dl, *dlob; Material *ma = NULL; - Curve *cu; Render *re; float imat[3][3], mat[4][4], vec[3]; float *fp, *nor, n1[3]; @@ -656,8 +658,7 @@ void shadeDispList(Scene *scene, Base *base) if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* now we need the normals */ - cu= ob->data; - dl= cu->disp.first; + dl= ob->disp.first; while(dl) { extern Material defmaterial; /* material.c */ @@ -1137,16 +1138,14 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis */ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) { - Curve *cu; DispList *dl; if(taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; - cu= taperobj->data; - dl= cu->disp.first; + dl= taperobj->disp.first; if(dl==NULL) { makeDispListCurveTypes(scene, taperobj, 0); - dl= cu->disp.first; + dl= taperobj->disp.first; } if(dl) { float fac= ((float)cur)/(float)(tot-1); @@ -1675,6 +1674,11 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, } } + /* make copy of 'undeformed" displist for texture space calculation + actually, it's not totally undeformed -- pre-tesselation modifiers are + already applied, thats how it worked for years, so keep for compatibility (sergey) */ + copy_displist(&cu->disp, dispbase); + if (!forRender) { tex_space_curve(cu); } @@ -1790,7 +1794,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* CU_2D conflicts with R_NOPUNOFLIP */ dl->rt= nu->flag & ~CU_2D; - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2"); + dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "bevelSplitFlag"); bevp= (BevPoint *)(bl+1); /* for each point of poly make a bevel piece */ @@ -1848,6 +1852,11 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if(cu->flag & CU_PATH) calc_curvepath(ob); + /* make copy of 'undeformed" displist for texture space calculation + actually, it's not totally undeformed -- pre-tesselation modifiers are + already applied, thats how it worked for years, so keep for compatibility (sergey) */ + copy_displist(&cu->disp, dispbase); + if (!forRender) { tex_space_curve(cu); } @@ -1862,13 +1871,16 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) { - Curve *cu = ob->data; + Curve *cu= ob->data; ListBase *dispbase; freedisplist(&(ob->disp)); - dispbase= &(cu->disp); + dispbase= &(ob->disp); freedisplist(dispbase); + /* free displist used for textspace */ + freedisplist(&cu->disp); + do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); if (ob->derivedFinal) { @@ -1938,7 +1950,7 @@ static void boundbox_displist(Object *ob) if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= cu->bb; - dl= cu->disp.first; + dl= ob->disp.first; while (dl) { if(dl->type==DL_INDEX3) tot= dl->nr; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 51f2203b525..a79a5fddf00 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -59,6 +59,7 @@ #include "BLI_listbase.h" #include "BLI_noise.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "PIL_time.h" @@ -86,7 +87,7 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" + #include "RE_render_ext.h" #include "RE_shader_ext.h" diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 53c3534bce3..641313b564c 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -61,10 +61,11 @@ #include "DNA_camera_types.h" #include "DNA_scene_types.h" -#include "BKE_utildefines.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_storage.h" +#include "BLI_utildefines.h" + #include "BKE_blender.h" #include "BKE_global.h" @@ -74,7 +75,7 @@ #include "BKE_object.h" #include "BKE_material.h" #include "BKE_report.h" - +#include "BKE_exotic.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_curve.h" @@ -458,54 +459,49 @@ int BKE_read_exotic(Scene *scene, const char *name) { int len; gzFile gzfile; - char str[32]; - int *s0 = (int*) str; - int retval = 0; + char header[7]; + int retval; // make sure we're not trying to read a directory.... len= strlen(name); - if (name[len-1] !='/' && name[len-1] != '\\') { + if (ELEM(name[len-1], '/', '\\')) { + retval= BKE_READ_EXOTIC_FAIL_PATH; + } + else { gzfile = gzopen(name,"rb"); - if (NULL == gzfile ) { - //XXX error("Can't open file: %s", name); - retval= -1; - } else { - gzread(gzfile, str, 31); + if (gzfile == NULL) { + retval= BKE_READ_EXOTIC_FAIL_OPEN; + } + else { + len= gzread(gzfile, header, sizeof(header)); gzclose(gzfile); - - if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) { - + if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { + retval= BKE_READ_EXOTIC_OK_BLEND; + } + else { //XXX waitcursor(1); if(is_dxf(name)) { dxf_read(scene, name); - retval = 1; + retval= BKE_READ_EXOTIC_OK_OTHER; } else if(is_stl(name)) { if (is_stl_ascii(name)) read_stl_mesh_ascii(scene, name); else read_stl_mesh_binary(scene, name); - retval = 1; + retval= BKE_READ_EXOTIC_OK_OTHER; } -#ifdef WITH_PYTHON - // TODO: this should not be in the kernel... - else { // unknown format, call Python importloader - if (BPY_call_importloader(name)) { - retval = 1; - } else { - //XXX error("Unknown file type or error, check console"); - } - + else { + retval= BKE_READ_EXOTIC_FAIL_FORMAT; } -#endif /* WITH_PYTHON */ //XXX waitcursor(0); } } } - return (retval); + return retval; } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index f2bc586f15c..16d332c3bcb 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_fcurve.h" #include "BKE_animsys.h" @@ -1514,7 +1515,7 @@ static float evaluate_driver (ChannelDriver *driver, float UNUSED(evaltime)) /* this evaluates the expression using Python,and returns its result: * - on errors it reports, then returns 0.0f */ - driver->curval= BPY_eval_driver(driver); + driver->curval= BPY_driver_exec(driver); } #endif /* WITH_PYTHON*/ } diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index ef89d39864a..3db9731310c 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_customdata.h" @@ -51,7 +52,7 @@ #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" + // headers for fluidsim bobj meshes #include <stdlib.h> diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 0376d75d651..e4aeb45a209 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -38,10 +38,11 @@ #include "BLI_blenlib.h" #include "BLI_math.h" /* windows needs for M_PI */ +#include "BLI_utildefines.h" #include "BKE_fcurve.h" #include "BKE_idprop.h" -#include "BKE_utildefines.h" + #define SMALL -1.0e-10 #define SELECT 1 diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index ec63975a3c0..ecaa15c8f7d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_vfontdata.h" +#include "BLI_utildefines.h" #include "DNA_packedFile_types.h" #include "DNA_curve_types.h" @@ -49,9 +50,7 @@ #include "DNA_object_types.h" #include "BKE_utildefines.h" - #include "BKE_packedFile.h" - #include "BKE_library.h" #include "BKE_font.h" #include "BKE_global.h" @@ -860,12 +859,15 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) yof= cu->yof + tb->y/cu->fsize; } + /* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */ +#if 0 if(ascii == '\n' || ascii == '\r') xof = cu->xof; else xof= cu->xof + (tb->x/cu->fsize); - +#else xof= cu->xof + (tb->x/cu->fsize); +#endif lnr++; cnr= 0; wsnr= 0; diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 80f26277689..c3e2d7ffcf4 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -33,8 +33,8 @@ #include "MEM_guardedalloc.h" - #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_gpencil_types.h" @@ -42,7 +42,7 @@ #include "BKE_gpencil.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_utildefines.h" + /* ************************************************** */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index e125f3d4bd7..e48ec8ac288 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -41,8 +41,9 @@ #include "DNA_particle_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_group.h" #include "BKE_library.h" diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 30e4318e256..1df272fad30 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -40,6 +40,7 @@ #include "DNA_world_types.h" #include "DNA_brush_types.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BKE_icons.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 70bfc96f0a2..58e3b4ba552 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -60,6 +60,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_bmfont.h" #include "BKE_global.h" @@ -70,6 +71,7 @@ #include "BKE_packedFile.h" #include "BKE_scene.h" #include "BKE_node.h" +#include "BKE_utildefines.h" //XXX #include "BIF_editseq.h" diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index e19f36a2a0b..0df456a443d 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -37,12 +37,13 @@ #include "BLI_threads.h" #include "BLI_math.h" #include "BLI_linklist.h" +#include "BLI_utildefines.h" #include "BKE_cloth.h" #include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #define CLOTH_OPENMP_LIMIT 25 diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a040c27caa0..b4dd81ce356 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -59,8 +59,9 @@ #include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_animsys.h" #include "BKE_action.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 8cdfbaf9e2a..328fb1b6a49 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -39,6 +39,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_math_vector.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_key_types.h" @@ -57,13 +58,13 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" -#include "RNA_access.h" +#include "RNA_access.h" -#define KEY_BPOINT 1 -#define KEY_BEZTRIPLE 2 +#define KEY_MODE_DUMMY 0 /* use where mode isn't checked for */ +#define KEY_MODE_BPOINT 1 +#define KEY_MODE_BEZTRIPLE 2 // old defines from DNA_ipo_types.h for data-type #define IPO_FLOAT 4 @@ -523,36 +524,53 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char ** return kb->data; } -static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock *kb, float *weights, int mode) + +/* currently only the first value of 'ofs' may be set. */ +static short key_pointer_size(const Key *key, const int mode, int *poinsize, int *ofs) +{ + if(key->from==NULL) { + return FALSE; + } + + switch(GS(key->from->name)) { + case ID_ME: + *ofs= sizeof(float)*3; + *poinsize= *ofs; + break; + case ID_LT: + *ofs= sizeof(float)*3; + *poinsize= *ofs; + break; + case ID_CU: + if(mode == KEY_MODE_BPOINT) { + *ofs= sizeof(float)*4; + *poinsize= *ofs; + } else { + ofs[0]= sizeof(float)*12; + *poinsize= (*ofs) / 3; + } + + break; + default: + BKE_assert(!"invalid 'key->from' ID type"); + return FALSE; + } + + return TRUE; +} + +static void cp_key(const int start, int end, const int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock *kb, float *weights, const int mode) { float ktot = 0.0, kd = 0.0; int elemsize, poinsize = 0, a, *ofsp, ofs[32], flagflo=0; char *k1, *kref, *freek1, *freekref; char *cp, elemstr[8]; - if(key->from==NULL) return; - - if( GS(key->from->name)==ID_ME ) { - ofs[0]= sizeof(float)*3; - ofs[1]= 0; - poinsize= ofs[0]; - } - else if( GS(key->from->name)==ID_LT ) { - ofs[0]= sizeof(float)*3; - ofs[1]= 0; - poinsize= ofs[0]; - } - else if( GS(key->from->name)==ID_CU ) { - if(mode==KEY_BPOINT) { - ofs[0]= sizeof(float)*4; - poinsize= ofs[0]; - }else { - ofs[0]= sizeof(float)*12; - poinsize= ofs[0]/3; - } + /* currently always 0, in future key_pointer_size may assign */ + ofs[1]= 0; - ofs[1]= 0; - } + if(!key_pointer_size(key, mode, &poinsize, &ofs[0])) + return; if(end>tot) end= tot; @@ -584,7 +602,7 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * else k1+= start*key->elemsize; } - if(mode==KEY_BEZTRIPLE) { + if(mode == KEY_MODE_BEZTRIPLE) { elemstr[0]= 1; elemstr[1]= IPO_BEZTRIPLE; elemstr[2]= 0; @@ -592,11 +610,11 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * /* just do it here, not above! */ elemsize= key->elemsize; - if(mode==KEY_BEZTRIPLE) elemsize*= 3; + if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3; for(a=start; a<end; a++) { cp= key->elemstr; - if(mode==KEY_BEZTRIPLE) cp= elemstr; + if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr; ofsp= ofs; @@ -619,8 +637,14 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * case IPO_BEZTRIPLE: memcpy(poin, k1, sizeof(float)*12); break; + default: + /* should never happen */ + if(freek1) MEM_freeN(freek1); + if(freekref) MEM_freeN(freekref); + BKE_assert(!"invalid 'cp[1]'"); + return; } - + poin+= ofsp[0]; cp+= 2; ofsp++; } @@ -639,14 +663,14 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * kref+= elemsize; } - if(mode==KEY_BEZTRIPLE) a+=2; + if(mode == KEY_MODE_BEZTRIPLE) a+=2; } if(freek1) MEM_freeN(freek1); if(freekref) MEM_freeN(freekref); } -static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int start, int end, char *out, int tot) +static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const int start, int end, char *out, const int tot) { Nurb *nu; int a, step, a1, a2; @@ -658,7 +682,7 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int st a1= MAX2(a, start); a2= MIN2(a+step, end); - if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_BPOINT); + if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; @@ -667,45 +691,26 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int st a1= MAX2(a, start); a2= MIN2(a+step, end); - if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_BEZTRIPLE); + if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE); } else step= 0; } } - -void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock *actkb, int mode) +void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *key, KeyBlock *actkb, const int mode) { KeyBlock *kb; int *ofsp, ofs[3], elemsize, b; char *cp, *poin, *reffrom, *from, elemstr[8]; char *freefrom, *freereffrom; - int poinsize= 0; - - if(key->from==NULL) return; + int poinsize; - if( GS(key->from->name)==ID_ME ) { - ofs[0]= sizeof(float)*3; - ofs[1]= 0; - poinsize= ofs[0]; - } - else if( GS(key->from->name)==ID_LT ) { - ofs[0]= sizeof(float)*3; - ofs[1]= 0; - poinsize= ofs[0]; - } - else if( GS(key->from->name)==ID_CU ) { - if(mode==KEY_BPOINT) { - ofs[0]= sizeof(float)*4; - poinsize= ofs[0]; - } else { - ofs[0]= sizeof(float)*12; - poinsize= ofs[0] / 3; - } + /* currently always 0, in future key_pointer_size may assign */ + ofs[1]= 0; - ofs[1]= 0; - } + if(!key_pointer_size(key, mode, &poinsize, &ofs[0])) + return; if(end>tot) end= tot; @@ -716,7 +721,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock /* just here, not above! */ elemsize= key->elemsize; - if(mode==KEY_BEZTRIPLE) elemsize*= 3; + if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3; /* step 1 init */ cp_key(start, end, tot, basispoin, key, actkb, key->refkey, NULL, mode); @@ -752,7 +757,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock weight= icuval; cp= key->elemstr; - if(mode==KEY_BEZTRIPLE) cp= elemstr; + if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr; ofsp= ofs; @@ -768,8 +773,14 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock case IPO_BEZTRIPLE: rel_flerp(12, (float *)poin, (float *)reffrom, (float *)from, weight); break; + default: + /* should never happen */ + if(freefrom) MEM_freeN(freefrom); + if(freereffrom) MEM_freeN(freereffrom); + BKE_assert(!"invalid 'cp[1]'"); + return; } - + poin+= ofsp[0]; cp+= 2; @@ -779,7 +790,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock reffrom+= elemsize; from+= elemsize; - if(mode==KEY_BEZTRIPLE) b+= 2; + if(mode == KEY_MODE_BEZTRIPLE) b+= 2; if(weights) weights++; } @@ -791,7 +802,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock } -static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, int mode) +static void do_key(const int start, int end, const int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, const int mode) { float k1tot = 0.0, k2tot = 0.0, k3tot = 0.0, k4tot = 0.0; float k1d = 0.0, k2d = 0.0, k3d = 0.0, k4d = 0.0; @@ -800,29 +811,11 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * char *k1, *k2, *k3, *k4, *freek1, *freek2, *freek3, *freek4; char *cp, elemstr[8];; - if(key->from==0) return; - - if( GS(key->from->name)==ID_ME ) { - ofs[0]= sizeof(float)*3; - ofs[1]= 0; - poinsize= ofs[0]; - } - else if( GS(key->from->name)==ID_LT ) { - ofs[0]= sizeof(float)*3; - ofs[1]= 0; - poinsize= ofs[0]; - } - else if( GS(key->from->name)==ID_CU ) { - if(mode==KEY_BPOINT) { - ofs[0]= sizeof(float)*4; - poinsize= ofs[0]; - } else { - ofs[0]= sizeof(float)*12; - poinsize= ofs[0] / 3; - } + /* currently always 0, in future key_pointer_size may assign */ + ofs[1]= 0; - ofs[1]= 0; - } + if(!key_pointer_size(key, mode, &poinsize, &ofs[0])) + return; if(end>tot) end= tot; @@ -924,12 +917,12 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * /* only here, not above! */ elemsize= key->elemsize; - if(mode==KEY_BEZTRIPLE) elemsize*= 3; + if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3; for(a=start; a<end; a++) { cp= key->elemstr; - if(mode==KEY_BEZTRIPLE) cp= elemstr; + if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr; ofsp= ofs; @@ -945,6 +938,14 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * case IPO_BEZTRIPLE: flerp(12, (void *)poin, (void *)k1, (void *)k2, (void *)k3, (void *)k4, t); break; + default: + /* should never happen */ + if(freek1) MEM_freeN(freek1); + if(freek2) MEM_freeN(freek2); + if(freek3) MEM_freeN(freek3); + if(freek4) MEM_freeN(freek4); + BKE_assert(!"invalid 'cp[1]'"); + return; } poin+= ofsp[0]; @@ -993,7 +994,7 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * else k4+= elemsize; } - if(mode==KEY_BEZTRIPLE) a+= 2; + if(mode == KEY_MODE_BEZTRIPLE) a+= 2; } if(freek1) MEM_freeN(freek1); @@ -1067,7 +1068,7 @@ static float *get_weights_array(Object *ob, char *vgroup) return NULL; } -static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) +static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { KeyBlock *k[4], *actkb= ob_get_keyblock(ob); float cfra, ctime, t[4], delta; @@ -1102,9 +1103,9 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(a, a+step, tot, (char *)out, key, actkb, k, t, 0); + do_key(a, a+step, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } else { @@ -1114,7 +1115,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) for(kb= key->block.first; kb; kb= kb->next) kb->weights= get_weights_array(ob, kb->vgroup); - do_rel_key(0, tot, tot, (char *)out, key, actkb, 0); + do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); for(kb= key->block.first; kb; kb= kb->next) { if(kb->weights) MEM_freeN(kb->weights); @@ -1137,14 +1138,14 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(0, tot, tot, (char *)out, key, actkb, k, t, 0); + do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } } -static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, char *out, int tot) +static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, char *out, const int tot) { Nurb *nu; int a, step; @@ -1152,18 +1153,18 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BPOINT); + do_key(a, a+step, tot, out, key, actkb, k, t, KEY_MODE_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; - do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BEZTRIPLE); + do_key(a, a+step, tot, out, key, actkb, k, t, KEY_MODE_BEZTRIPLE); } else step= 0; } } -static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(ctime), char *out, int tot) +static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(ctime), char *out, const int tot) { Nurb *nu; int a, step; @@ -1171,18 +1172,18 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(cti for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - do_rel_key(a, a+step, tot, out, key, actkb, KEY_BPOINT); + do_rel_key(a, a+step, tot, out, key, actkb, KEY_MODE_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; - do_rel_key(a, a+step, tot, out, key, actkb, KEY_BEZTRIPLE); + do_rel_key(a, a+step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE); } else step= 0; } } -static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) +static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { Curve *cu= ob->data; KeyBlock *k[4], *actkb= ob_get_keyblock(ob); @@ -1206,11 +1207,11 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) for(nu=cu->nurb.first; nu; nu=nu->next) { if(nu->bp) { - mode= KEY_BPOINT; + mode= KEY_MODE_BPOINT; estep= nu->pntsu*nu->pntsv; } else if(nu->bezt) { - mode= KEY_BEZTRIPLE; + mode= KEY_MODE_BEZTRIPLE; estep= 3*nu->pntsu; } else @@ -1230,7 +1231,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) } count= MIN2(remain, estep); - if (mode == KEY_BEZTRIPLE) { + if (mode == KEY_MODE_BEZTRIPLE) { count += 3 - count % 3; } @@ -1268,7 +1269,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) } } -static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) +static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { Lattice *lt= ob->data; KeyBlock *k[4], *actkb= ob_get_keyblock(ob); @@ -1294,9 +1295,9 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(a, a+1, tot, (char *)out, key, actkb, k, t, 0); + do_key(a, a+1, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(a, a+1, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(a, a+1, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } else { @@ -1306,7 +1307,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) for(kb= key->block.first; kb; kb= kb->next) kb->weights= get_weights_array(ob, kb->vgroup); - do_rel_key(0, tot, tot, (char *)out, key, actkb, 0); + do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); for(kb= key->block.first; kb; kb= kb->next) { if(kb->weights) MEM_freeN(kb->weights); @@ -1326,9 +1327,9 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(0, tot, tot, (char *)out, key, actkb, k, t, 0); + do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 891d42c4a76..be3ec62374f 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -60,7 +61,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" + #include "BKE_deform.h" //XXX #include "BIF_editdeform.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 87174a4ae14..58167a866a3 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -67,11 +67,11 @@ #include "DNA_world_types.h" #include "DNA_gpencil_types.h" - #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_library.h" @@ -1271,18 +1271,36 @@ static void lib_indirect_test_id(ID *id, Library *lib) } } -void tag_main(struct Main *mainvar, int tag) +void tag_main_lb(ListBase *lb, const short tag) { - ListBase *lbarray[MAX_LIBARRAY]; ID *id; + if(tag) { + for(id= lb->first; id; id= id->next) { + id->flag |= LIB_DOIT; + } + } + else { + for(id= lb->first; id; id= id->next) { + id->flag &= ~LIB_DOIT; + } + } +} + +void tag_main_idcode(struct Main *mainvar, const short type, const short tag) +{ + ListBase *lb= which_libbase(mainvar, type); + + tag_main_lb(lb, tag); +} + +void tag_main(struct Main *mainvar, const short tag) +{ + ListBase *lbarray[MAX_LIBARRAY]; int a; a= set_listbasepointers(mainvar, lbarray); while(a--) { - for(id= lbarray[a]->first; id; id= id->next) { - if(tag) id->flag |= LIB_DOIT; - else id->flag &= ~LIB_DOIT; - } + tag_main_lb(lbarray[a], tag); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 9d6a430cb56..995c08fe481 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_displist.h" @@ -55,7 +56,7 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_node.h" -#include "BKE_utildefines.h" + #include "GPU_material.h" @@ -85,7 +86,8 @@ void free_material(Material *ma) BKE_free_animdata((ID *)ma); - BKE_previewimg_free(&ma->preview); + if(ma->preview) + BKE_previewimg_free(&ma->preview); BKE_icon_delete((struct ID*)ma); ma->id.icon_id = 0; @@ -251,7 +253,7 @@ Material *localize_material(Material *ma) if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); - if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); + man->preview = NULL; if(ma->nodetree) { man->nodetree= ntreeLocalize(ma->nodetree); @@ -786,6 +788,13 @@ int object_add_material_slot(Object *ob) ma= give_current_material(ob, ob->actcol); + if(ma == NULL) + ma= add_material("Material"); + else + ma= copy_material(ma); + + id_us_min(&ma->id); + assign_material(ob, ma, ob->totcol+1); ob->actcol= ob->totcol; return TRUE; @@ -809,10 +818,10 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) ma->texco |= mtex->texco; ma->mapto |= mtex->mapto; - if(r_mode & R_OSA) { - if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA; - else if(mtex->texflag & MTEX_NEW_BUMP) ma->texco |= TEXCO_OSA; // NEWBUMP: need texture derivatives for procedurals as well - } + + /* always get derivatives for these textures */ + if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA; + else if(mtex->texflag & MTEX_NEW_BUMP) ma->texco |= TEXCO_OSA; if(ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1; else if(ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1; @@ -1341,7 +1350,6 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) /* copy/paste buffer, if we had a propper py api that would be better */ Material matcopybuf; -// MTex mtexcopybuf; static short matcopied=0; void clear_matcopybuf(void) @@ -1352,7 +1360,6 @@ void clear_matcopybuf(void) void free_matcopybuf(void) { -// extern MTex mtexcopybuf; /* buttons.c */ int a; for(a=0; a<MAX_MTEX; a++) { @@ -1373,7 +1380,6 @@ void free_matcopybuf(void) MEM_freeN(matcopybuf.nodetree); matcopybuf.nodetree= NULL; } -// default_mtex(&mtexcopybuf); matcopied= 0; } @@ -1442,10 +1448,4 @@ void paste_matcopybuf(Material *ma) } ma->nodetree= ntreeCopyTree(matcopybuf.nodetree, 0); - - /* - BIF_preview_changed(ID_MA); - BIF_undo_push("Paste material settings"); - scrarea_queue_winredraw(curarea); - */ } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 8658d7e482f..6e48b922424 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -48,8 +48,9 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 7a72207ff69..dc4838366c4 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -43,6 +43,12 @@ #include "DNA_meshdata_types.h" #include "DNA_ipo_types.h" +#include "BLI_blenlib.h" +#include "BLI_editVert.h" +#include "BLI_math.h" +#include "BLI_edgehash.h" +#include "BLI_utildefines.h" + #include "BKE_animsys.h" #include "BKE_main.h" #include "BKE_DerivedMesh.h" @@ -58,12 +64,6 @@ #include "BKE_curve.h" /* -- */ #include "BKE_object.h" -#include "BKE_utildefines.h" - -#include "BLI_blenlib.h" -#include "BLI_editVert.h" -#include "BLI_math.h" -#include "BLI_edgehash.h" EditMesh *BKE_mesh_get_editmesh(Mesh *me) @@ -735,7 +735,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me) int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, MEdge **alledge, int *totedge, MFace **allface, int *totface) { - return nurbs_to_mdata_customdb(ob, &((Curve *)ob->data)->disp, + return nurbs_to_mdata_customdb(ob, &ob->disp, allvert, totvert, alledge, totedge, allface, totface); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index f8fdc9e32a4..03091b9b0a4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -40,11 +40,13 @@ #include <math.h> #include <float.h> +#include "MEM_guardedalloc.h" + #include "DNA_armature_types.h" #include "DNA_object_types.h" #include "DNA_meshdata_types.h" -#include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BKE_bmesh.h" #include "BKE_cloth.h" @@ -147,14 +149,14 @@ ModifierData *modifiers_findByName(Object *ob, const char *name) void modifiers_clearErrors(Object *ob) { ModifierData *md = ob->modifiers.first; - int qRedraw = 0; + /* int qRedraw = 0; */ for (; md; md=md->next) { if (md->error) { MEM_freeN(md->error); md->error = NULL; - qRedraw = 1; + /* qRedraw = 1; */ } } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 84350127968..6c1b8fb6047 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -38,6 +38,7 @@ #include "BLI_math.h" #include "BLI_pbvh.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" @@ -46,7 +47,7 @@ #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" -#include "BKE_utildefines.h" + #include "BKE_object.h" #include "CCGSubSurf.h" @@ -197,7 +198,7 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, return 1; } - mrdm->release(mrdm); + if(mrdm) mrdm->release(mrdm); return 0; } @@ -471,6 +472,128 @@ static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } + + +/* assumes no is normalized; return value's sign is negative if v is on + the other side of the plane */ +static float v3_dist_from_plane(float v[3], float center[3], float no[3]) +{ + float s[3]; + sub_v3_v3v3(s, v, center); + return dot_v3v3(s, no); +} + +void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) +{ + DerivedMesh *cddm, *dispdm, *origdm; + Mesh *me; + ListBase *fmap; + float (*origco)[3]; + int i, j, offset, totlvl; + + multires_force_update(ob); + + me = get_mesh(ob); + totlvl = mmd->totlvl; + + /* nothing to do */ + if(!totlvl) + return; + + /* XXX - probably not necessary to regenerate the cddm so much? */ + + /* generate highest level with displacements */ + cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); + dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0); + cddm->release(cddm); + + /* copy the new locations of the base verts into the mesh */ + offset = dispdm->getNumVerts(dispdm) - me->totvert; + for(i = 0; i < me->totvert; ++i) { + dispdm->getVertCo(dispdm, offset + i, me->mvert[i].co); + } + + /* heuristic to produce a better-fitting base mesh */ + + cddm = CDDM_from_mesh(me, NULL); + fmap = cddm->getFaceMap(ob, cddm); + origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco"); + for(i = 0; i < me->totvert ;++i) + copy_v3_v3(origco[i], me->mvert[i].co); + + for(i = 0; i < me->totvert; ++i) { + IndexNode *n; + float avg_no[3] = {0,0,0}, center[3] = {0,0,0}, push[3]; + float dist; + int tot; + + /* don't adjust verts not used by at least one face */ + if(!fmap[i].first) + continue; + + /* find center */ + for(n = fmap[i].first, tot = 0; n; n = n->next) { + MFace *f = &me->mface[n->index]; + int S = f->v4 ? 4 : 3; + + /* this double counts, not sure if that's bad or good */ + for(j = 0; j < S; ++j) { + int vndx = (&f->v1)[j]; + if(vndx != i) { + add_v3_v3(center, origco[vndx]); + ++tot; + } + } + } + mul_v3_fl(center, 1.0f / tot); + + /* find normal */ + for(n = fmap[i].first; n; n = n->next) { + MFace *f = &me->mface[n->index]; + int S = f->v4 ? 4 : 3; + float v[4][3], no[3]; + + for(j = 0; j < S; ++j) { + int vndx = (&f->v1)[j]; + if(vndx == i) + copy_v3_v3(v[j], center); + else + copy_v3_v3(v[j], origco[vndx]); + } + + if(S == 4) + normal_quad_v3(no, v[0], v[1], v[2], v[3]); + else + normal_tri_v3(no, v[0], v[1], v[2]); + add_v3_v3(avg_no, no); + } + normalize_v3(avg_no); + + /* push vertex away from the plane */ + dist = v3_dist_from_plane(me->mvert[i].co, center, avg_no); + copy_v3_v3(push, avg_no); + mul_v3_fl(push, dist); + add_v3_v3(me->mvert[i].co, push); + + } + + MEM_freeN(origco); + cddm->release(cddm); + + /* subdivide the mesh to highest level without displacements */ + cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); + origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0); + cddm->release(cddm); + + /* calc disps */ + multiresModifier_disp_run(dispdm, me, 1, 0, origdm->getGridData(origdm), totlvl); + + origdm->release(origdm); + dispdm->release(dispdm); +} + void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) { Mesh *me = ob->data; @@ -1870,7 +1993,7 @@ void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y) { float offset = face_side*0.5f - 0.5f; - int S; + int S = 0; if (corners == 4) { if(u <= offset && v <= offset) S = 0; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 5996bdc9f9a..72466261e14 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" @@ -46,7 +47,7 @@ #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_library.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" #include "nla_private.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index db11b42ee1e..c4d54cd6296 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -43,11 +43,10 @@ #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" - +#include "BKE_utildefines.h" #include "PIL_time.h" - #include "CMP_node.h" #include "intern/CMP_util.h" /* stupid include path... */ @@ -552,7 +551,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ld->next) { + for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; MEM_freeN(ld->data); @@ -867,7 +866,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ld->next) { + for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; MEM_freeN(ld->data); @@ -1270,8 +1269,7 @@ static void node_init_preview(bNode *node, int xsize, int ysize) node->preview->xsize= xsize; node->preview->ysize= ysize; } - else - memset(node->preview->rect, 0, 4*xsize + xsize*ysize*sizeof(char)*4); + /* no clear, makes nicer previews */ } void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 60503128f80..1ebbdf78f61 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -57,8 +57,9 @@ #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_pbvh.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_main.h" #include "BKE_global.h" @@ -2559,6 +2560,7 @@ void object_handle_update(Scene *scene, Object *ob) switch(ob->type) { case OB_MESH: { +#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; BKE_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); if(em) { @@ -2566,6 +2568,16 @@ void object_handle_update(Scene *scene, Object *ob) BKE_mesh_end_editmesh(ob->data, em); } else makeDerivedMesh(scene, ob, NULL, scene->customdata_mask); + +#else /* ensure CD_MASK_BAREMESH for now */ + EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + if(em) { + makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */ + BKE_mesh_end_editmesh(ob->data, em); + } else + makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH); +#endif + } break; diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index c278bf3b3d2..12ebaf7578a 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -47,6 +47,7 @@ #include "DNA_packedFile_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 116ed3c8ef2..853338d0722 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -31,7 +31,9 @@ #include "DNA_scene_types.h" #include "DNA_brush_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_brush.h" #include "BKE_library.h" #include "BKE_paint.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 95e14542e28..26f96d0c304 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -46,10 +46,11 @@ #include "DNA_scene_types.h" #include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_kdtree.h" #include "BLI_rand.h" #include "BLI_threads.h" -#include "BLI_math.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -61,7 +62,7 @@ #include "BKE_group.h" #include "BKE_main.h" #include "BKE_lattice.h" -#include "BKE_utildefines.h" + #include "BKE_displist.h" #include "BKE_particle.h" #include "BKE_object.h" @@ -1055,6 +1056,7 @@ typedef struct ParticleInterpolationData { static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2) { static PTCacheMem *pm = NULL; + int index1, index2; if(index < 0) { /* initialize */ *cur = cache->mem_cache.first; @@ -1069,15 +1071,19 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache, pm = *cur; - BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); - if(pm->prev->index_array && pm->prev->index_array[index] == 0) + index2 = BKE_ptcache_mem_index_find(pm, index); + index1 = BKE_ptcache_mem_index_find(pm->prev, index); + + BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame); + if(index1 < 0) copy_particle_key(key1, key2, 1); else - BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame); + BKE_ptcache_make_particle_key(key1, index1, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { pm = cache->mem_cache.first; - BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); + index2 = BKE_ptcache_mem_index_find(pm, index); + BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame); copy_particle_key(key1, key2, 1); } } @@ -1088,14 +1094,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float int ret = 0; for(pm=cache->mem_cache.first; pm; pm=pm->next) { - if(pm->index_array) { - if(pm->index_array[index]) { - *start = pm->frame; - ret++; - break; - } - } - else { + if(BKE_ptcache_mem_index_find(pm, index) >= 0) { *start = pm->frame; ret++; break; @@ -1103,14 +1102,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float } for(pm=cache->mem_cache.last; pm; pm=pm->prev) { - if(pm->index_array) { - if(pm->index_array[index]) { - *end = pm->frame; - ret++; - break; - } - } - else { + if(BKE_ptcache_mem_index_find(pm, index) >= 0) { *end = pm->frame; ret++; break; @@ -1125,13 +1117,8 @@ float psys_get_dietime_from_cache(PointCache *cache, int index) { int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */ for(pm=cache->mem_cache.last; pm; pm=pm->prev) { - if(pm->index_array) { - if(pm->index_array[index]) - return (float)pm->frame; - } - else { + if(BKE_ptcache_mem_index_find(pm, index) >= 0) return (float)pm->frame; - } } return (float)dietime; @@ -1862,144 +1849,184 @@ static float vert_weight(MDeformVert *dvert, int group) return 0.0; } -static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, short type, short axis, float obmat[][4]) +static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat, short type, short axis, float obmat[][4], int smooth_start) { - float vec[3]={0.0,0.0,0.0}, q1[4]={1,0,0,0},q2[4]; - float t; + float kink[3]={1.f,0.f,0.f}, par_vec[3], q1[4]={1.f,0.f,0.f,0.f}; + float t, dt=1.f, result[3]; + + if(par == NULL || type == PART_KINK_NO) + return; - CLAMP(time,0.0,1.0); + CLAMP(time, 0.f, 1.f); if(shape!=0.0f && type!=PART_KINK_BRAID) { if(shape<0.0f) - time= (float)pow(time, 1.0+shape); + time= (float)pow(time, 1.f+shape); else - time= (float)pow(time, 1.0/(1.0-shape)); + time= (float)pow(time, 1.f/(1.f-shape)); } - t=time; + t = time * freq *(float)M_PI; + + if(smooth_start) { + dt = fabs(t); + /* smooth the beginning of kink */ + CLAMP(dt, 0.f, (float)M_PI); + dt = sin(dt/2.f); + } - t*=(float)M_PI*freq; + if(type != PART_KINK_RADIAL) { + float temp[3]; - if(par==0) return; + kink[axis]=1.f; - switch(type){ - case PART_KINK_CURL: - vec[axis]=1.0; - if(par_rot) - QUATCOPY(q2,par_rot) - else - vec_to_quat( q2,par->vel,axis,(axis+1)%3); - mul_qt_v3(q2,vec); - mul_v3_fl(vec,amplitude); - VECADD(state->co,state->co,vec); + if(obmat) + mul_mat3_m4_v3(obmat, kink); + + if(par_rot) + mul_qt_v3(par_rot, kink); - VECSUB(vec,state->co,par->co); + /* make sure kink is normal to strand */ + project_v3_v3v3(temp, kink, par->vel); + sub_v3_v3(kink, temp); + normalize_v3(kink); + } - if(t!=0.0) - axis_angle_to_quat(q1,par->vel,t); - - mul_qt_v3(q1,vec); - - VECADD(state->co,par->co,vec); - break; - case PART_KINK_RADIAL: - VECSUB(vec,state->co,par->co); + copy_v3_v3(result, state->co); + sub_v3_v3v3(par_vec, par->co, state->co); - normalize_v3(vec); - mul_v3_fl(vec,amplitude*(float)sin(t)); + switch(type) { + case PART_KINK_CURL: + { + mul_v3_fl(par_vec, -1.f); - VECADD(state->co,state->co,vec); - break; - case PART_KINK_WAVE: - vec[axis]=1.0; - if(obmat) - mul_mat3_m4_v3(obmat,vec); + if(flat > 0.f) { + float proj[3]; + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(par_vec, proj, -flat); - if(par_rot) - mul_qt_v3(par_rot,vec); + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(par_vec, proj, -flat); + } - project_v3_v3v3(q1,vec,par->vel); - - VECSUB(vec,vec,q1); - normalize_v3(vec); + axis_angle_to_quat(q1, kink, (float)M_PI/2.f); - mul_v3_fl(vec,amplitude*(float)sin(t)); + mul_qt_v3(q1, par_vec); - VECADD(state->co,state->co,vec); - break; - case PART_KINK_BRAID: - if(par){ - float y_vec[3]={0.0,1.0,0.0}; - float z_vec[3]={0.0,0.0,1.0}; - float vec_from_par[3], vec_one[3], radius, state_co[3]; - float inp_y,inp_z,length; - - if(par_rot) - QUATCOPY(q2,par_rot) - else - vec_to_quat(q2,par->vel,axis,(axis+1)%3); - mul_qt_v3(q2,y_vec); - mul_qt_v3(q2,z_vec); - - VECSUB(vec_from_par,state->co,par->co); - radius= normalize_v3_v3(vec_one, vec_from_par); + madd_v3_v3fl(par_vec, kink, amplitude); - inp_y=dot_v3v3(y_vec,vec_one); - inp_z=dot_v3v3(z_vec,vec_one); + /* rotate kink vector around strand tangent */ + if(t!=0.f) { + axis_angle_to_quat(q1, par->vel, t); + mul_qt_v3(q1, par_vec); + } - if(inp_y>0.5){ - VECCOPY(state_co,y_vec); + add_v3_v3v3(result, par->co, par_vec); + break; + } + case PART_KINK_RADIAL: + { + if(flat > 0.f) { + float proj[3]; + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } - mul_v3_fl(y_vec,amplitude*(float)cos(t)); - mul_v3_fl(z_vec,amplitude/2.0f*(float)sin(2.0f*t)); - } - else if(inp_z>0.0){ - VECCOPY(state_co,z_vec); - mul_v3_fl(state_co,(float)sin(M_PI/3.0f)); - VECADDFAC(state_co,state_co,y_vec,-0.5f); + madd_v3_v3fl(result, par_vec, -amplitude*(float)sin(t)); + break; + } + case PART_KINK_WAVE: + { + madd_v3_v3fl(result, kink, amplitude*(float)sin(t)); - mul_v3_fl(y_vec,-amplitude*(float)cos(t + M_PI/3.0f)); - mul_v3_fl(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f)); - } - else{ - VECCOPY(state_co,z_vec); - mul_v3_fl(state_co,-(float)sin(M_PI/3.0f)); - VECADDFAC(state_co,state_co,y_vec,-0.5f); + if(flat > 0.f) { + float proj[3]; + /* flatten along wave */ + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(result, proj, flat); - mul_v3_fl(y_vec,amplitude*(float)-sin(t+M_PI/6.0f)); - mul_v3_fl(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f)); - } + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } + break; + } + case PART_KINK_BRAID: + { + float y_vec[3]={0.f,1.f,0.f}; + float z_vec[3]={0.f,0.f,1.f}; + float vec_one[3], radius, state_co[3]; + float inp_y, inp_z, length; - mul_v3_fl(state_co,amplitude); - VECADD(state_co,state_co,par->co); - VECSUB(vec_from_par,state->co,state_co); + mul_qt_v3(par_rot, y_vec); + mul_qt_v3(par_rot, z_vec); + + mul_v3_fl(par_vec, -1.f); + radius= normalize_v3_v3(vec_one, par_vec); - length=normalize_v3(vec_from_par); - mul_v3_fl(vec_from_par,MIN2(length,amplitude/2.0f)); + inp_y=dot_v3v3(y_vec, vec_one); + inp_z=dot_v3v3(z_vec, vec_one); - VECADD(state_co,par->co,y_vec); - VECADD(state_co,state_co,z_vec); - VECADD(state_co,state_co,vec_from_par); + if(inp_y>0.5){ + copy_v3_v3(state_co, y_vec); - shape=(2.0f*(float)M_PI)*(1.0f+shape); + mul_v3_fl(y_vec, amplitude*(float)cos(t)); + mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t)); + } + else if(inp_z>0.0){ + mul_v3_v3fl(state_co, z_vec, (float)sin(M_PI/3.f)); + VECADDFAC(state_co,state_co,y_vec,-0.5f); - if(t<shape){ - shape=t/shape; - shape=(float)sqrt((double)shape); - interp_v3_v3v3(state->co,state->co,state_co,shape); - } - else{ - VECCOPY(state->co,state_co); - } - } - break; + mul_v3_fl(y_vec, -amplitude * (float)cos(t + M_PI/3.f)); + mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + M_PI/6.f)); + } + else{ + mul_v3_v3fl(state_co, z_vec, -(float)sin(M_PI/3.f)); + madd_v3_v3fl(state_co, y_vec, -0.5f); + + mul_v3_fl(y_vec, amplitude * (float)-sin(t + M_PI/6.f)); + mul_v3_fl(z_vec, amplitude/2.f * (float)-sin(2.f*t + M_PI/3.f)); + } + + mul_v3_fl(state_co, amplitude); + add_v3_v3(state_co, par->co); + sub_v3_v3v3(par_vec, state->co, state_co); + + length = normalize_v3(par_vec); + mul_v3_fl(par_vec, MIN2(length, amplitude/2.f)); + + add_v3_v3v3(state_co, par->co, y_vec); + add_v3_v3(state_co, z_vec); + add_v3_v3(state_co, par_vec); + + shape = 2.f*(float)M_PI * (1.f+shape); + + if(t<shape){ + shape = t/shape; + shape = (float)sqrt((double)shape); + interp_v3_v3v3(result, result, state_co, shape); + } + else{ + copy_v3_v3(result, state_co); + } + break; + } } + + /* blend the start of the kink */ + if(dt < 1.f) + interp_v3_v3v3(state->co, state->co, result, dt); + else + copy_v3_v3(state->co, result); } -static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clumpfac, float clumppow, float pa_clump) +static float do_clump(ParticleKey *state, ParticleKey *par, float time, float clumpfac, float clumppow, float pa_clump) { + float clump = 0.f; + if(par && clumpfac!=0.0){ - float clump, cpow; + float cpow; if(clumppow<0.0) cpow=1.0f+clumppow; @@ -2010,8 +2037,11 @@ static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clu clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow); else clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow); + interp_v3_v3v3(state->co,state->co,par->co,clump); } + + return clump; } void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) { @@ -2124,7 +2154,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) } par.co[0] = par.co[1] = par.co[2] = 0.0f; VECCOPY(key.co, vec_to_point); - do_prekink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, pd->kink, pd->kink_axis, 0); + do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); do_clump(&key, &par, guidetime, pd->clump_fac, pd->clump_pow, 1.0f); VECCOPY(vec_to_point, key.co); @@ -2229,20 +2259,23 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st return k; } } -static void offset_child(ChildParticle *cpa, ParticleKey *par, ParticleKey *child, float flat, float radius) +static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, ParticleKey *child, float flat, float radius) { - VECCOPY(child->co,cpa->fuv); - mul_v3_fl(child->co,radius); + copy_v3_v3(child->co, cpa->fuv); + mul_v3_fl(child->co, radius); child->co[0]*=flat; - VECCOPY(child->vel,par->vel); - - mul_qt_v3(par->rot,child->co); + copy_v3_v3(child->vel, par->vel); - QUATCOPY(child->rot,par->rot); + if(par_rot) { + mul_qt_v3(par_rot, child->co); + copy_qt_qt(child->rot, par_rot); + } + else + unit_qt(child->rot); - VECADD(child->co,child->co,par->co); + add_v3_v3(child->co, par->co); } float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) { @@ -2372,12 +2405,9 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c if(totchild==0) return 0; /* init random number generator */ - if(ctx->sim.psys->part->flag & PART_ANIM_BRANCHING) - seed= 31415926 + ctx->sim.psys->seed + (int)cfra; - else - seed= 31415926 + ctx->sim.psys->seed; + seed= 31415926 + ctx->sim.psys->seed; - if(part->flag & PART_BRANCHING || ctx->editupdate || totchild < 10000) + if(ctx->editupdate || totchild < 10000) totthread= 1; for(i=0; i<totthread; i++) { @@ -2420,7 +2450,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c } /* note: this function must be thread safe, except for branching! */ -static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ParticleCacheKey *keys, int i) +static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ParticleCacheKey *child_keys, int i) { ParticleThreadContext *ctx= thread->ctx; Object *ob= ctx->sim.ob; @@ -2428,44 +2458,29 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle ParticleSettings *part = psys->part; ParticleCacheKey **cache= psys->childcache; ParticleCacheKey **pcache= psys_in_edit_mode(ctx->sim.scene, psys) ? psys->edit->pathcache : psys->pathcache; - ParticleCacheKey *state, *par = NULL, *key[4]; - ParticleData *pa=NULL; + ParticleCacheKey *child, *par = NULL, *key[4]; ParticleTexture ptex; - float *cpa_fuv=0, *par_rot=0; - float co[3], orco[3], ornor[3], hairmat[4][4], t, cpa_1st[3], dvec[3]; - float branch_begin, branch_end, branch_prob, rough_rand; + float *cpa_fuv=0, *par_rot=0, rot[4]; + float orco[3], ornor[3], hairmat[4][4], t, dvec[3], off1[4][3], off2[4][3]; float length, max_length = 1.0f, cur_length = 0.0f; - float eff_length, eff_vec[3]; + float eff_length, eff_vec[3], weight[4]; int k, cpa_num; short cpa_from; if(!pcache) return; - if(part->flag & PART_BRANCHING) { - branch_begin=rng_getFloat(thread->rng_path); - branch_end=branch_begin+(1.0f-branch_begin)*rng_getFloat(thread->rng_path); - branch_prob=rng_getFloat(thread->rng_path); - rough_rand=rng_getFloat(thread->rng_path); - } - else { - branch_begin= 0.0f; - branch_end= 0.0f; - branch_prob= 0.0f; - rough_rand= 0.0f; - } - - if(i<psys->totpart){ - branch_begin=0.0f; - branch_end=1.0f; - branch_prob=0.0f; - } - if(ctx->between){ + ParticleData *pa = psys->particles + cpa->pa[0]; int w, needupdate; - float foffset; - - if(ctx->editupdate && !(part->flag & PART_BRANCHING)) { + float foffset, wsum=0.f; + float co[3]; + float p_min = part->parting_min; + float p_max = part->parting_max; + /* Virtual parents don't work nicely with parting. */ + float p_fac = part->parents > 0.f ? 0.f : part->parting_fac; + + if(ctx->editupdate) { needupdate= 0; w= 0; while(w<4 && cpa->pa[w]>=0) { @@ -2479,223 +2494,223 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if(!needupdate) return; else - memset(keys, 0, sizeof(*keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); } /* get parent paths */ - w= 0; - while(w<4 && cpa->pa[w]>=0){ - key[w] = pcache[cpa->pa[w]]; - w++; + for(w=0; w<4; w++) { + if(cpa->pa[w] >= 0) { + key[w] = pcache[cpa->pa[w]]; + weight[w] = cpa->w[w]; + } + else { + key[w] = pcache[0]; + weight[w] = 0.f; + } + } + + /* modify weights to create parting */ + if(p_fac > 0.f) { + for(w=0; w<4; w++) { + if(w && weight[w] > 0.f) { + float d; + if(part->flag & PART_CHILD_LONG_HAIR) { + /* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */ + float d1 = len_v3v3(key[0]->co, key[w]->co); + float d2 = len_v3v3((key[0]+key[0]->steps-1)->co, (key[w]+key[w]->steps-1)->co); + + d = d1 > 0.f ? d2/d1 - 1.f : 10000.f; + } + else { + float v1[3], v2[3]; + sub_v3_v3v3(v1, (key[0]+key[0]->steps-1)->co, key[0]->co); + sub_v3_v3v3(v2, (key[w]+key[w]->steps-1)->co, key[w]->co); + normalize_v3(v1); + normalize_v3(v2); + + d = saacos(dot_v3v3(v1, v2)) * 180.f / M_PI; + } + + if(p_max > p_min) + d = (d - p_min)/(p_max - p_min); + else + d = (d - p_min) <= 0.f ? 0.f : 1.f; + + CLAMP(d, 0.f, 1.f); + + if(d > 0.f) + weight[w] *= (1.f - d); + } + wsum += weight[w]; + } + for(w=0; w<4; w++) + weight[w] /= wsum; + + interp_v4_v4v4(weight, cpa->w, weight, p_fac); } /* get the original coordinates (orco) for texture usage */ cpa_num = cpa->num; - foffset= cpa->foffset; + foffset = cpa->foffset; cpa_fuv = cpa->fuv; cpa_from = PART_FROM_FACE; psys_particle_on_emitter(ctx->sim.psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa->fuv,foffset,co,ornor,0,0,orco,0); - if(part->path_start==0.0f) { - /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ - VECCOPY(cpa_1st,co); - mul_m4_v3(ob->obmat,cpa_1st); - } + mul_m4_v3(ob->obmat, co); - pa = psys->particles + cpa->pa[0]; + for(w=0; w<4; w++) + sub_v3_v3v3(off1[w], co, key[w]->co); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); - - pa=0; } else{ - if(ctx->editupdate && !(part->flag & PART_BRANCHING)) { + ParticleData *pa = psys->particles + cpa->parent; + float co[3]; + if(ctx->editupdate) { if(!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) return; - memset(keys, 0, sizeof(*keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); } /* get the parent path */ - key[0]=pcache[cpa->parent]; + key[0] = pcache[cpa->parent]; /* get the original coordinates (orco) for texture usage */ - pa=psys->particles+cpa->parent; - - cpa_from=part->from; - cpa_num=pa->num; - cpa_fuv=pa->fuv; + cpa_from = part->from; + cpa_num = pa->num; + cpa_fuv = pa->fuv; psys_particle_on_emitter(ctx->sim.psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,ornor,0,0,orco,0); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); } - keys->steps = ctx->steps; - - /* correct child ipo timing */ -#if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - float dsta=part->end-part->sta; - calc_ipo(part->ipo, 100.0f*(ctx->cfra-(part->sta+dsta*cpa->rand[1]))/(part->lifetime*(1.0f - part->randlife*cpa->rand[0]))); - execute_ipo((ID *)part, part->ipo); - } -#endif // XXX old animation system + child_keys->steps = ctx->steps; /* get different child parameters from textures & vgroups */ get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex); if(ptex.exist < PSYS_FRAND(i + 24)) { - keys->steps = -1; + child_keys->steps = -1; return; } /* create the child path */ - for(k=0,state=keys; k<=ctx->steps; k++,state++){ + for(k=0,child=child_keys; k<=ctx->steps; k++,child++){ if(ctx->between){ int w=0; - state->co[0] = state->co[1] = state->co[2] = 0.0f; - state->vel[0] = state->vel[1] = state->vel[2] = 0.0f; - state->rot[0] = state->rot[1] = state->rot[2] = state->rot[3] = 0.0f; + zero_v3(child->co); + zero_v3(child->vel); + unit_qt(child->rot); - //QUATCOPY(state->rot,key[0]->rot); + for(w=0; w<4; w++) { + copy_v3_v3(off2[w], off1[w]); - /* child position is the weighted sum of parent positions */ - while(w<4 && cpa->pa[w]>=0){ - state->co[0] += cpa->w[w] * key[w]->co[0]; - state->co[1] += cpa->w[w] * key[w]->co[1]; - state->co[2] += cpa->w[w] * key[w]->co[2]; - - state->vel[0] += cpa->w[w] * key[w]->vel[0]; - state->vel[1] += cpa->w[w] * key[w]->vel[1]; - state->vel[2] += cpa->w[w] * key[w]->vel[2]; - key[w]++; - w++; - } - if(part->path_start==0.0f) { - if(k==0){ - /* calculate the offset between actual child root position and first position interpolated from parents */ - VECSUB(cpa_1st,cpa_1st,state->co); + if(part->flag & PART_CHILD_LONG_HAIR) { + /* Use parent rotation (in addition to emission location) to determine child offset. */ + if(k) + mul_qt_v3((key[w]+k)->rot, off2[w]); + + /* Fade the effect of rotation for even lengths in the end */ + project_v3_v3v3(dvec, off2[w], (key[w]+k)->vel); + madd_v3_v3fl(off2[w], dvec, -(float)k/(float)ctx->steps); } - /* apply offset for correct positioning */ - VECADD(state->co,state->co,cpa_1st); + + add_v3_v3(off2[w], (key[w]+k)->co); } + + /* child position is the weighted sum of parent positions */ + interp_v3_v3v3v3v3(child->co, off2[0], off2[1], off2[2], off2[3], weight); + interp_v3_v3v3v3v3(child->vel, (key[0]+k)->vel, (key[1]+k)->vel, (key[2]+k)->vel, (key[3]+k)->vel, weight); + + copy_qt_qt(child->rot, (key[0]+k)->rot); } else{ + if(k) { + mul_qt_qtqt(rot, (key[0]+k)->rot, key[0]->rot); + par_rot = rot; + } + else { + par_rot = key[0]->rot; + } /* offset the child from the parent position */ - offset_child(cpa, (ParticleKey*)key[0], (ParticleKey*)state, part->childflat, part->childrad); - - key[0]++; + offset_child(cpa, (ParticleKey*)(key[0]+k), par_rot, (ParticleKey*)child, part->childflat, part->childrad); } } /* apply effectors */ if(part->flag & PART_CHILD_EFFECT) { - for(k=0,state=keys; k<=ctx->steps; k++,state++) { + for(k=0,child=child_keys; k<=ctx->steps; k++,child++) { if(k) { - do_path_effectors(&ctx->sim, cpa->pa[0], state, k, ctx->steps, keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); + do_path_effectors(&ctx->sim, cpa->pa[0], child, k, ctx->steps, child_keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } else { - sub_v3_v3v3(eff_vec,(state+1)->co,state->co); - eff_length= len_v3(eff_vec); + sub_v3_v3v3(eff_vec, (child+1)->co, child->co); + eff_length = len_v3(eff_vec); } } } - for(k=0,state=keys; k<=ctx->steps; k++,state++){ - t=(float)k/(float)ctx->steps; + for(k=0,child=child_keys; k<=ctx->steps; k++,child++){ + t = (float)k/(float)ctx->steps; - if(ctx->totparent){ - if(i>=ctx->totparent) { - /* this is now threadsafe, virtual parents are calculated before rest of children */ - par = cache[cpa->parent] + k; + if(ctx->totparent) + /* this is now threadsafe, virtual parents are calculated before rest of children */ + par = (i >= ctx->totparent) ? cache[cpa->parent] : NULL; + else if(cpa->parent >= 0) + par = pcache[cpa->parent]; + + if(par) { + if(k) { + mul_qt_qtqt(rot, (par+k)->rot, par->rot); + par_rot = rot; } - else - par=0; - } - else if(cpa->parent>=0){ - par=pcache[cpa->parent]+k; - par_rot = par->rot; + else { + par_rot = par->rot; + } + par += k; } /* apply different deformations to the child path */ - do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)state, t); - - /* TODO: better branching */ - //if(part->flag & PART_BRANCHING && ctx->between == 0 && part->flag & PART_ANIM_BRANCHING) - // rough_t = t * rough_rand; - //else - // rough_t = t; - - /* TODO: better branching */ - //if(part->flag & PART_BRANCHING && ctx->between==0){ - // if(branch_prob > part->branch_thres){ - // branchfac=0.0f; - // } - // else{ - // if(part->flag & PART_SYMM_BRANCHING){ - // if(t < branch_begin || t > branch_end) - // branchfac=0.0f; - // else{ - // if((t-branch_begin)/(branch_end-branch_begin)<0.5) - // branchfac=2.0f*(t-branch_begin)/(branch_end-branch_begin); - // else - // branchfac=2.0f*(branch_end-t)/(branch_end-branch_begin); - - // CLAMP(branchfac,0.0f,1.0f); - // } - // } - // else{ - // if(t < branch_begin){ - // branchfac=0.0f; - // } - // else{ - // branchfac=(t-branch_begin)/((1.0f-branch_begin)*0.5f); - // CLAMP(branchfac,0.0f,1.0f); - // } - // } - // } - - // if(i<psys->totpart) - // interp_v3_v3v3(state->co, (pcache[i] + k)->co, state->co, branchfac); - // else - // /* this is not threadsafe, but should only happen for - // * branching particles particles, which are not threaded */ - // interp_v3_v3v3(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac); - //} + do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)child, t); /* we have to correct velocity because of kink & clump */ if(k>1){ - VECSUB((state-1)->vel,state->co,(state-2)->co); - mul_v3_fl((state-1)->vel,0.5); + sub_v3_v3v3((child-1)->vel, child->co, (child-2)->co); + mul_v3_fl((child-1)->vel, 0.5); if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) - get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel); + get_strand_normal(ctx->ma, ornor, cur_length, (child-1)->vel); } if(k == ctx->steps) - VECSUB(state->vel,state->co,(state-1)->co); + sub_v3_v3v3(child->vel, child->co, (child-1)->co); /* check if path needs to be cut before actual end of data points */ if(k){ - VECSUB(dvec,state->co,(state-1)->co); - length=1.0f/(float)ctx->steps; - k=check_path_length(k,keys,state,max_length,&cur_length,length,dvec); + sub_v3_v3v3(dvec, child->co, (child-1)->co); + length = 1.0f/(float)ctx->steps; + k = check_path_length(k, child_keys, child, max_length, &cur_length, length, dvec); } else{ /* initialize length calculation */ - max_length= ptex.length; - cur_length= 0.0f; + max_length = ptex.length; + cur_length = 0.0f; } if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) { - VECCOPY(state->col, &ctx->ma->r) - get_strand_normal(ctx->ma, ornor, cur_length, state->vel); + VECCOPY(child->col, &ctx->ma->r) + get_strand_normal(ctx->ma, ornor, cur_length, child->vel); } } + + /* Hide virtual parents */ + if(i < ctx->totparent) + child_keys->steps = -1; } static void *exec_child_path_cache(void *data) @@ -2721,7 +2736,6 @@ static void *exec_child_path_cache(void *data) void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupdate) { - ParticleSettings *part = sim->psys->part; ParticleThread *pthreads; ParticleThreadContext *ctx; ParticleCacheKey **cache; @@ -2742,7 +2756,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd totchild= ctx->totchild; totparent= ctx->totparent; - if(editupdate && sim->psys->childcache && !(part->flag & PART_BRANCHING) && totchild == sim->psys->totchildcache) { + if(editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { cache = sim->psys->childcache; } else { @@ -2783,6 +2797,43 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd psys_threads_free(pthreads); } +/* figure out incremental rotations along path starting from unit quat */ +static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCacheKey *key1, ParticleCacheKey *key2, float *prev_tangent, int i) +{ + float cosangle, angle, tangent[3], normal[3], q[4]; + + switch(i) { + case 0: + /* start from second key */ + break; + case 1: + /* calculate initial tangent for incremental rotations */ + sub_v3_v3v3(prev_tangent, key0->co, key1->co); + normalize_v3(prev_tangent); + unit_qt(key1->rot); + break; + default: + sub_v3_v3v3(tangent, key0->co, key1->co); + normalize_v3(tangent); + + cosangle= dot_v3v3(tangent, prev_tangent); + + /* note we do the comparison on cosangle instead of + * angle, since floating point accuracy makes it give + * different results across platforms */ + if(cosangle > 0.999999f) { + QUATCOPY(key1->rot, key2->rot); + } + else { + angle= saacos(cosangle); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt(key1->rot, q, key2->rot); + } + + copy_v3_v3(prev_tangent, tangent); + } +} /* Calculates paths ready for drawing/rendering. */ /* -Usefull for making use of opengl vertex arrays for super fast strand drawing. */ /* -Makes child strands possible and creates them too into the cache. */ @@ -2895,22 +2946,19 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /*--interpolate actual path from data points--*/ for(k=0, ca=cache[p]; k<=steps; k++, ca++){ time = (float)k / (float)steps; - t = birthtime + time * (dietime - birthtime); - result.time = -t; - do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, &result); + copy_v3_v3(ca->co, result.co); /* dynamic hair is in object space */ /* keyed and baked are already in global space */ if(hair_dm) - mul_m4_v3(sim->ob->obmat, result.co); + mul_m4_v3(sim->ob->obmat, ca->co); else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) - mul_m4_v3(hairmat, result.co); + mul_m4_v3(hairmat, ca->co); - VECCOPY(ca->co, result.co); - VECCOPY(ca->col, col); + copy_v3_v3(ca->col, col); } /*--modify paths and calculate rotation & velocity--*/ @@ -2945,54 +2993,25 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* finally do rotation & velocity */ for(k=1, ca=cache[p]+1; k<=steps; k++, ca++) { - /* figure out rotation */ - float cosangle, angle, tangent[3], normal[3], q[4]; - - if(k == 1) { - /* calculate initial tangent for incremental rotations */ - VECSUB(tangent, ca->co, (ca - 1)->co); - normalize_v3_v3(prev_tangent, tangent); - - /* First rotation is based on emitting face orientation. */ - /* This is way better than having flipping rotations resulting */ - /* from using a global axis as a rotation pole (vec_to_quat()). */ - /* It's not an ideal solution though since it disregards the */ - /* initial tangent, but taking that in to account will allow */ - /* the possibility of flipping again. -jahka */ - mat3_to_quat_is_ok( (ca-1)->rot,rotmat); - } - else { - VECSUB(tangent, ca->co, (ca - 1)->co); - normalize_v3(tangent); - - cosangle= dot_v3v3(tangent, prev_tangent); - - /* note we do the comparison on cosangle instead of - * angle, since floating point accuracy makes it give - * different results across platforms */ - if(cosangle > 0.999999f) { - QUATCOPY((ca - 1)->rot, (ca - 2)->rot); - } - else { - angle= saacos(cosangle); - cross_v3_v3v3(normal, prev_tangent, tangent); - axis_angle_to_quat( q,normal, angle); - mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); - } - - VECCOPY(prev_tangent, tangent); - } + cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k); if(k == steps) - QUATCOPY(ca->rot, (ca - 1)->rot); - + copy_qt_qt(ca->rot, (ca - 1)->rot); /* set velocity */ - VECSUB(ca->vel, ca->co, (ca-1)->co); + sub_v3_v3v3(ca->vel, ca->co, (ca-1)->co); if(k==1) - VECCOPY((ca-1)->vel, ca->vel); + copy_v3_v3((ca-1)->vel, ca->vel); } + /* First rotation is based on emitting face orientation. + * This is way better than having flipping rotations resulting + * from using a global axis as a rotation pole (vec_to_quat()). + * It's not an ideal solution though since it disregards the + * initial tangent, but taking that in to account will allow + * the possibility of flipping again. -jahka + */ + mat3_to_quat_is_ok(cache[p]->rot, rotmat); } psys->totcached = totpart; @@ -3047,12 +3066,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; - if(pset->brushtype == PE_BRUSH_WEIGHT){ - /* use weight painting colors now... */ -#if 0 - sel_col[0] = sel_col[1] = sel_col[2] = 1.0f; - nosel_col[0] = nosel_col[1] = nosel_col[2] = 0.0f; -#endif + if(pset->brushtype == PE_BRUSH_WEIGHT) { + ;/* use weight painting colors now... */ } else{ sel_col[0] = (float)edit->sel_col[0] / 255.0f; @@ -3093,9 +3108,9 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf if(psys) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - VECCOPY(rotmat[0], hairmat[2]); - VECCOPY(rotmat[1], hairmat[1]); - VECCOPY(rotmat[2], hairmat[0]); + copy_v3_v3(rotmat[0], hairmat[2]); + copy_v3_v3(rotmat[1], hairmat[1]); + copy_v3_v3(rotmat[2], hairmat[0]); } birthtime = pind.birthtime; @@ -3109,66 +3124,32 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /*--interpolate actual path from data points--*/ for(k=0, ca=cache[i]; k<=steps; k++, ca++){ time = (float)k / (float)steps; - t = birthtime + time * (dietime - birthtime); - result.time = -t; - do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); + copy_v3_v3(ca->co, result.co); /* non-hair points are already in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { - mul_m4_v3(hairmat, result.co); + mul_m4_v3(hairmat, ca->co); - /* create rotations for proper creation of children */ if(k) { - float cosangle, angle, tangent[3], normal[3], q[4]; - - if(k == 1) { - /* calculate initial tangent for incremental rotations */ - VECSUB(tangent, ca->co, (ca - 1)->co); - normalize_v3_v3(prev_tangent, tangent); - - /* First rotation is based on emitting face orientation. */ - /* This is way better than having flipping rotations resulting */ - /* from using a global axis as a rotation pole (vec_to_quat()). */ - /* It's not an ideal solution though since it disregards the */ - /* initial tangent, but taking that in to account will allow */ - /* the possibility of flipping again. -jahka */ - mat3_to_quat_is_ok( (ca-1)->rot,rotmat); - } - else { - VECSUB(tangent, ca->co, (ca - 1)->co); - normalize_v3(tangent); - - cosangle= dot_v3v3(tangent, prev_tangent); - - /* note we do the comparison on cosangle instead of - * angle, since floating point accuracy makes it give - * different results across platforms */ - if(cosangle > 0.999999f) { - QUATCOPY((ca - 1)->rot, (ca - 2)->rot); - } - else { - angle= saacos(cosangle); - cross_v3_v3v3(normal, prev_tangent, tangent); - axis_angle_to_quat( q,normal, angle); - mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); - } - - VECCOPY(prev_tangent, tangent); - } + cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k); if(k == steps) - QUATCOPY(ca->rot, (ca - 1)->rot); - } + copy_qt_qt(ca->rot, (ca - 1)->rot); - } - - VECCOPY(ca->co, result.co); + /* set velocity */ + sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co); - ca->vel[0] = ca->vel[1] = 0.0f; - ca->vel[1] = 1.0f; + if(k==1) + copy_v3_v3((ca - 1)->vel, ca->vel); + } + } + else { + ca->vel[0] = ca->vel[1] = 0.0f; + ca->vel[1] = 1.0f; + } /* selection coloring in edit mode */ if(pset->brushtype==PE_BRUSH_WEIGHT){ @@ -3216,6 +3197,16 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ca->time = t; } + if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { + /* First rotation is based on emitting face orientation. + * This is way better than having flipping rotations resulting + * from using a global axis as a rotation pole (vec_to_quat()). + * It's not an ideal solution though since it disregards the + * initial tangent, but taking that in to account will allow + * the possibility of flipping again. -jahka + */ + mat3_to_quat_is_ok(cache[i]->rot, rotmat); + } } edit->totcached = totpart; @@ -3492,6 +3483,7 @@ static void default_particle_settings(ParticleSettings *part) part->adapt_angle= 5; part->adapt_pix= 3; part->kink_axis= 2; + part->kink_amp_clump= 1.f; part->reactevent= PART_EVENT_DEATH; part->disp=100; part->from= PART_FROM_FACE; @@ -3921,11 +3913,15 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t); if(guided==0){ - if(kink_freq > 0.f) - do_prekink(state, par, par_rot, t, kink_freq, part->kink_shape, - part->kink_amp, part->kink, part->kink_axis, sim->ob->obmat); - - do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); + float clump = do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); + + if(kink_freq != 0.f) { + float kink_amp = part->kink_amp * (1.f - part->kink_amp_clump * clump); + + do_kink(state, par, par_rot, t, kink_freq, part->kink_shape, + kink_amp, part->kink_flat, part->kink, part->kink_axis, + sim->ob->obmat, sim->psys->part->childtype == PART_CHILD_FACES); + } } if(rough1 > 0.f) @@ -4114,7 +4110,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * } else{ /* offset the child from the parent position */ - offset_child(cpa, keys, state, part->childflat, part->childrad); + offset_child(cpa, keys, keys->rot, state, part->childflat, part->childrad); } par = keys; @@ -4212,7 +4208,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta float t = (cfra - pa->time) / pa->lifetime; key1=&pa->state; - offset_child(cpa, key1, state, part->childflat, part->childrad); + offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); CLAMP(t,0.0,1.0); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f0af7e8684b..3534a7dba37 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -63,6 +63,7 @@ #include "BLI_listbase.h" #include "BLI_threads.h" #include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */ +#include "BLI_utildefines.h" #include "BKE_main.h" #include "BKE_animsys.h" @@ -73,7 +74,7 @@ #include "BKE_effect.h" #include "BKE_particle.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #include "BKE_DerivedMesh.h" #include "BKE_object.h" #include "BKE_material.h" @@ -130,6 +131,16 @@ int psys_get_current_display_percentage(ParticleSystem *psys) return psys->part->disp; } +static int tot_particles(ParticleSystem *psys, PTCacheID *pid) +{ + if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) + return pid->cache->totpoint; + else if(psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) + return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res; + else + return psys->part->totpart; +} + void psys_reset(ParticleSystem *psys, int mode) { PARTICLE_P; @@ -137,7 +148,7 @@ void psys_reset(ParticleSystem *psys, int mode) if(ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) { if(mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) { /* don't free if not absolutely necessary */ - if(psys->totpart != psys->part->totpart) { + if(psys->totpart != tot_particles(psys, NULL)) { psys_free_particles(psys); psys->totpart= 0; } @@ -616,15 +627,21 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) } } +/* Find the index in "sum" array before "value" is crossed. */ static int binary_search_distribution(float *sum, int n, float value) { int mid, low=0, high=n; + if(value == 0.f) + return 0; + while(low <= high) { mid= (low + high)/2; - if(sum[mid] <= value && value <= sum[mid+1]) + + if(sum[mid] < value && value <= sum[mid+1]) return mid; - else if(sum[mid] > value) + + if(sum[mid] >= value) high= mid - 1; else if(sum[mid] < value) low= mid + 1; @@ -648,7 +665,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData DerivedMesh *dm= ctx->dm; ParticleData *tpa; /* ParticleSettings *part= ctx->sim.psys->part; */ - float *v1, *v2, *v3, *v4, nor[3], orco1[3], co1[3], co2[3], nor1[3], ornor1[3]; + float *v1, *v2, *v3, *v4, nor[3], orco1[3], co1[3], co2[3], nor1[3]; float cur_d, min_d, randu, randv; int from= ctx->from; int cfrom= ctx->cfrom; @@ -789,12 +806,9 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData int parent[10]; float pweight[10]; - /*do_seams= (part->flag&PART_CHILD_SEAMS && ctx->seams);*/ - - psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,0,0,orco1,ornor1); + psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL); transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); - //maxw = BLI_kdtree_find_n_nearest(ctx->tree,(do_seams)?10:4,orco1,ornor1,ptn); - maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,ornor1,ptn); + maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,NULL,ptn); maxd=ptn[maxw-1].dist; mind=ptn[0].dist; @@ -809,63 +823,6 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData parent[w]=-1; pweight[w]=0.0f; } - //if(do_seams){ - // ParticleSeam *seam=ctx->seams; - // float temp[3],temp2[3],tan[3]; - // float inp,cur_len,min_len=10000.0f; - // int min_seam=0, near_vert=0; - // /* find closest seam */ - // for(i=0; i<ctx->totseam; i++, seam++){ - // sub_v3_v3v3(temp,co1,seam->v0); - // inp=dot_v3v3(temp,seam->dir)/seam->length2; - // if(inp<0.0f){ - // cur_len=len_v3v3(co1,seam->v0); - // } - // else if(inp>1.0f){ - // cur_len=len_v3v3(co1,seam->v1); - // } - // else{ - // copy_v3_v3(temp2,seam->dir); - // mul_v3_fl(temp2,inp); - // cur_len=len_v3v3(temp,temp2); - // } - // if(cur_len<min_len){ - // min_len=cur_len; - // min_seam=i; - // if(inp<0.0f) near_vert=-1; - // else if(inp>1.0f) near_vert=1; - // else near_vert=0; - // } - // } - // seam=ctx->seams+min_seam; - // - // copy_v3_v3(temp,seam->v0); - // - // if(near_vert){ - // if(near_vert==-1) - // sub_v3_v3v3(tan,co1,seam->v0); - // else{ - // sub_v3_v3v3(tan,co1,seam->v1); - // copy_v3_v3(temp,seam->v1); - // } - - // normalize_v3(tan); - // } - // else{ - // copy_v3_v3(tan,seam->tan); - // sub_v3_v3v3(temp2,co1,temp); - // if(dot_v3v3(tan,temp2)<0.0f) - // negate_v3(tan); - // } - // for(w=0; w<maxw; w++){ - // sub_v3_v3v3(temp2,ptn[w].co,temp); - // if(dot_v3v3(tan,temp2)<0.0f){ - // parent[w]=-1; - // pweight[w]=0.0f; - // } - // } - - //} for(w=0,i=0; w<maxw && i<4; w++){ if(parent[w]>=0){ @@ -1001,6 +958,8 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, if(from==PART_FROM_CHILD){ distr=PART_DISTR_RAND; + BLI_srandom(31415926 + psys->seed + psys->child_seed); + if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ dm= finaldm; children=1; @@ -1017,50 +976,6 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, totpart=get_psys_tot_child(scene, psys); cfrom=from=PART_FROM_FACE; - - //if(part->flag&PART_CHILD_SEAMS){ - // MEdge *ed, *medge=dm->getEdgeDataArray(dm,CD_MEDGE); - // MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); - // int totedge=dm->getNumEdges(dm); - - // for(p=0, ed=medge; p<totedge; p++,ed++) - // if(ed->flag&ME_SEAM) - // totseam++; - - // if(totseam){ - // ParticleSeam *cur_seam=seams=MEM_callocN(totseam*sizeof(ParticleSeam),"Child Distribution Seams"); - // float temp[3],temp2[3]; - - // for(p=0, ed=medge; p<totedge; p++,ed++){ - // if(ed->flag&ME_SEAM){ - // copy_v3_v3(cur_seam->v0,(mvert+ed->v1)->co); - // copy_v3_v3(cur_seam->v1,(mvert+ed->v2)->co); - - // sub_v3_v3v3(cur_seam->dir,cur_seam->v1,cur_seam->v0); - - // cur_seam->length2=len_v3(cur_seam->dir); - // cur_seam->length2*=cur_seam->length2; - - // temp[0]=(float)((mvert+ed->v1)->no[0]); - // temp[1]=(float)((mvert+ed->v1)->no[1]); - // temp[2]=(float)((mvert+ed->v1)->no[2]); - // temp2[0]=(float)((mvert+ed->v2)->no[0]); - // temp2[1]=(float)((mvert+ed->v2)->no[1]); - // temp2[2]=(float)((mvert+ed->v2)->no[2]); - - // add_v3_v3v3(cur_seam->nor,temp,temp2); - // normalize_v3(cur_seam->nor); - - // cross_v3_v3v3(cur_seam->tan,cur_seam->dir,cur_seam->nor); - - // normalize_v3(cur_seam->tan); - - // cur_seam++; - // } - // } - // } - // - //} } else{ /* no need to figure out distribution */ @@ -1297,7 +1212,8 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, float pos; for(p=0; p<totpart; p++) { - pos= BLI_frand(); + /* In theory sys[tot] should be 1.0, but due to float errors this is not necessarily always true, so scale pos accordingly. */ + pos= BLI_frand() * sum[tot]; index[p]= binary_search_distribution(sum, tot, pos); index[p]= MIN2(tot-1, index[p]); jitoff[index[p]]= pos; @@ -2943,7 +2859,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { pa->alive = PARS_DYING; - pa->dietime = pa->state.time + (cfra - pa->state.time) * f; + pa->dietime = sim->psys->cfra + (cfra - sim->psys->cfra) * f; copy_v3_v3(pa->state.co, co); interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, f); @@ -3297,8 +3213,8 @@ static void hair_step(ParticleSimulationData *sim, float cfra) cloth_free_modifier(psys->clmd); } - /* dynamics with cloth simulation */ - if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) + /* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */ + if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles) do_hair_dynamics(sim); /* following lines were removed r29079 but cause bug [#22811], see report for details */ @@ -3572,7 +3488,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; PARTICLE_P; - float disp, birthtime, dietime; + float disp, dietime; BLI_srandom(psys->seed); @@ -3587,7 +3503,6 @@ static void cached_step(ParticleSimulationData *sim, float cfra) psys->lattice= psys_get_lattice(sim); - birthtime = pa->time; dietime = pa->dietime; /* update alive status and push events */ @@ -3726,16 +3641,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNUSED(cfra)) { ParticleSystem *psys = sim->psys; - ParticleSettings *part = psys->part; int oldtotpart = psys->totpart; - int totpart = oldtotpart; - - if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) - totpart = pid->cache->totpoint; - else if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) - totpart = part->grid_res*part->grid_res*part->grid_res; - else - totpart = psys->part->totpart; + int totpart = tot_particles(psys, pid); if(totpart != oldtotpart) realloc_particles(sim, totpart); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b8e8508da26..1d58f276117 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -44,6 +44,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "PIL_time.h" @@ -63,6 +64,7 @@ #include "BKE_smoke.h" #include "BKE_softbody.h" #include "BKE_utildefines.h" + #include "BIK_api.h" /* both in intern */ @@ -115,7 +117,7 @@ static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, size_t size); /* Common functions */ static int ptcache_basic_header_read(PTCacheFile *pf) { - uint32_t totpoint, data_types; + uint32_t totpoint, data_types= 0; int error=0; /* Custom functions should read these basic elements too! */ @@ -1159,6 +1161,39 @@ static void ptcache_file_pointers_init(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<<BPHYS_DATA_BOIDS)) ? &pf->data.boids : NULL; } +/* Check to see if point number "index" is in pm, uses binary search for index data. */ +int BKE_ptcache_mem_index_find(PTCacheMem *pm, int index) +{ + if(pm->data[BPHYS_DATA_INDEX]) { + uint32_t key = index; + uint32_t *data = pm->data[BPHYS_DATA_INDEX]; + uint32_t mid, low = 0, high = pm->totpoint - 1; + + if(key < *data || key > *(data+high)) + return -1; + + /* check simple case for continuous indexes first */ + if(data[key-*data]==key) + return key-*data; + + while(low <= high) { + mid= (low + high)/2; + + if(data[mid] > key) + high = mid - 1; + else if(data[mid] < key) + low = mid + 1; + else + return mid; + } + + return -1; + } + else { + return (index < pm->totpoint ? index : -1); + } +} + void BKE_ptcache_mem_pointers_init(PTCacheMem *pm) { int data_types = pm->data_types; @@ -1180,7 +1215,7 @@ void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm) int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm) { int data_types = pm->data_types; - int i, index = pm->index_array ? pm->index_array[point_index] - 1 : point_index; + int i, index = BKE_ptcache_mem_index_find(pm, point_index); if(index < 0) { /* Can't give proper location without reallocation, so don't give any location. @@ -1216,11 +1251,6 @@ static void ptcache_data_free(PTCacheMem *pm) if(data[i]) MEM_freeN(data[i]); } - - if(pm->index_array) { - MEM_freeN(pm->index_array); - pm->index_array = NULL; - } } static void ptcache_data_copy(void *from[], void *to[]) { @@ -1304,24 +1334,6 @@ static void ptcache_find_frames_around(PTCacheID *pid, int frame, int *fra1, int } } } -static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) -{ - int i, *index; - - if(pm->index_array) { - MEM_freeN(pm->index_array); - pm->index_array = NULL; - } - - if(!pm->data[BPHYS_DATA_INDEX]) - return; - - pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); - index = pm->data[BPHYS_DATA_INDEX]; - - for(i=0; i<pm->totpoint; i++, index++) - pm->index_array[*index] = i + 1; -} static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) { @@ -1396,9 +1408,6 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) } } - if(!error) - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, pm->frame)); - if(error && pm) { ptcache_data_free(pm); ptcache_extra_free(pm); @@ -1804,7 +1813,6 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) } } else { - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); BLI_addtail(&cache->mem_cache, pm); } @@ -2252,17 +2260,18 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) } for(psys=ob->particlesystem.first; psys; psys=psys->next) { - /* Baked cloth hair has to be checked first, because we don't want to reset */ + /* children or just redo can be calculated without reseting anything */ + if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD) + skip = 1; + /* Baked cloth hair has to be checked too, because we don't want to reset */ /* particles or cloth in that case -jahka */ - if(psys->clmd) { + else if(psys->clmd) { BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd); if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) reset |= BKE_ptcache_id_reset(scene, &pid, mode); else skip = 1; } - else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD) - skip = 1; if(skip == 0 && psys->part) { BKE_ptcache_id_from_particles(&pid, ob, psys); @@ -2986,7 +2995,6 @@ void BKE_ptcache_update_info(PTCacheID *pid) bytes += sizeof(PTCacheExtra); } - bytes += MEM_allocN_len(pm->index_array); bytes += sizeof(PTCacheMem); totframes++; diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 5df912c871d..a22b36b9524 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -29,10 +29,11 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_report.h" #include "BKE_global.h" /* G.background only */ -#include "BKE_utildefines.h" + #include <stdarg.h> #include <stdio.h> diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fcaf44e2961..fe6d834cb70 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -39,6 +39,8 @@ #include <io.h> #endif +#include "MEM_guardedalloc.h" + #include "DNA_anim_types.h" #include "DNA_group_types.h" #include "DNA_object_types.h" @@ -46,7 +48,9 @@ #include "DNA_screen_types.h" #include "DNA_sequence_types.h" -#include "MEM_guardedalloc.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -63,15 +67,12 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_world.h" -#include "BKE_utildefines.h" + #include "BKE_sound.h" //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" - #include "FRS_freestyle_config.h" //XXX #include "nla.h" diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index b25c533ad4c..122e186bcd7 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -32,6 +32,7 @@ #include "DNA_sequence_types.h" #include "BKE_sequencer.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_mempool.h" #include <pthread.h> diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c11b51b9dd4..2f90da2296b 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -35,6 +35,7 @@ #include "PIL_dynlib.h" #include "BLI_math.h" /* windows needs for M_PI */ +#include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" @@ -1591,15 +1592,10 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo // This function calculates the blur band for the wipe effects static float in_band(WipeZone *wipezone,float width,float dist,float perc,int side,int dir) { - float t1,t2,alpha,percwidth; + float t1,t2,alpha; if(width == 0) return (float)side; - - if(side == 1) - percwidth = width * perc; - else - percwidth = width * (1 - perc); if(width < dist) return side; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1b5d1093373..5f25e419eec 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -41,6 +41,14 @@ #include "DNA_object_types.h" #include "DNA_sound_types.h" +#include "BLI_math.h" +#include "BLI_fileops.h" +#include "BLI_listbase.h" +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_threads.h" +#include "BLI_utildefines.h" + #include "BKE_animsys.h" #include "BKE_global.h" #include "BKE_image.h" @@ -49,14 +57,10 @@ #include "BKE_fcurve.h" #include "BKE_scene.h" #include "RNA_access.h" +#include "BKE_utildefines.h" + #include "RE_pipeline.h" -#include "BLI_math.h" -#include "BLI_fileops.h" -#include "BLI_listbase.h" -#include "BLI_path_util.h" -#include "BLI_string.h" -#include "BLI_threads.h" #include <pthread.h> #include "IMB_imbuf.h" @@ -330,7 +334,7 @@ unsigned int seq_hash_render_data(const SeqRenderData * a) return rval; } -/* ************************* itterator ************************** */ +/* ************************* iterator ************************** */ /* *************** (replaces old WHILE_SEQ) ********************* */ /* **************** use now SEQ_BEGIN() SEQ_END ***************** */ diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 16e4933332c..753e31d565b 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto + * Contributor(s): Andr Pinto * * ***** END GPL LICENSE BLOCK ***** */ @@ -40,18 +40,18 @@ #include "DNA_mesh_types.h" #include "DNA_scene_types.h" +#include "BLI_editVert.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + #include "BKE_shrinkwrap.h" #include "BKE_DerivedMesh.h" #include "BKE_lattice.h" -#include "BKE_utildefines.h" + #include "BKE_deform.h" #include "BKE_mesh.h" #include "BKE_subsurf.h" -#include "BLI_editVert.h" -#include "BLI_math.h" - - /* Util macros */ #define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n")) diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 7e39cdd1196..06c6e0f197a 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -31,9 +31,10 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_sketch.h" -#include "BKE_utildefines.h" + #include "DNA_userdef_types.h" diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 9a0f278bcd0..8039d729842 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -48,6 +48,7 @@ #include "BLI_edgehash.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" +#include "BLI_utildefines.h" #include "BKE_bvhutils.h" #include "BKE_cdderivedmesh.h" @@ -58,7 +59,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_smoke.h" -#include "BKE_utildefines.h" + #include "DNA_customdata_types.h" #include "DNA_group_types.h" diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index eb56331acfb..e38f1bb545c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -63,6 +63,7 @@ variables on the UI for now #include "DNA_meshdata_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_threads.h" @@ -2452,7 +2453,8 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bproot; ListBase *do_effector = NULL; - float iks, gravity; + float gravity; + /* float iks; */ float fieldfactor = -1.0f, windfactor = 0.25; int do_deflector,do_selfcollision,do_springcollision,do_aero; @@ -2464,7 +2466,7 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); - iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ + /* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */ bproot= sb->bpoint; /* need this for proper spring addressing */ if (do_springcollision || do_aero) diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 874fd0fef17..e139820be32 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -41,6 +41,13 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_blenlib.h" +#include "BLI_edgehash.h" +#include "BLI_math.h" +#include "BLI_memarena.h" +#include "BLI_pbvh.h" +#include "BLI_utildefines.h" + #include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" @@ -48,13 +55,7 @@ #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" -#include "BKE_utildefines.h" -#include "BLI_blenlib.h" -#include "BLI_edgehash.h" -#include "BLI_math.h" -#include "BLI_memarena.h" -#include "BLI_pbvh.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -1372,7 +1373,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v ccgdm_pbvh_update(ccgdm); doDraw = 0; - numVerts = 0; matnr = -1; transp = GPU_get_material_blend_mode(); orig_transp = transp; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bb3a31a0977..0b5347ca304 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_constraint_types.h" #include "DNA_controller_types.h" @@ -51,7 +52,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_text.h" -#include "BKE_utildefines.h" + #ifdef WITH_PYTHON #include "BPY_extern.h" @@ -168,7 +169,7 @@ void free_text(Text *text) if(text->name) MEM_freeN(text->name); MEM_freeN(text->undo_buf); #ifdef WITH_PYTHON - if (text->compiled) BPY_free_compiled_text(text); + if (text->compiled) BPY_text_free_code(text); #endif } @@ -684,7 +685,7 @@ static void txt_make_dirty (Text *text) { text->flags |= TXT_ISDIRTY; #ifdef WITH_PYTHON - if (text->compiled) BPY_free_compiled_text(text); + if (text->compiled) BPY_text_free_code(text); #endif } @@ -1232,7 +1233,7 @@ int txt_find_string(Text *text, char *findstr, int wrap) { TextLine *tl, *startl; char *s= NULL; - int oldcl, oldsl, oldcc, oldsc; + int oldcl, oldsl; if (!text || !text->curl || !text->sell) return 0; @@ -1241,8 +1242,6 @@ int txt_find_string(Text *text, char *findstr, int wrap) oldcl= txt_get_span(text->lines.first, text->curl); oldsl= txt_get_span(text->lines.first, text->sell); tl= startl= text->sell; - oldcc= text->curc; - oldsc= text->selc; s= strstr(&tl->line[text->selc], findstr); while (!s) { diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 595b85955b8..11c0ce74b4a 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -38,11 +38,10 @@ #include "PIL_dynlib.h" - - #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_kdopbvh.h" +#include "BLI_utildefines.h" #include "DNA_key_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index de708f216fd..014a15de1ef 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -38,11 +38,12 @@ #include "DNA_scene_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + #include "BKE_writeavi.h" #include "AVI_avi.h" diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index dd63c266491..eb1c66604f8 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -47,7 +47,9 @@ #include "DNA_userdef_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_global.h" #include "BKE_report.h" diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 96505dae448..46c0f767b5f 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -40,8 +40,6 @@ extern "C" { #include <stdlib.h> #include <string.h> -#include "BKE_utildefines.h" - #include "BLI_mempool.h" #include "BLI_blenlib.h" diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 3c2c6312f4d..f8a4ee48c6f 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -58,7 +58,8 @@ float dist_to_line_v2(float p[2], float l1[2], float l2[2]); float dist_to_line_segment_v2(float p[2], float l1[2], float l2[2]); float dist_to_line_segment_v3(float p[3], float l1[3], float l2[3]); -float closest_to_line_v3(float r[3], float p[3], float l1[3], float l2[3]); +float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); +float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]); void closest_to_line_segment_v3(float r[3], float p[3], float l1[3], float l2[3]); /******************************* Intersection ********************************/ diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 7b21c5f6df7..8fbd0205b41 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -165,8 +165,8 @@ int is_negative_m4(float mat[4][4]); /*********************************** Other ***********************************/ -void print_m3(char *str, float M[3][3]); -void print_m4(char *str, float M[3][4]); +void print_m3(const char *str, float M[3][3]); +void print_m4(const char *str, float M[3][4]); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 5f6251bf382..43cf612c33c 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -175,6 +175,8 @@ void range_vni(int *array, const int size, const int start); void mul_vn_fl(float *array, const int size, const float f); void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f); void add_vn_vn(float *array_tar, const float *array_src, const int size); +void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size); +void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size); void fill_vni(int *array_tar, const int size, const int val); void fill_vn(float *array_tar, const int size, const float val); diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h new file mode 100644 index 00000000000..468c146a65d --- /dev/null +++ b/source/blender/blenlib/BLI_utildefines.h @@ -0,0 +1,218 @@ +/* + * $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 BLI_UTILDEFINES_H +#define BLI_UTILDEFINES_H + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + + +#define ELEM(a, b, c) ( (a)==(b) || (a)==(c) ) +#define ELEM3(a, b, c, d) ( ELEM(a, b, c) || (a)==(d) ) +#define ELEM4(a, b, c, d, e) ( ELEM(a, b, c) || ELEM(a, d, e) ) +#define ELEM5(a, b, c, d, e, f) ( ELEM(a, b, c) || ELEM3(a, d, e, f) ) +#define ELEM6(a, b, c, d, e, f, g) ( ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) +#define ELEM7(a, b, c, d, e, f, g, h) ( ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) +#define ELEM8(a, b, c, d, e, f, g, h, i) ( ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) +#define ELEM9(a, b, c, d, e, f, g, h, i, j) ( ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) +#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) ( ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) ) +#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) ( ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) ) + +/* shift around elements */ +#define SHIFT3(type, a, b, c) { type tmp; tmp = a; a = c; c = b; b = tmp; } +#define SHIFT4(type, a, b, c, d) { type tmp; tmp = a; a = d; d = c; c = b; b = tmp; } + +/* min/max */ +#define MIN2(x,y) ( (x)<(y) ? (x) : (y) ) +#define MIN3(x,y,z) MIN2( MIN2((x),(y)) , (z) ) +#define MIN4(x,y,z,a) MIN2( MIN2((x),(y)) , MIN2((z),(a)) ) + +#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) +#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) ) +#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) ) + +#define INIT_MINMAX(min, max) { (min)[0]= (min)[1]= (min)[2]= 1.0e30f; (max)[0]= (max)[1]= (max)[2]= -1.0e30f; } + +#define INIT_MINMAX2(min, max) { (min)[0]= (min)[1]= 1.0e30f; (max)[0]= (max)[1]= -1.0e30f; } + +#define DO_MIN(vec, min) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \ + if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \ + if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; } \ + +#define DO_MAX(vec, max) { if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ + if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \ + if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \ + +#define DO_MINMAX(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \ + if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \ + if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \ + if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ + if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \ + if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \ + +#define DO_MINMAX2(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \ + if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \ + if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \ + if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; } + +/* some math and copy defines */ + +#ifndef SWAP +#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } +#endif + +#define ABS(a) ( (a)<0 ? (-(a)) : (a) ) + +#define AVG2(x, y) ( 0.5 * ((x) + (y)) ) + +#define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f)) +#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f)) + +#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);} +#define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);} +#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);} +#define LONGCOPY(a, b, c) {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);} + + +#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);} +#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);} +#define VECSUB2D(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);} +#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);} +#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);} +#define QUATADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac); *(v1+3)= *(v2+3) + *(v3+3)*(fac);} + +#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] ) + +/* some misc stuff.... */ +#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c) +#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a)) +#define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);} + +#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1) + +#define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0))) +#define IN_RANGE(a, b, c) ((b < c)? ((b<a && a<c)? 1:0) : ((c<a && a<b)? 1:0)) +#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0)) + + +/* This one rotates the bytes in an int64, int (32) and short (16) */ +#define SWITCH_INT64(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ + s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ + s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ + s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } + + #define SWITCH_INT(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \ + s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; } + +#define SWITCH_SHORT(a) { \ + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; } + + +/* Warning-free macros for storing ints in pointers. Use these _only_ + * for storing an int in a pointer, not a pointer in an int (64bit)! */ +#define SET_INT_IN_POINTER(i) ((void*)(intptr_t)(i)) +#define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) + +/* Macro to convert a value to string in the preprocessor + * STRINGIFY_ARG: gives the defined name in the string + * STRINGIFY: gives the defined value. */ +#define STRINGIFY_ARG(x) #x +#define STRINGIFY(x) STRINGIFY_ARG(x) + +/* useful for debugging */ +#define AT __FILE__ ":" STRINGIFY(__LINE__) + +/* UNUSED macro, for function argument */ +#ifdef __GNUC__ +# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) +#else +# define UNUSED(x) UNUSED_ ## x +#endif + + +/*little macro so inline keyword works*/ +#if defined(_MSC_VER) +# define BM_INLINE static __forceinline +#elif defined(__GNUC__) +# define BM_INLINE static inline __attribute((always_inline)) +#else +/* #warning "MSC/GNUC defines not found, inline non-functional" */ +# define BM_INLINE static +#endif + + +/* BKE_assert(), default only to print + * for aborting need to define WITH_ASSERT_ABORT + */ +#if !defined NDEBUG +# ifdef WITH_ASSERT_ABORT +# define _dummy_abort abort +# else +# define _dummy_abort() (void)0 +# endif +# ifdef __GNUC__ /* just want to check if __func__ is available */ +# define BKE_assert(a) \ +do { \ + if (0 == (a)) { \ + fprintf(stderr, \ + "BKE_assert failed: %s, %s(), %d at \'%s\'\n", \ + __FILE__, __func__, __LINE__, STRINGIFY(a)); \ + _dummy_abort(); \ + } \ +} while (0) +# else +# define BKE_assert(a) \ +do { \ + if (0 == (a)) { \ + fprintf(stderr, \ + "BKE_assert failed: %s, %d at \'%s\'\n", \ + __FILE__, __LINE__, STRINGIFY(a)); \ + _dummy_abort(); \ + } \ +} while (0) +# endif +#else +# define BKE_assert(a) (void)0 +#endif + +#endif // BLI_UTILDEFINES_H diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index d8be94c211a..23125a67875 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -122,6 +122,7 @@ set(SRC BLI_storage_types.h BLI_string.h BLI_threads.h + BLI_utildefines.h BLI_uvproject.h BLI_vfontdata.h BLI_voxel.h diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c index b9df4b309df..ff41f76a1f9 100644 --- a/source/blender/blenlib/intern/BLI_args.c +++ b/source/blender/blenlib/intern/BLI_args.c @@ -35,6 +35,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BLI_args.h" #include "BLI_ghash.h" diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 729f5309523..a8ca828aa66 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -30,6 +30,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLO_sys_types.h" // for intptr_t support /***/ diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 8c0be971682..4673462f58b 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -30,7 +30,9 @@ #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BLI_kdopbvh.h" #include "BLI_math.h" diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 377c322a34b..92deb6fbebc 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -55,6 +55,7 @@ #include "BLI_blenlib.h" #include "BLI_bpath.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_image.h" /* so we can check the image's type */ diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 15218fb9ece..462e3ed9d01 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -218,7 +218,7 @@ int BLI_copy_fileops(const char *file, const char *to) { return err; } -int BLI_link(const char *UNUSED(file), const char *UNUSED(to)) { +int BLI_link(const char *file, const char *to) { callLocalErrorCallBack("Linking files is unsupported on Windows"); return 1; diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index fc41839c303..f63302e3cee 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -46,12 +46,13 @@ #include "BLI_vfontdata.h" #include "BLI_blenlib.h" -#include "BLI_math.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" //XXX #include "BIF_toolbox.h" #include "BKE_font.h" -#include "BKE_utildefines.h" + #include "DNA_vfont_types.h" #include "DNA_packedFile_types.h" diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index b324cb4616a..a96b2d20976 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -31,8 +31,9 @@ #include "BLI_graph.h" #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" static void testRadialSymmetry(BGraph *graph, BNode* root_node, RadialArc* ring, int total, float axis[3], float limit, int group); diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 9d93168590f..0408d814d81 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -209,7 +209,6 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv) s = (cmax - cmin)/cmax; else { s = 0.0f; - h = 0.0f; } if (s == 0.0f) h = -1.0f; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 673d8113f32..d25aefef543 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -30,8 +30,9 @@ #include "BLI_math.h" #include "BLI_memarena.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" /********************************** Polygons *********************************/ @@ -629,7 +630,7 @@ static int getLowestRoot(float a, float b, float c, float maxR, float* root) if (determinant >= 0.0f) { // calculate the two roots: (if determinant == 0 then - // x1==x2 but let’s disregard that slight optimization) + // x1==x2 but lets disregard that slight optimization) float sqrtD = (float)sqrt(determinant); float r1 = (-b - sqrtD) / (2.0f*a); float r2 = (-b + sqrtD) / (2.0f*a); @@ -661,7 +662,7 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v { float e1[3], e2[3], e3[3], point[3], vel[3], /*dist[3],*/ nor[3], temp[3], bv[3]; float a, b, c, d, e, x, y, z, radius2=radius*radius; - float elen2,edotv,edotbv,nordotv,vel2; + float elen2,edotv,edotbv,nordotv; float newLambda; int found_by_sweep=0; @@ -735,7 +736,7 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v *lambda=1.0f; /*---test points---*/ - a=vel2=dot_v3v3(vel,vel); + a=dot_v3v3(vel,vel); /*v0*/ sub_v3_v3v3(temp,p1,v0); @@ -824,10 +825,10 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v } /*e3*/ - sub_v3_v3v3(bv,v0,p1); - elen2 = dot_v3v3(e1,e1); - edotv = dot_v3v3(e1,vel); - edotbv = dot_v3v3(e1,bv); + /* sub_v3_v3v3(bv,v0,p1); */ /* UNUSED */ + /* elen2 = dot_v3v3(e1,e1); */ /* UNUSED */ + /* edotv = dot_v3v3(e1,vel); */ /* UNUSED */ + /* edotbv = dot_v3v3(e1,bv); */ /* UNUSED */ sub_v3_v3v3(bv,v1,p1); elen2 = dot_v3v3(e3,e3); @@ -972,7 +973,6 @@ int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3] { float a[3], b[3], c[3], ab[3], cb[3], ca[3], dir1[3], dir2[3]; float d; - float d1; sub_v3_v3v3(c, v3, v1); sub_v3_v3v3(a, v2, v1); @@ -985,8 +985,6 @@ int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3] /* colinear or one vector is zero-length*/ return 0; } - - d1 = d; cross_v3_v3v3(ab, a, b); d = dot_v3v3(c, ab); @@ -1033,7 +1031,7 @@ int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3 /* find closest point to p on line through l1,l2 and return lambda, * where (0 <= lambda <= 1) when cp is in the line segement l1,l2 */ -float closest_to_line_v3(float cp[3],float p[3], float l1[3], float l2[3]) +float closest_to_line_v3(float cp[3], const float p[3], const float l1[3], const float l2[3]) { float h[3],u[3],lambda; sub_v3_v3v3(u, l2, l1); @@ -1045,6 +1043,17 @@ float closest_to_line_v3(float cp[3],float p[3], float l1[3], float l2[3]) return lambda; } +float closest_to_line_v2(float cp[2],const float p[2], const float l1[2], const float l2[2]) +{ + float h[2],u[2],lambda; + sub_v2_v2v2(u, l2, l1); + sub_v2_v2v2(h, p, l1); + lambda =dot_v2v2(u,h)/dot_v2v2(u,u); + cp[0] = l1[0] + u[0] * lambda; + cp[1] = l1[1] + u[1] * lambda; + return lambda; +} + #if 0 /* little sister we only need to know lambda */ static float lambda_cp_line(float p[3], float l1[3], float l2[3]) diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 154eb746e5c..77ef825ee34 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1224,7 +1224,7 @@ void loc_axisangle_size_to_mat4(float mat[4][4], const float loc[3], const float /*********************************** Other ***********************************/ -void print_m3(char *str, float m[][3]) +void print_m3(const char *str, float m[][3]) { printf("%s\n", str); printf("%f %f %f\n",m[0][0],m[1][0],m[2][0]); @@ -1233,7 +1233,7 @@ void print_m3(char *str, float m[][3]) printf("\n"); } -void print_m4(char *str, float m[][4]) +void print_m4(const char *str, float m[][4]) { printf("%s\n", str); printf("%f %f %f %f\n",m[0][0],m[1][0],m[2][0],m[3][0]); @@ -1457,7 +1457,6 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) eps = powf(2.0f,-52.0f); while (p > 0) { int kase=0; - k=0; // Test for maximum iterations to avoid infinite loop if(maxiter == 0) diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 2ff1e948317..539d3fb97f6 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -398,6 +398,24 @@ void add_vn_vn(float *array_tar, const float *array_src, const int size) while(i--) { *(tar--) += *(src--); } } +void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size) +{ + float *tar= array_tar + (size-1); + const float *src_a= array_src_a + (size-1); + const float *src_b= array_src_b + (size-1); + int i= size; + while(i--) { *(tar--) = *(src_a--) + *(src_b--); } +} + +void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size) +{ + float *tar= array_tar + (size-1); + const float *src_a= array_src_a + (size-1); + const float *src_b= array_src_b + (size-1); + int i= size; + while(i--) { *(tar--) = *(src_a--) - *(src_b--); } +} + void fill_vni(int *array_tar, const int size, const int val) { int *tar= array_tar + (size-1); diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 801130eebc8..96dad590fee 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -1756,7 +1756,7 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity signal = offset - fabs(noisefunc(x, y, z)); signal *= signal; result = signal; - weight = 1.f; + for( i=1; i<(int)octaves; i++ ) { x *= lacunarity; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 4cbd93ce0a1..0e46a9df4fc 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -43,6 +43,7 @@ #include "BLI_string.h" #include "BLI_storage.h" #include "BLI_storage_types.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" #include "BKE_blender.h" // BLENDER_VERSION diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 9d126a4a931..8727fab7086 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -27,6 +27,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_pbvh.h" diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 53d9f2b78e7..6da59fd4e81 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -91,6 +91,7 @@ #include "BLI_linklist.h" #include "BLI_storage_types.h" #include "BLI_string.h" + #include "BKE_utildefines.h" /* vars: */ diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 2b04a49e848..72a9c7d98ec 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -27,8 +27,9 @@ */ #include "BLI_voxel.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" BM_INLINE float D(float *data, int *res, int x, int y, int z) { diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index b3438590321..c7ec34d69a3 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -36,10 +36,13 @@ #include "MEM_guardedalloc.h" #include "BLI_path_util.h" #include "BLI_string.h" + +#include "BKE_utildefines.h" + #define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY #include "BLI_winstuff.h" -#include "BKE_utildefines.h" /* FILE_MAXDIR + FILE_MAXFILE */ + /* FILE_MAXDIR + FILE_MAXFILE */ int BLI_getInstallationDir( char * str ) { char dir[FILE_MAXDIR]; diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 87ff98eef1d..bc7f674d6ba 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -38,6 +38,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_linklist.h" @@ -49,6 +50,7 @@ #include "BKE_library.h" // for free_main #include "BKE_idcode.h" #include "BKE_report.h" +#include "BKE_utildefines.h" #include "BLO_readfile.h" #include "BLO_undofile.h" @@ -169,11 +171,11 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) memcpy(new_prv, prv, sizeof(PreviewImage)); if (prv->rect[0]) { unsigned int *rect = NULL; - int rectlen = 0; + // int rectlen = 0; new_prv->rect[0] = MEM_callocN(new_prv->w[0]*new_prv->h[0]*sizeof(unsigned int), "prvrect"); bhead= blo_nextbhead(fd, bhead); rect = (unsigned int*)(bhead+1); - rectlen = new_prv->w[0]*new_prv->h[0]*sizeof(unsigned int); + // rectlen = new_prv->w[0]*new_prv->h[0]*sizeof(unsigned int); memcpy(new_prv->rect[0], rect, bhead->len); } else { new_prv->rect[0] = NULL; @@ -181,11 +183,11 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) if (prv->rect[1]) { unsigned int *rect = NULL; - int rectlen = 0; + // int rectlen = 0; new_prv->rect[1] = MEM_callocN(new_prv->w[1]*new_prv->h[1]*sizeof(unsigned int), "prvrect"); bhead= blo_nextbhead(fd, bhead); rect = (unsigned int*)(bhead+1); - rectlen = new_prv->w[1]*new_prv->h[1]*sizeof(unsigned int); + // rectlen = new_prv->w[1]*new_prv->h[1]*sizeof(unsigned int); memcpy(new_prv->rect[1], rect, bhead->len); } else { new_prv->rect[1] = NULL; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0ad4a554247..36f359af3c3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -89,6 +89,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_action.h" @@ -382,7 +383,7 @@ static void add_main_to_main(Main *mainvar, Main *from) ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(mainvar, lbarray); + set_listbasepointers(mainvar, lbarray); a= set_listbasepointers(from, fromarray); while(a--) { BLI_movelisttolist(lbarray[a], fromarray[a]); @@ -2457,7 +2458,7 @@ static void direct_link_key(FileData *fd, Key *key) while(kb) { kb->data= newdataadr(fd, kb->data); - + if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) switch_endian_keyblock(key, kb); @@ -2936,15 +2937,6 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) pm = cache->mem_cache.first; for(; pm; pm=pm->next) { - if(pm->index_array) - pm->index_array = newdataadr(fd, pm->index_array); - - /* writedata saved array of ints */ - if(pm->index_array && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) { - for(i=0; i<pm->totpoint; i++) - SWITCH_INT(pm->index_array[i]); - } - for(i=0; i<BPHYS_TOT_DATA; i++) { pm->data[i] = newdataadr(fd, pm->data[i]); @@ -3161,7 +3153,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) for(a=1,pa++; a<psys->totpart; a++, pa++) pa->boid = (pa-1)->boid + 1; } - else { + else if(psys->particles) { for(a=0,pa=psys->particles; a<psys->totpart; a++, pa++) pa->boid = NULL; } @@ -3811,9 +3803,10 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) clmd->sim_parms->presets = 0; clmd->sim_parms->reset = 0; + + clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights); } - clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights); if(!clmd->sim_parms->effector_weights) clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL); @@ -3927,9 +3920,10 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type==eModifierType_ParticleSystem) { ParticleSystemModifierData *psmd = (ParticleSystemModifierData*) md; - psmd->dm=0; - psmd->psys=newdataadr(fd, psmd->psys); + psmd->dm= NULL; + psmd->psys= newdataadr(fd, psmd->psys); psmd->flag &= ~eParticleSystemFlag_psys_updated; + psmd->flag |= eParticleSystemFlag_file_loaded; } else if (md->type==eModifierType_Explode) { ExplodeModifierData *psmd = (ExplodeModifierData*) md; @@ -4322,9 +4316,8 @@ static void link_recurs_seq(FileData *fd, ListBase *lb) static void direct_link_paint(FileData *fd, Paint **paint) { - Paint *p; /* TODO. is this needed */ - p= (*paint)= newdataadr(fd, (*paint)); + (*paint)= newdataadr(fd, (*paint)); } static void direct_link_scene(FileData *fd, Scene *sce) @@ -11331,6 +11324,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) part->boids->pitch = 1.0f; part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */ + part->kink_amp_clump = 1.f; /* keep old files looking similar */ } for (sc= main->screen.first; sc; sc= sc->id.next) { @@ -11375,7 +11369,42 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } /* put compatibility code here until next subversion bump */ + { + /* Fix for sample line scope initializing with no height */ + bScreen *sc; + ScrArea *sa; + for(sc= main->screen.first; sc; sc= sc->id.next) { + sa= sc->areabase.first; + while(sa) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_IMAGE) { + SpaceImage *sima= (SpaceImage *)sl; + if (sima->sample_line_hist.height == 0 ) + sima->sample_line_hist.height = 100; + } + } + sa= sa->next; + } + } + } + + { + Key *key; + + /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in + * 2.4x would never reveal this to users as a dummy value always ended up getting used + * instead + */ + for (key = main->key.first; key; key = key->id.next) { + KeyBlock *kb; + + for (kb = key->block.first; kb; kb = kb->next) { + if (IS_EQ(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) + kb->slidermax = kb->slidermin + 1.0f; + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ @@ -12714,7 +12743,7 @@ static void append_do_cursor(Scene *scene, Library *curlib, short flag) static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag) { - Main *mainvar= CTX_data_main(C); + Main *mainvar; Scene *scene= CTX_data_scene(C); Library *curlib; @@ -12817,7 +12846,7 @@ static int mainvar_count_libread_blocks(Main *mainvar) a= set_listbasepointers(mainvar, lbarray); while(a--) { - ID *id= lbarray[a]->first; + ID *id; for (id= lbarray[a]->first; id; id= id->next) if (id->flag & LIB_READ) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e6db5fea6bf..cb2f2b9871d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -130,6 +130,7 @@ Any case: direct data is ALWAYS after the lib block #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_bpath.h" +#include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_blender.h" @@ -141,7 +142,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_node.h" #include "BKE_report.h" #include "BKE_sequencer.h" -#include "BKE_utildefines.h" // for defines +#include "BKE_utildefines.h" #include "BKE_modifier.h" #include "BKE_fcurve.h" #include "BKE_pointcache.h" @@ -784,8 +785,6 @@ static void write_pointcaches(WriteData *wd, ListBase *ptcaches) for(; pm; pm=pm->next) { writestruct(wd, DATA, "PTCacheMem", 1, pm); - if(pm->index_array) - writedata(wd, DATA, MEM_allocN_len(pm->index_array), pm->index_array); for(i=0; i<BPHYS_TOT_DATA; i++) { if(pm->data[i] && pm->data_types & (1<<i)) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index f7ee0dbd16d..6dbffd5232c 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -45,6 +45,11 @@ #include "COLLADASaxFWLLoader.h" +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" + #include "BKE_main.h" #include "BKE_library.h" #include "BKE_texture.h" @@ -57,10 +62,6 @@ #include "BKE_utildefines.h" #include "BKE_image.h" -#include "BLI_listbase.h" -#include "BLI_math.h" -#include "BLI_string.h" - #include "DNA_camera_types.h" #include "DNA_lamp_types.h" diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 592149157aa..cc1e8bd9eb8 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -31,6 +31,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -42,6 +43,7 @@ #include "DNA_space_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" #include "DNA_linestyle_types.h" #include "DNA_mesh_types.h" #include "DNA_material_types.h" @@ -50,9 +52,11 @@ #include "DNA_world_types.h" #include "RNA_access.h" + #include "BKE_curve.h" #include "BKE_key.h" #include "BKE_context.h" +#include "BKE_utildefines.h" /* FILE_MAX */ #include "UI_interface.h" #include "UI_interface_icons.h" @@ -2311,6 +2315,82 @@ static bAnimChannelType ACF_DSMESH= acf_dsmesh_setting_ptr /* pointer for setting */ }; +/* Lattice Expander ------------------------------------------- */ + +// TODO: just get this from RNA? +static int acf_dslat_icon(bAnimListElem *UNUSED(ale)) +{ + return ICON_LATTICE_DATA; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +{ + /* clear extra return data first */ + *neg= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + return LT_DS_EXPAND; + + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ + return ADT_NLA_EVAL_OFF; + + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ + *neg= 1; + return ADT_CURVES_NOT_VISIBLE; + + case ACHANNEL_SETTING_SELECT: /* selected */ + return ADT_UI_SELECTED; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) +{ + Lattice *lt= (Lattice *)ale->data; + + /* clear extra return data first */ + *type= 0; + + switch (setting) { + case ACHANNEL_SETTING_EXPAND: /* expanded */ + GET_ACF_FLAG_PTR(lt->flag); + + case ACHANNEL_SETTING_SELECT: /* selected */ + case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ + case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ + if (lt->adt) + GET_ACF_FLAG_PTR(lt->adt->flag) + else + return NULL; + + default: /* unsupported */ + return NULL; + } +} + +/* node tree expander type define */ +static bAnimChannelType ACF_DSLAT= +{ + "Lattice Expander", /* type name */ + + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop,/* backdrop */ + acf_generic_indention_1, /* indent level */ // XXX this only works for compositing + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_dslat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslat_setting_flag, /* flag for setting */ + acf_dslat_setting_ptr /* pointer for setting */ +}; + /* ShapeKey Entry ------------------------------------------- */ /* name for ShapeKey */ @@ -2567,6 +2647,7 @@ void ANIM_init_channel_typeinfo_data (void) animchannelTypeInfo[type++]= &ACF_DSARM; /* Armature Channel */ animchannelTypeInfo[type++]= &ACF_DSMESH; /* Mesh Channel */ animchannelTypeInfo[type++]= &ACF_DSTEX; /* Texture Channel */ + animchannelTypeInfo[type++]= &ACF_DSLAT; /* Lattice Channel */ animchannelTypeInfo[type++]= &ACF_DSLINESTYLE; /* LineStyle Channel */ animchannelTypeInfo[type++]= &ACF_SHAPEKEY; /* ShapeKey */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 9d6b6d80a78..f4e3602343f 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -32,6 +32,8 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -114,6 +116,8 @@ void ANIM_set_active_channel (bAnimContext *ac, void *data, short datatype, int case ANIMTYPE_DSMBALL: case ANIMTYPE_DSARM: case ANIMTYPE_DSMESH: + case ANIMTYPE_DSTEX: + case ANIMTYPE_DSLAT: { /* need to verify that this data is valid for now */ if (ale->adt) { @@ -157,6 +161,7 @@ void ANIM_set_active_channel (bAnimContext *ac, void *data, short datatype, int case ANIMTYPE_DSMBALL: case ANIMTYPE_DSARM: case ANIMTYPE_DSMESH: + case ANIMTYPE_DSLAT: { /* need to verify that this data is valid for now */ // XXX: ale may be null! @@ -234,6 +239,7 @@ void ANIM_deselect_anim_channels (bAnimContext *ac, void *data, short datatype, case ANIMTYPE_DSMESH: case ANIMTYPE_DSNTREE: case ANIMTYPE_DSTEX: + case ANIMTYPE_DSLAT: case ANIMTYPE_DSLINESTYLE: { if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) @@ -318,6 +324,7 @@ void ANIM_deselect_anim_channels (bAnimContext *ac, void *data, short datatype, case ANIMTYPE_DSMESH: case ANIMTYPE_DSNTREE: case ANIMTYPE_DSTEX: + case ANIMTYPE_DSLAT: case ANIMTYPE_DSLINESTYLE: { /* need to verify that this data is valid for now */ @@ -1940,6 +1947,7 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i case ANIMTYPE_DSMESH: case ANIMTYPE_DSNTREE: case ANIMTYPE_DSTEX: + case ANIMTYPE_DSLAT: case ANIMTYPE_DSLINESTYLE: { /* sanity checking... */ diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 02d69fd61fa..340101612b9 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -38,6 +38,7 @@ #include "DNA_sequence_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_action.h" diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 641183db4c4..91af5534eaa 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -70,6 +70,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BKE_animsys.h" @@ -82,6 +83,7 @@ #include "BKE_material.h" #include "BKE_node.h" #include "BKE_sequencer.h" +#include "BKE_utildefines.h" #include "ED_anim_api.h" @@ -106,23 +108,7 @@ static Key *actedit_get_shapekeys (bAnimContext *ac) //if (saction->pin) return NULL; /* shapekey data is stored with geometry data */ - switch (ob->type) { - case OB_MESH: - key= ((Mesh *)ob->data)->key; - break; - - case OB_LATTICE: - key= ((Lattice *)ob->data)->key; - break; - - case OB_CURVE: - case OB_SURF: - key= ((Curve *)ob->data)->key; - break; - - default: - return NULL; - } + key= ob_get_key(ob); if (key) { if (key->type == KEY_RELATIVE) @@ -643,6 +629,19 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s ale->adt= BKE_animdata_from_id(data); } break; + case ANIMTYPE_DSLAT: + { + Lattice *lt= (Lattice *)data; + AnimData *adt= lt->adt; + + ale->flag= FILTER_LATTICE_OBJD(lt); + + ale->key_data= (adt) ? adt->action : NULL; + ale->datatype= ALE_ACT; + + ale->adt= BKE_animdata_from_id(data); + } + break; case ANIMTYPE_DSSKEY: { Key *key= (Key *)data; @@ -1613,6 +1612,14 @@ static int animdata_filter_dopesheet_obdata (bAnimContext *ac, ListBase *anim_da expanded= FILTER_MESH_OBJD(me); } break; + case OB_LATTICE: /* ---- Lattice ---- */ + { + Lattice *lt = (Lattice *)ob->data; + + type= ANIMTYPE_DSLAT; + expanded= FILTER_LATTICE_OBJD(lt); + } + break; } /* special exception for drivers instead of action */ @@ -1871,6 +1878,19 @@ static int animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, } } break; + case OB_LATTICE: /* ------- Lattice ---------- */ + { + Lattice *lt= (Lattice *)ob->data; + + if ((ads->filterflag & ADS_FILTER_NOLAT) == 0) { + ANIMDATA_FILTER_CASES(lt, + { /* AnimData blocks - do nothing... */ }, + obdata_ok= 1;, + obdata_ok= 1;, + obdata_ok= 1;) + } + } + break; } if (obdata_ok) items += animdata_filter_dopesheet_obdata(ac, anim_data, ads, base, filter_mode); @@ -2500,6 +2520,23 @@ static int animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDo dataOk= !(ads->filterflag & ADS_FILTER_NOMESH);) } break; + case OB_LATTICE: /* ------- Lattice ---------- */ + { + Lattice *lt= (Lattice *)ob->data; + dataOk= 0; + ANIMDATA_FILTER_CASES(lt, + if ((ads->filterflag & ADS_FILTER_NOLAT)==0) { + /* for the special AnimData blocks only case, we only need to add + * the block if it is valid... then other cases just get skipped (hence ok=0) + */ + ANIMDATA_ADD_ANIMDATA(lt); + dataOk=0; + }, + dataOk= !(ads->filterflag & ADS_FILTER_NOLAT);, + dataOk= !(ads->filterflag & ADS_FILTER_NOLAT);, + dataOk= !(ads->filterflag & ADS_FILTER_NOLAT);) + } + break; default: /* --- other --- */ dataOk= 0; break; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 56161f4bfa0..3e2212c15bb 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -37,10 +37,11 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2f5ad28c8f2..80b026ddd6e 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -38,6 +38,7 @@ #include "RNA_enum_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_fcurve.h" @@ -82,6 +83,8 @@ static ListBase *context_get_markers(const bContext *C) return &CTX_data_scene(C)->markers; } +/* --------------------------------- */ + /* Get the marker that is closest to this point */ /* XXX for select, the min_dist should be small */ TimeMarker *ED_markers_find_nearest_marker (ListBase *markers, float x) @@ -175,6 +178,8 @@ void ED_markers_get_minmax (ListBase *markers, short sel, float *first, float *l *last= max; } +/* --------------------------------- */ + /* Adds a marker to list of cfra elems */ void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel) { @@ -218,6 +223,23 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) add_marker_to_cfra_elem(lb, marker, only_sel); } +/* --------------------------------- */ + +/* Get the first selected marker */ +TimeMarker *ED_markers_get_first_selected(ListBase *markers) +{ + TimeMarker *marker; + + if (markers) { + for (marker = markers->first; marker; marker = marker->next) { + if (marker->flag & SELECT) + return marker; + } + } + + return NULL; +} + /* ************* Marker Drawing ************ */ /* function to draw markers */ @@ -239,10 +261,11 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* vertical line - dotted */ #ifdef DURIAN_CAMERA_SWITCH - if ((marker->camera) || (flag & DRAW_MARKERS_LINES)) { + if ((marker->camera) || (flag & DRAW_MARKERS_LINES)) #else - if (flag & DRAW_MARKERS_LINES) { + if (flag & DRAW_MARKERS_LINES) #endif + { setlinestyle(3); if (marker->flag & SELECT) @@ -333,6 +356,84 @@ void draw_markers_time(const bContext *C, int flag) } } +/* ************************ Marker Wrappers API ********************* */ +/* These wrappers allow marker operators to function within the confines + * of standard animation editors, such that they can coexist with the + * primary operations of those editors. + */ + +/* maximum y-axis value (in region screen-space) that marker events should still be accepted for */ +#define ANIMEDIT_MARKER_YAXIS_MAX 30 + +/* ------------------------ */ + +/* special poll() which checks if there are selected markers first */ +static int ed_markers_poll_selected_markers(bContext *C) +{ + ListBase *markers = context_get_markers(C); + + /* first things first: markers can only exist in timeline views */ + if (ED_operator_animview_active(C) == 0) + return 0; + + /* check if some marker is selected */ + return ED_markers_get_first_selected(markers) != NULL; +} + +/* ------------------------ */ + +/* Second-tier invoke() callback that performs context validation before running the + * "custom"/third-tier invoke() callback supplied as the last arg (which would normally + * be the operator's invoke() callback elsewhere) + * + * < invoke_func: (fn(bContext*, wmOperator*, wmEvent*)=int) "standard" invoke function + * that operator would otherwise have used. If NULL, the operator's standard + * exec() callback will be called instead in the appropriate places. + */ +static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, wmEvent *evt, + int (*invoke_func)(bContext*,wmOperator*,wmEvent*)) +{ + ScrArea *sa = CTX_wm_area(C); + int retval = OPERATOR_PASS_THROUGH; + + /* only timeline view doesn't need calling-location validation as it's the only dedicated view */ + if (sa->spacetype != SPACE_TIME) { + /* restrict y-values to within ANIMEDIT_MARKER_YAXIS_MAX of the view's vertical extents, including scrollbars */ + if (evt->mval[1] > ANIMEDIT_MARKER_YAXIS_MAX) { + /* not ok... "pass-through" to let normal editor's operators have a chance at tackling this event... */ + //printf("MARKER-WRAPPER-DEBUG: event mval[1] = %d, so over accepted tolerance\n", evt->mval[1]); + return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + } + } + + /* allow operator to run now */ + if (invoke_func) + retval = invoke_func(C, op, evt); + else if (op->type->exec) + retval = op->type->exec(C, op); + else + BKE_report(op->reports, RPT_ERROR, "Programming error: operator doesn't actually have code to do anything!"); + + /* return status modifications - for now, make this spacetype dependent as above */ + if (sa->spacetype != SPACE_TIME) { + /* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */ + if (retval != OPERATOR_FINISHED) + retval |= OPERATOR_PASS_THROUGH; + } + + return retval; +} + +/* standard wrapper - first-tier invoke() callback to be directly assigned to operator typedata + * for operators which don't need any special invoke calls. Any operators with special invoke calls + * though will need to implement their own wrapper which calls the second-tier callback themselves + * (passing through the custom invoke function they use) + */ +static int ed_markers_opwrap_invoke(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, NULL); +} + /* ************************** add markers *************************** */ /* add TimeMarker at curent frame */ @@ -376,6 +477,7 @@ static void MARKER_OT_add(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_add; + ot->invoke = ed_markers_opwrap_invoke; ot->poll= ED_operator_animview_active; /* flags */ @@ -396,7 +498,7 @@ functions: exit() cleanup, send notifier - cancel() to escpae from modal + cancel() to escape from modal callbacks: @@ -488,6 +590,11 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt) return OPERATOR_CANCELLED; } +static int ed_marker_move_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, ed_marker_move_invoke); +} + /* note, init has to be called succesfully */ static void ed_marker_move_apply(wmOperator *op) { @@ -665,9 +772,9 @@ static void MARKER_OT_move(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_move_exec; - ot->invoke= ed_marker_move_invoke; + ot->invoke= ed_marker_move_invoke_wrapper; ot->modal= ed_marker_move_modal; - ot->poll= ED_operator_animview_active; + ot->poll= ed_markers_poll_selected_markers; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; @@ -744,6 +851,11 @@ static int ed_marker_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *evt) return ed_marker_move_invoke(C, op, evt); } +static int ed_marker_duplicate_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, ed_marker_duplicate_invoke); +} + static void MARKER_OT_duplicate(wmOperatorType *ot) { /* identifiers */ @@ -753,9 +865,9 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_duplicate_exec; - ot->invoke= ed_marker_duplicate_invoke; + ot->invoke= ed_marker_duplicate_invoke_wrapper; ot->modal= ed_marker_move_modal; - ot->poll= ED_operator_animview_active; + ot->poll= ed_markers_poll_selected_markers; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -794,7 +906,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) float viewx; int x, y, cfra; - if(markers == NULL) + if (markers == NULL) return OPERATOR_PASS_THROUGH; x= evt->x - CTX_wm_region(C)->winrct.xmin; @@ -811,27 +923,27 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) #ifdef DURIAN_CAMERA_SWITCH - if(camera) { + if (camera) { Scene *scene= CTX_data_scene(C); Base *base; TimeMarker *marker; int sel= 0; - + if (!extend) scene_deselect_all(scene); - + for (marker= markers->first; marker; marker= marker->next) { if(marker->frame==cfra) { sel= (marker->flag & SELECT); break; } } - + for (marker= markers->first; marker; marker= marker->next) { - if(marker->camera) { - if(marker->frame==cfra) { + if (marker->camera) { + if (marker->frame==cfra) { base= object_in_scene(marker->camera, scene); - if(base) { + if (base) { ED_base_object_select(base, sel); if(sel) ED_base_object_activate(C, base); @@ -839,7 +951,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) } } } - + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } #endif @@ -861,6 +973,11 @@ static int ed_marker_select_invoke(bContext *C, wmOperator *op, wmEvent *evt) return ed_marker_select(C, evt, extend, camera); } +static int ed_marker_select_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, ed_marker_select_invoke); +} + static void MARKER_OT_select(wmOperatorType *ot) { /* identifiers */ @@ -869,7 +986,7 @@ static void MARKER_OT_select(wmOperatorType *ot) ot->idname= "MARKER_OT_select"; /* api callbacks */ - ot->invoke= ed_marker_select_invoke; + ot->invoke= ed_marker_select_invoke_wrapper; ot->poll= ED_operator_animview_active; /* flags */ @@ -917,24 +1034,18 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(v2d, xmin, ymin, &xminf, &yminf); UI_view2d_region_to_view(v2d, xmax, ymax, &xmaxf, &ymaxf); - /* XXX disputable */ - if(yminf > 30.0f || ymaxf < 0.0f) - return 0; - - if(markers == NULL) + if (markers == NULL) return 0; /* XXX marker context */ - for(marker= markers->first; marker; marker= marker->next) { + for (marker= markers->first; marker; marker= marker->next) { if ((marker->frame > xminf) && (marker->frame <= xmaxf)) { switch (gesture_mode) { case GESTURE_MODAL_SELECT: - if ((marker->flag & SELECT) == 0) - marker->flag |= SELECT; + marker->flag |= SELECT; break; case GESTURE_MODAL_DESELECT: - if (marker->flag & SELECT) - marker->flag &= ~SELECT; + marker->flag &= ~SELECT; break; } } @@ -946,6 +1057,11 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) return 1; } +static int ed_marker_select_border_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, WM_border_select_invoke); +} + static void MARKER_OT_select_border(wmOperatorType *ot) { /* identifiers */ @@ -955,7 +1071,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_border_select_exec; - ot->invoke= WM_border_select_invoke; + ot->invoke= ed_marker_select_border_invoke_wrapper; ot->modal= WM_border_select_modal; ot->poll= ED_operator_animview_active; @@ -975,17 +1091,11 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) TimeMarker *marker; int action = RNA_enum_get(op->ptr, "action"); - if(markers == NULL) + if (markers == NULL) return OPERATOR_CANCELLED; if (action == SEL_TOGGLE) { - action = SEL_SELECT; - for(marker= markers->first; marker; marker= marker->next) { - if(marker->flag & SELECT) { - action = SEL_DESELECT; - break; - } - } + action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT; } for(marker= markers->first; marker; marker= marker->next) { @@ -997,11 +1107,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) marker->flag &= ~SELECT; break; case SEL_INVERT: - if (marker->flag & SELECT) { - marker->flag &= ~SELECT; - } else { - marker->flag |= SELECT; - } + marker->flag ^= SELECT; break; } } @@ -1021,6 +1127,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_select_all_exec; + ot->invoke = ed_markers_opwrap_invoke; ot->poll= ED_operator_animview_active; /* flags */ @@ -1030,7 +1137,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } -/* ******************************* remove marker ***************** */ +/* ***************** remove marker *********************** */ /* remove selected TimeMarkers */ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1039,12 +1146,12 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) TimeMarker *marker, *nmarker; short changed= 0; - if(markers == NULL) + if (markers == NULL) return OPERATOR_CANCELLED; - for(marker= markers->first; marker; marker= nmarker) { + for (marker= markers->first; marker; marker= nmarker) { nmarker= marker->next; - if(marker->flag & SELECT) { + if (marker->flag & SELECT) { BLI_freelinkN(markers, marker); changed= 1; } @@ -1058,6 +1165,11 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +static int ed_marker_delete_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + // XXX: must we keep these confirmations? + return ed_markers_opwrap_invoke_custom(C, op, evt, WM_operator_confirm); +} static void MARKER_OT_delete(wmOperatorType *ot) { @@ -1067,35 +1179,90 @@ static void MARKER_OT_delete(wmOperatorType *ot) ot->idname= "MARKER_OT_delete"; /* api callbacks */ - ot->invoke= WM_operator_confirm; + ot->invoke= ed_marker_delete_invoke_wrapper; ot->exec= ed_marker_delete_exec; - ot->poll= ED_operator_animview_active; + ot->poll= ed_markers_poll_selected_markers; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + + +/* **************** rename marker ***************** */ + +/* rename first selected TimeMarker */ +static int ed_marker_rename_exec(bContext *C, wmOperator *op) +{ + TimeMarker *marker= ED_markers_get_first_selected(context_get_markers(C)); + + if(marker) { + RNA_string_get(op->ptr, "name", marker->name); + + WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + /* must initialise the marker name first if there is a marker selected */ + TimeMarker *marker = ED_markers_get_first_selected(context_get_markers(C)); + if (marker) + RNA_string_set(op->ptr, "name", marker->name); + /* now see if the operator is usable */ + return ed_markers_opwrap_invoke_custom(C, op, evt, WM_operator_props_popup); } +static void MARKER_OT_rename(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Rename Marker"; + ot->description= "Rename first selected time marker"; + ot->idname= "MARKER_OT_rename"; + + /* api callbacks */ + ot->invoke= ed_marker_rename_invoke_wrapper; + ot->exec= ed_marker_rename_exec; + ot->poll= ed_markers_poll_selected_markers; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", sizeof(((TimeMarker *)NULL)->name), "Name", "New name for marker"); + //RNA_def_boolean(ot->srna, "ensure_unique", 0, "Ensure Unique", "Ensure that new name is unique within collection of markers"); +} + +/* **************** make links to scene ***************** */ + static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) { ListBase *markers= context_get_markers(C); Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); TimeMarker *marker, *marker_new; - if(scene_to==NULL) { + if (scene_to==NULL) { BKE_report(op->reports, RPT_ERROR, "Scene not found"); return OPERATOR_CANCELLED; } - if(scene_to == CTX_data_scene(C)) { - BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene"); + if (scene_to == CTX_data_scene(C)) { + BKE_report(op->reports, RPT_ERROR, "Can't re-link markers into the same scene"); return OPERATOR_CANCELLED; } /* copy markers */ for (marker= markers->first; marker; marker= marker->next) { - if(marker->flag & SELECT) { + if (marker->flag & SELECT) { marker_new= MEM_dupallocN(marker); + marker_new->prev= marker_new->next = NULL; + BLI_addtail(&scene_to->markers, marker_new); } } @@ -1109,12 +1276,13 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) /* identifiers */ ot->name= "Make Links to Scene"; - ot->description= "Link markers to another scene"; + ot->description= "Copy selected markers to another scene"; ot->idname= "MARKER_OT_make_links_scene"; /* api callbacks */ ot->exec= ed_marker_make_links_scene_exec; - ot->poll= ED_operator_animview_active; + ot->invoke = ed_markers_opwrap_invoke; + ot->poll= ed_markers_poll_selected_markers; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1163,7 +1331,8 @@ static void MARKER_OT_camera_bind(wmOperatorType *ot) /* api callbacks */ ot->exec= ed_marker_camera_bind_exec; - ot->poll= ED_operator_animview_active; + ot->invoke = ed_markers_opwrap_invoke; + ot->poll= ed_markers_poll_selected_markers; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1182,6 +1351,7 @@ void ED_operatortypes_marker(void) WM_operatortype_append(MARKER_OT_select_border); WM_operatortype_append(MARKER_OT_select_all); WM_operatortype_append(MARKER_OT_delete); + WM_operatortype_append(MARKER_OT_rename); WM_operatortype_append(MARKER_OT_make_links_scene); #ifdef DURIAN_CAMERA_SWITCH WM_operatortype_append(MARKER_OT_camera_bind); @@ -1213,6 +1383,7 @@ void ED_marker_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_delete", DELKEY, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "MARKER_OT_rename", MKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0); #ifdef DURIAN_CAMERA_SWITCH diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index ba5a53e6d7a..6b0fa30b096 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -31,6 +31,8 @@ #include "BLO_sys_types.h" +#include "BLI_utildefines.h" + #include "DNA_anim_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 902fa2f789f..c6c333755b0 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -32,6 +32,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 7642f63b531..b47fea58633 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -43,6 +43,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 548d06993e7..93808233288 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -39,6 +39,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -47,6 +48,7 @@ #include "DNA_scene_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" #include "DNA_linestyle_types.h" #include "DNA_mesh_types.h" #include "DNA_material_types.h" @@ -59,7 +61,7 @@ #include "BKE_key.h" #include "BKE_material.h" #include "BKE_global.h" // XXX remove me! -#include "BKE_utildefines.h" + #include "BIF_gl.h" @@ -775,6 +777,8 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl /* add material's data */ action_to_keylist(ma->adt, ma->adt->action, keys, blocks); + + // TODO: textures... } } @@ -830,6 +834,14 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl action_to_keylist(me->adt, me->adt->action, keys, blocks); } break; + case OB_LATTICE: /* ------- Lattice ---------- */ + { + Lattice *lt= (Lattice *)ob->data; + + if ((lt->adt) && !(filterflag & ADS_FILTER_NOLAT)) + action_to_keylist(lt->adt, lt->adt->action, keys, blocks); + } + break; } /* Add Particle System Keyframes */ diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index a1c02f922f2..ca056b61efa 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -33,12 +33,14 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" #include "DNA_linestyle_types.h" #include "DNA_mesh_types.h" #include "DNA_material_types.h" @@ -52,7 +54,7 @@ #include "BKE_fcurve.h" #include "BKE_key.h" #include "BKE_material.h" -#include "BKE_utildefines.h" + #include "ED_anim_api.h" #include "ED_keyframes_edit.h" @@ -319,6 +321,16 @@ static short ob_keyframes_loop(KeyframeEditData *ked, Object *ob, KeyframeEditFu } } break; + case OB_LATTICE: /* ---- Lattice ------ */ + { + Lattice *lt= (Lattice *)ob->data; + + if ((lt->adt) && !(filterflag & ADS_FILTER_NOLAT)) { + if (adt_keyframes_loop(ked, lt->adt, key_ok, key_cb, fcu_cb, filterflag)) + return 1; + } + } + break; } /* Add Particle System Keyframes */ diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index e8509a1bbc2..92fce2a77e5 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -34,6 +34,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index e588a3610d8..726c898e843 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -72,6 +73,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "anim_intern.h" @@ -1074,7 +1076,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= NULL; - int type= RNA_int_get(op->ptr, "type"); + int type= RNA_enum_get(op->ptr, "type"); float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; @@ -1139,11 +1141,12 @@ void ANIM_OT_keyframe_insert (wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - /* keyingset to use - * - here the type is int not enum, since many of the indicies here are determined dynamically - */ - prop= RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1); + /* keyingset to use (dynamic enum) */ + prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); + ot->prop= prop; + /* confirm whether a keyframe was added by showing a popup * - by default, this is enabled, since this operator is assumed to be called independently */ @@ -1168,7 +1171,7 @@ static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED( } else { /* just call the exec() on the active keyingset */ - RNA_int_set(op->ptr, "type", 0); + RNA_enum_set(op->ptr, "type", 0); RNA_boolean_set(op->ptr, "confirm_success", 1); return op->type->exec(C, op); @@ -1192,17 +1195,19 @@ void ANIM_OT_keyframe_insert_menu (wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - /* keyingset to use - * - here the type is int not enum, since many of the indicies here are determined dynamically - */ - prop= RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1); + /* keyingset to use (dynamic enum) */ + prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); + ot->prop= prop; + /* confirm whether a keyframe was added by showing a popup * - by default, this is disabled so that if a menu is shown, this doesn't come up too */ // XXX should this just be always on? prop= RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", "Show a popup when the keyframes get successfully added"); RNA_def_property_flag(prop, PROP_HIDDEN); + /* whether the menu should always be shown * - by default, the menu should only be shown when there is no active Keying Set (2.5 behaviour), * although in some cases it might be useful to always shown (pre 2.5 behaviour) @@ -1218,7 +1223,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= NULL; - int type= RNA_int_get(op->ptr, "type"); + int type= RNA_enum_get(op->ptr, "type"); float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; @@ -1269,6 +1274,8 @@ static int delete_key_exec (bContext *C, wmOperator *op) void ANIM_OT_keyframe_delete (wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Delete Keyframe"; ot->idname= "ANIM_OT_keyframe_delete"; @@ -1281,10 +1288,12 @@ void ANIM_OT_keyframe_delete (wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - /* keyingset to use - * - here the type is int not enum, since many of the indicies here are determined dynamically - */ - RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1); + /* keyingset to use (dynamic enum) */ + prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); + RNA_def_property_flag(prop, PROP_HIDDEN); + ot->prop= prop; + /* confirm whether a keyframe was added by showing a popup * - by default, this is enabled, since this operator is assumed to be called independently */ @@ -1407,7 +1416,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) } else if (G.f & G_DEBUG) { printf("ptr.data = %p, prop = %p,", (void *)ptr.data, (void *)prop); - if(prop) + if (prop) printf("animateable = %d \n", RNA_property_animateable(&ptr, prop)); else printf("animateable = NULL \n"); @@ -1416,7 +1425,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ uiContextAnimUpdate(C); - + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ @@ -1488,7 +1497,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ uiContextAnimUpdate(C); - + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index d0e7d8be769..51b00cc0086 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_scene_types.h" @@ -59,6 +60,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "anim_intern.h" @@ -417,12 +419,9 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) /* try to find a path matching this description */ ksp= BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); - + if (ksp) { - /* just free it... */ - MEM_freeN(ksp->rna_path); - BLI_freelinkN(&ks->paths, ksp); - + BKE_keyingset_free_path(ks, ksp); success= 1; } @@ -691,6 +690,67 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK /* Menu of All Keying Sets ----------------------------- */ +/* Dynamically populate an enum of Keying Sets */ +EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), int *free) +{ + Scene *scene = CTX_data_scene(C); + KeyingSet *ks; + EnumPropertyItem *item= NULL, item_tmp= {0}; + int totitem= 0; + int i= 0; + + if (C == NULL) { + return DummyRNA_DEFAULT_items; + } + + /* active Keying Set + * - only include entry if it exists + */ + if (scene->active_keyingset) { + /* active Keying Set */ + item_tmp.identifier= item_tmp.name= "Active Keying Set"; + item_tmp.value= i++; + RNA_enum_item_add(&item, &totitem, &item_tmp); + + /* separator */ + RNA_enum_item_add_separator(&item, &totitem); + } + else + i++; + + /* user-defined Keying Sets + * - these are listed in the order in which they were defined for the active scene + */ + if (scene->keyingsets.first) { + for (ks= scene->keyingsets.first; ks; ks= ks->next) { + if (ANIM_keyingset_context_ok_poll(C, ks)) { + item_tmp.identifier= item_tmp.name= ks->name; + item_tmp.value= i++; + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + } + + /* separator */ + RNA_enum_item_add_separator(&item, &totitem); + } + + /* builtin Keying Sets */ + i= -1; + for (ks= builtin_keyingsets.first; ks; ks= ks->next) { + /* only show KeyingSet if context is suitable */ + if (ANIM_keyingset_context_ok_poll(C, ks)) { + item_tmp.identifier= item_tmp.name= ks->name; + item_tmp.value= i--; + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + } + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} + /* 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, const char title[], const char op_name[]) { diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6d677e2f89e..935331e3263 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -44,6 +44,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_ghash.h" diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 6abdd85bf71..527f5ba5e69 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -39,8 +39,9 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_graph.h" +#include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "ED_armature.h" #include "armature_intern.h" diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 3e8c5c3ebb2..e9d0645ceba 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_graph.h" #include "BLI_rand.h" diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 121a7d6987b..7a5c14b1dab 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_graph.h" #include "BLI_ghash.h" diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 3d8e87d9e79..c0600ceed1c 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -41,10 +41,11 @@ #include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_memarena.h" +#include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" + #ifdef RIGID_DEFORM #include "BLI_editVert.h" @@ -648,8 +649,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, MFace *mface; float solution, weight; int *vertsflipped = NULL, *mask= NULL; - int a, totface, j, bbone, firstsegment, lastsegment, thrownerror = 0; - + int a, totface, j, bbone, firstsegment, lastsegment; + *err_str= NULL; /* count triangles and create mask */ @@ -761,9 +762,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } } } - else if(!thrownerror) { + else if(*err_str == NULL) { *err_str= "Bone Heat Weighting: failed to find solution for one or more bones"; - thrownerror= 1; break; } @@ -1264,11 +1264,9 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) { MDefBoundIsect *isect; float outside[3], start[3], dir[3]; - int i, counter; + int i; for(i=1; i<=6; i++) { - counter = 0; - outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f)*MESHDEFORM_OFFSET[i][0]; outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1]; outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2]; diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index c51621080c5..47e5f734f86 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 6756691c506..7b1b3b6c5c8 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 71b6be42900..d5994e24cd6 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index bea7155291b..2ce6da9b04c 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -36,6 +36,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -791,7 +792,7 @@ void pose_copy_menu(Scene *scene) } else { /* constraints, optional (note: max we can have is 24 constraints) */ bConstraint *con, *con_back; - int const_toggle[24]; + int const_toggle[24]= {0}; /* XXX, initialize as 0 to quiet errors */ ListBase const_copy = {NULL, NULL}; BLI_duplicatelist(&const_copy, &(pchanact->constraints)); diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index e896cccd1b3..780dc8827c4 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_ghash.h" diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 47b9dd3733b..73db7b1a377 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -48,6 +48,7 @@ #include "BLI_math.h" #include "BLI_dynstr.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BKE_context.h" @@ -1972,7 +1973,7 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) if(ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -2020,7 +2021,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -2073,7 +2074,7 @@ static int set_radius_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -2149,7 +2150,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -2315,7 +2316,7 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -2644,7 +2645,7 @@ static int hide_exec(bContext *C, wmOperator *op) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -2704,7 +2705,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -3203,7 +3204,7 @@ static int subdivide_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -3508,7 +3509,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) if(ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -3554,7 +3555,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) sethandlesNurb(editnurb, RNA_enum_get(op->ptr, "type")); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -3916,7 +3917,7 @@ static int merge_nurb(bContext *C, wmOperator *op) set_actNurb(obedit, NULL); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -3928,7 +3929,6 @@ static int make_segment_exec(bContext *C, wmOperator *op) Curve *cu= obedit->data; ListBase *nubase= curve_get_editcurve(obedit); Nurb *nu, *nu1=0, *nu2=0; - BezTriple *bezt = NULL; BPoint *bp; float *fp, offset; int a, ok= 0; @@ -3960,12 +3960,10 @@ static int make_segment_exec(bContext *C, wmOperator *op) for(nu= nubase->first; nu; nu= nu->next) { if((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */ if(nu->type == CU_BEZIER) { - bezt= nu->bezt; if(nu1==0) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) nu1= nu; + if( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu; else { - bezt= bezt+(nu->pntsu-1); - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { nu1= nu; switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); @@ -3973,14 +3971,13 @@ static int make_segment_exec(bContext *C, wmOperator *op) } } else if(nu2==0) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { nu2= nu; switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); } else { - bezt= bezt+(nu->pntsu-1); - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { nu2= nu; } } @@ -4021,7 +4018,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) if((nu1 && nu2) && (nu1!=nu2)) { if( nu1->type==nu2->type) { if(nu1->type == CU_BEZIER) { - bezt = + BezTriple *bezt = (BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN"); ED_curve_beztcpy(cu->editnurb, bezt, nu2->bezt, nu2->pntsu); ED_curve_beztcpy(cu->editnurb, bezt+nu2->pntsu, nu1->bezt, nu1->pntsu); @@ -4077,7 +4074,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) } 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))) { + BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt+(nu1->pntsu-1))) { nu1->flagu|= CU_NURB_CYCLIC; calchandlesNurb(nu1); ok= 1; @@ -4094,7 +4091,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -4285,7 +4282,8 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen static int spin_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - float cent[3], axis[3]; + RegionView3D *rv3d= ED_view3d_context_rv3d(C); + float cent[3], axis[3], viewmat[4][4]; RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); @@ -4293,7 +4291,12 @@ static int spin_exec(bContext *C, wmOperator *op) invert_m4_m4(obedit->imat, obedit->obmat); mul_m4_v3(obedit->imat, cent); - if(!spin_nurb(ED_view3d_context_rv3d(C)->viewmat, obedit, axis, cent)) { + if(rv3d) + copy_m4_m4(viewmat, rv3d->viewmat); + else + unit_m4(viewmat); + + if(!spin_nurb(viewmat, obedit, axis, cent)) { BKE_report(op->reports, RPT_ERROR, "Can't spin"); return OPERATOR_CANCELLED; } @@ -4302,7 +4305,7 @@ static int spin_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -4312,9 +4315,13 @@ static int spin_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d= ED_view3d_context_rv3d(C); + float axis[3]= {0.0f, 0.0f, 1.0f}; + + if(rv3d) + copy_v3_v3(axis, rv3d->viewinv[2]); RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d)); - RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]); + RNA_float_set_array(op->ptr, "axis", axis); return spin_exec(C, op); } @@ -4570,7 +4577,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -4647,7 +4654,7 @@ static int extrude_exec(bContext *C, wmOperator *UNUSED(op)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } } @@ -4759,7 +4766,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -5581,7 +5588,7 @@ static int delete_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -5704,11 +5711,10 @@ static int delete_exec(bContext *C, wmOperator *op) } else if(type==1) { /* erase segment */ /* find the 2 selected points */ - bezt1= bezt2= 0; - bp1= bp2= 0; - nu= nubase->first; - nu1= 0; - while(nu) { + bezt1= bezt2= NULL; + bp1= bp2= NULL; + nu1= NULL; + for(nu= nubase->first; nu; nu= nu->next) { next= nu->next; if(nu->type == CU_BEZIER) { bezt= nu->bezt; @@ -5724,7 +5730,7 @@ static int delete_exec(bContext *C, wmOperator *op) nu->flagu &= ~CU_NURB_CYCLIC; calchandlesNurb(nu); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } } @@ -5750,7 +5756,7 @@ static int delete_exec(bContext *C, wmOperator *op) if( bp2->f1 & SELECT ) { nu->flagu &= ~CU_NURB_CYCLIC; WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } } @@ -5764,8 +5770,6 @@ static int delete_exec(bContext *C, wmOperator *op) } } if(nu1) break; - - nu= nu->next; } if(nu1) { if(bezt1) { @@ -5855,7 +5859,7 @@ static int delete_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -5927,7 +5931,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } @@ -6090,13 +6094,17 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) BezTriple *bezt; BPoint *bp; Curve *cu= (Curve*)obedit->data; - float vec[3]; + float vec[3], zvec[3]= {0.0f, 0.0f, 1.0f}; + float umat[4][4]= MAT4_UNITY, viewmat[4][4]= MAT4_UNITY; float fac, grid; int a, b, cutype, stype; int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ - float umat[4][4]= MAT4_UNITY; - + if(rv3d) { + copy_m4_m4(viewmat, rv3d->viewmat); + VECCOPY(zvec, rv3d->viewinv[2]); + } + cutype= type & CU_TYPE; // poly, bezier, nurbs, etc stype= type & CU_PRIMITIVE; @@ -6380,7 +6388,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) BLI_addtail(editnurb, nu); /* temporal for spin */ 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 if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); else spin_nurb(umat, obedit, tmp_vec, mat[3]); nurbs_knot_calc_v(nu); @@ -6409,7 +6417,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) /* same as above */ 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 if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); else spin_nurb(umat, obedit, tmp_vec, mat[3]); @@ -6800,7 +6808,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index ab80a7a6ead..70a41ae7432 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_object_types.h" @@ -265,7 +266,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re BKE_text_to_curve(scene, obedit, mode); if(recalc) - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); } @@ -299,7 +300,7 @@ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op)) insert_into_textbuf(obedit, '\n'); insert_into_textbuf(obedit, '\n'); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -626,7 +627,7 @@ static int set_style(bContext *C, int style, int clear) ef->textbufinfo[i].flag |= style; } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 29cdfffa551..901542ea2de 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -38,6 +38,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_gpencil_types.h" #include "DNA_scene_types.h" @@ -48,7 +49,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_gpencil.h" -#include "BKE_utildefines.h" + #include "WM_api.h" diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index d76e5fcf17c..0ee8b914205 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -668,15 +668,10 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) } else { /* try to find a marker */ - for (marker= scene->markers.first; marker; marker=marker->next) { - if (marker->flag & SELECT) { - initialised = 1; - break; - } + marker= ED_markers_get_first_selected(&scene->markers); + if(marker) { + initialised= 1; } - - if (initialised == 0) - marker = NULL; } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index e0d257ca3bf..e7660659dfa 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -37,6 +37,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index d42e63bf354..d5cdb552439 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_gpencil.h" #include "BKE_context.h" @@ -141,17 +142,21 @@ static void gp_session_validatebuffer(tGPsdata *p); /* check if context is suitable for drawing */ static int gpencil_draw_poll (bContext *C) { - if(ED_operator_regionactive(C)) { + if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ - if(gpencil_data_get_pointers(C, NULL) != NULL) { - return 1; + if (gpencil_data_get_pointers(C, NULL) != NULL) { + /* check if Grease Pencil isn't already running */ + if ((G.f & G_GREASEPENCIL) == 0) + return 1; + else + CTX_wm_operator_poll_msg_set(C, "Grease Pencil operator is already active"); } else { - CTX_wm_operator_poll_msg_set(C, "failed to find grease pencil data to draw into"); + CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into"); } } else { - CTX_wm_operator_poll_msg_set(C, "active region not set"); + CTX_wm_operator_poll_msg_set(C, "Active region not set"); } return 0; @@ -161,7 +166,7 @@ static int gpencil_draw_poll (bContext *C) static int gpencil_project_check (tGPsdata *p) { bGPdata *gpd= p->gpd; - return ((gpd->sbuffer_sflag & GP_STROKE_3DSPACE) && (p->gpd->flag & (GP_DATA_DEPTH_VIEW | GP_DATA_DEPTH_STROKE))) ? 1:0; + return ((gpd->sbuffer_sflag & GP_STROKE_3DSPACE) && (p->gpd->flag & (GP_DATA_DEPTH_VIEW | GP_DATA_DEPTH_STROKE))); } /* ******************************************* */ @@ -176,7 +181,7 @@ static void gp_get_3d_reference (tGPsdata *p, float *vec) float *fp= give_cursor(p->scene, v3d); /* the reference point used depends on the owner... */ -#if 0 // XXX: disabled for now, since we can't draw relative ot the owner yet +#if 0 // XXX: disabled for now, since we can't draw relative to the owner yet if (p->ownerPtr.type == &RNA_Object) { Object *ob= (Object *)p->ownerPtr.data; @@ -206,13 +211,17 @@ static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2]) if (p->gpd->sbuffer_size == 0) return 1; - /* check if mouse moved at least certain distance on both axes (best case) */ + /* check if mouse moved at least certain distance on both axes (best case) + * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand + */ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) return 1; - /* check if the distance since the last point is significant enough */ - // future optimisation: sqrt here may be too slow? - else if (sqrt(dx*dx + dy*dy) > MIN_EUCLIDEAN_PX) + /* check if the distance since the last point is significant enough + * - prevents points being added too densely + * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though + */ + else if ((dx*dx + dy*dy) > MIN_EUCLIDEAN_PX*MIN_EUCLIDEAN_PX) return 1; /* mouse 'didn't move' */ @@ -228,7 +237,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[], flo /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) { - if(gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out, 0, depth))) { + if (gpencil_project_check(p) && (view_autodist_simple(p->ar, mval, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -286,7 +295,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[], flo /* 2d - relative to screen (viewport area) */ else { - if(p->subrect == NULL) { /* normal 3D view */ + if (p->subrect == NULL) { /* normal 3D view */ out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100; out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } @@ -406,12 +415,12 @@ static void gp_stroke_simplify (tGPsdata *p) short flag= gpd->sbuffer_sflag; short i, j; - /* only simplify if simlification is enabled, and we're not doing a straight line */ + /* only simplify if simplification is enabled, and we're not doing a straight line */ if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)) return; /* don't simplify if less than 4 points in buffer */ - if ((num_points <= 2) || (old_points == NULL)) + if ((num_points <= 4) || (old_points == NULL)) return; /* clear buffer (but don't free mem yet) so that we can write to it @@ -532,60 +541,62 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } else { float *depth_arr= NULL; - + /* get an array of depths, far depths are blended */ - if(gpencil_project_check(p)) { + if (gpencil_project_check(p)) { short mval[2]; int interp_depth = 0; int found_depth = 0; - + depth_arr= MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); - + for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { mval[0]= ptc->x; mval[1]= ptc->y; - if(view_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) + if (view_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) interp_depth= TRUE; else found_depth= TRUE; } - - if(found_depth==FALSE) { + + if (found_depth == FALSE) { /* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */ for (i=gpd->sbuffer_size-1; i >= 0; i--) depth_arr[i] = 0.9999f; } else { - if(p->gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS) { + if (p->gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS) { /* remove all info between the valid endpoints */ int first_valid = 0; int last_valid = 0; - - for (i=0; i < gpd->sbuffer_size; i++) - if(depth_arr[i] != FLT_MAX) + + for (i=0; i < gpd->sbuffer_size; i++) { + if (depth_arr[i] != FLT_MAX) break; + } first_valid= i; - - for (i=gpd->sbuffer_size-1; i >= 0; i--) - if(depth_arr[i] != FLT_MAX) + + for (i=gpd->sbuffer_size-1; i >= 0; i--) { + if (depth_arr[i] != FLT_MAX) break; + } last_valid= i; - + /* invalidate non-endpoints, so only blend between first and last */ for (i=first_valid+1; i < last_valid; i++) depth_arr[i]= FLT_MAX; - + interp_depth= TRUE; } - - if(interp_depth) { + + if (interp_depth) { interp_sparse_array(depth_arr, gpd->sbuffer_size, FLT_MAX); } } } - - + + pt= gps->points; - + /* convert all points (normal behaviour) */ for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { /* convert screen-coordinates to appropriate coordinates (and store them) */ @@ -594,8 +605,8 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* copy pressure */ pt->pressure= ptc->pressure; } - - if(depth_arr) + + if (depth_arr) MEM_freeN(depth_arr); } @@ -725,7 +736,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } #endif else { - if(p->subrect == NULL) { /* normal 3D view */ + if (p->subrect == NULL) { /* normal 3D view */ x0= (int)(gps->points->x / 100 * p->ar->winx); y0= (int)(gps->points->y / 100 * p->ar->winy); } @@ -1015,9 +1026,6 @@ static tGPsdata *gp_session_initpaint (bContext *C) /* set edit flags - so that buffer will get drawn */ G.f |= G_GREASEPENCIL; - /* set initial run flag */ - p->flags |= GP_PAINTFLAG_FIRSTRUN; - /* clear out buffer (stored in gp-data), in case something contaminated it */ gp_session_validatebuffer(p); @@ -1080,6 +1088,9 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->paintmode= paintmode; if (p->paintmode == GP_PAINTMODE_ERASER) p->gpd->sbuffer_sflag |= GP_STROKE_ERASER; + + /* set 'initial run' flag, which is only used to denote when a new stroke is starting */ + p->flags |= GP_PAINTFLAG_FIRSTRUN; /* check if points will need to be made in view-aligned space */ if (p->gpd->flag & GP_DATA_VIEWALIGN) { @@ -1236,7 +1247,7 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op) } /* cleanup */ - if(gpencil_project_check(p)) { + if (gpencil_project_check(p)) { View3D *v3d= p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ @@ -1261,6 +1272,46 @@ static int gpencil_draw_cancel (bContext *C, wmOperator *op) /* ------------------------------- */ +/* update UI indicators of status, including cursor and header prints */ +static void gpencil_draw_status_indicators (tGPsdata *p) +{ + /* header prints */ + switch (p->status) { + case GP_STATUS_PAINTING: + /* only print this for paint-sessions, otherwise it gets annoying */ + if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) + ED_area_headerprint(p->sa, "Grease Pencil: Drawing/erasing stroke... Release to end stroke"); + break; + + case GP_STATUS_IDLING: + /* print status info */ + switch (p->paintmode) { + case GP_PAINTMODE_ERASER: + ED_area_headerprint(p->sa, "Grease Pencil Erase Session: Hold and drag LMB or RMB to erase | ESC/Enter to end"); + break; + case GP_PAINTMODE_DRAW_STRAIGHT: + ED_area_headerprint(p->sa, "Grease Pencil Line Session: Hold and drag LMB to draw | ESC/Enter to end"); + break; + case GP_PAINTMODE_DRAW: + ED_area_headerprint(p->sa, "Grease Pencil Freehand Session: Hold and drag LMB to draw | ESC/Enter to end"); + break; + + default: /* unhandled future cases */ + ED_area_headerprint(p->sa, "Grease Pencil Session: ESC/Enter to end"); + break; + } + break; + + case GP_STATUS_ERROR: + case GP_STATUS_DONE: + /* clear status string */ + ED_area_headerprint(p->sa, NULL); + break; + } +} + +/* ------------------------------- */ + /* create a new stroke point at the point indicated by the painting context */ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) { @@ -1325,12 +1376,22 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) tablet= (wmtab->Active != EVT_TABLET_NONE); p->pressure= wmtab->Pressure; + //if (wmtab->Active == EVT_TABLET_ERASER) // TODO... this should get caught by the keymaps which call drawing in the first place } else p->pressure= 1.0f; + /* fill in stroke data (not actually used directly by gpencil_draw_apply) */ + RNA_collection_add(op->ptr, "stroke", &itemptr); + + mousef[0]= p->mval[0]; + mousef[1]= p->mval[1]; + RNA_float_set_array(&itemptr, "mouse", mousef); + RNA_float_set(&itemptr, "pressure", p->pressure); + RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN)); + /* special exception for start of strokes (i.e. maybe for just a dot) */ if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; @@ -1346,14 +1407,6 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) return; } - /* fill in stroke data (not actually used directly by gpencil_draw_apply) */ - RNA_collection_add(op->ptr, "stroke", &itemptr); - - mousef[0]= p->mval[0]; - mousef[1]= p->mval[1]; - RNA_float_set_array(&itemptr, "mouse", mousef); - RNA_float_set(&itemptr, "pressure", p->pressure); - /* apply the current latest drawing point */ gpencil_draw_apply(op, p); @@ -1396,6 +1449,17 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) p->mval[1] = (short)mousef[1]; p->pressure= RNA_float_get(&itemptr, "pressure"); + if (RNA_boolean_get(&itemptr, "is_start")) { + /* if first-run flag isn't set already (i.e. not true first stroke), + * then we must terminate the previous one first before continuing + */ + if ((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) { + // TODO: both of these ops can set error-status, but we probably don't need to worry + gp_paint_strokeend(p); + gp_paint_initstroke(p, p->paintmode); + } + } + /* if first run, set previous data too */ if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; @@ -1447,6 +1511,8 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) // TODO: set any additional settings that we can take from the events? // TODO? if tablet is erasing, force eraser to be on? + // TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... + /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { // TODO: this involves mucking around with radial control, so we leave this for now.. @@ -1484,67 +1550,110 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p= op->customdata; + int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ //printf("\tGP - handle modal event...\n"); - switch (event->type) { - /* end of stroke -> ONLY when a mouse-button release occurs - * otherwise, carry on to mouse-move... - */ - case LEFTMOUSE: - case RIGHTMOUSE: - /* if painting, end stroke */ - if (p->status == GP_STATUS_PAINTING) { - /* basically, this should be mouse-button up */ - //printf("\t\tGP - end of stroke \n"); - gpencil_draw_exit(C, op); - - /* one last flush before we're done */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + /* exit painting mode (and/or end current stroke) */ + if (ELEM3(event->type, RETKEY, PADENTER, ESCKEY)) { + /* exit() ends the current stroke before cleaning up */ + //printf("\t\tGP - end of paint op + end of stroke\n"); + gpencil_draw_exit(C, op); + p->status= GP_STATUS_DONE; + estate = OPERATOR_FINISHED; + } + + /* toggle painting mode upon mouse-button movement */ + if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE)) { + /* if painting, end stroke */ + if (p->status == GP_STATUS_PAINTING) { + /* basically, this should be mouse-button up = end stroke + * BUT what happens next depends on whether we 'painting sessions' is enabled + */ + if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) { + /* end stroke only, and then wait to resume painting soon */ + //printf("\t\tGP - end stroke only\n"); + gp_paint_strokeend(p); + p->status= GP_STATUS_IDLING; - return OPERATOR_FINISHED; + /* we've just entered idling state, so this event was processed (but no others yet) */ + estate = OPERATOR_RUNNING_MODAL; + } + else { + //printf("\t\tGP - end of stroke + op\n"); + gpencil_draw_exit(C, op); + p->status= GP_STATUS_DONE; + estate = OPERATOR_FINISHED; + } + } + else { + /* not painting, so start stroke (this should be mouse-button down) */ + + /* we must check that we're still within the area that we're set up to work from + * otherwise we could crash (see bug #20586) + */ + if (CTX_wm_area(C) != p->sa) { + //printf("\t\t\tGP - wrong area execution abort! \n"); + gpencil_draw_exit(C, op); + p->status= GP_STATUS_ERROR; + estate = OPERATOR_CANCELLED; } else { - /* not painting, so start stroke (this should be mouse-button down) */ - - /* we must check that we're still within the area that we're set up to work from - * otherwise we could crash (see bug #20586) - */ - if (CTX_wm_area(C) != p->sa) { - //printf("\t\t\tGP - wrong area execution abort! \n"); - gpencil_draw_exit(C, op); - return OPERATOR_CANCELLED; - } - //printf("\t\tGP - start stroke \n"); p->status= GP_STATUS_PAINTING; - /* no break now, since we should immediately start painting */ - } - - /* moving mouse - assumed that mouse button is down if in painting status */ - case MOUSEMOVE: - case INBETWEEN_MOUSEMOVE: - /* check if we're currently painting */ - if (p->status == GP_STATUS_PAINTING) { - /* handle drawing event */ - //printf("\t\tGP - add point\n"); - gpencil_draw_apply_event(op, event); - /* finish painting operation if anything went wrong just now */ + /* we may need to set up paint env again if we're resuming */ + // XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions + // XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support + gp_paint_initstroke(p, p->paintmode); + if (p->status == GP_STATUS_ERROR) { - //printf("\t\t\tGP - error done! \n"); gpencil_draw_exit(C, op); - return OPERATOR_CANCELLED; + estate = OPERATOR_CANCELLED; } } - break; + } + } + + /* handle painting mouse-movements? */ + if ((p->status == GP_STATUS_PAINTING) && + (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) || (p->flags & GP_PAINTFLAG_FIRSTRUN)) ) + { + /* handle drawing event */ + //printf("\t\tGP - add point\n"); + gpencil_draw_apply_event(op, event); - default: - //printf("\t\tGP unknown event - %d \n", event->type); + /* finish painting operation if anything went wrong just now */ + if (p->status == GP_STATUS_ERROR) { + //printf("\t\t\t\tGP - add error done! \n"); + gpencil_draw_exit(C, op); + estate = OPERATOR_CANCELLED; + } + else { + /* event handled, so just tag as running modal */ + //printf("\t\t\t\tGP - add point handled!\n"); + estate = OPERATOR_RUNNING_MODAL; + } + } + + /* update status indicators - cursor, header, etc. */ + gpencil_draw_status_indicators(p); + + /* process last operations before exiting */ + switch (estate) { + case OPERATOR_FINISHED: + /* one last flush before we're done */ + WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + break; + + case OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH: + /* event doesn't need to be handled */ + //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); break; } - return OPERATOR_RUNNING_MODAL; + /* return status code */ + return estate; } /* ------------------------------- */ @@ -1558,8 +1667,6 @@ static EnumPropertyItem prop_gpencil_drawmodes[] = { void GPENCIL_OT_draw (wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name= "Grease Pencil Draw"; ot->idname= "GPENCIL_OT_draw"; @@ -1576,8 +1683,7 @@ void GPENCIL_OT_draw (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; /* settings for drawing */ - prop= RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to intepret mouse movements."); - RNA_def_property_flag(prop, PROP_HIDDEN); + RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to intepret mouse movements."); RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 4679d36e400..997250b7a2a 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -153,6 +153,7 @@ typedef enum eAnim_ChannelType { ANIMTYPE_DSARM, ANIMTYPE_DSMESH, ANIMTYPE_DSTEX, + ANIMTYPE_DSLAT, ANIMTYPE_DSLINESTYLE, ANIMTYPE_SHAPEKEY, @@ -232,6 +233,8 @@ typedef enum eAnimFilter_Flags { #define FILTER_MBALL_OBJD(mb) ((mb->flag2 & MB_DS_EXPAND)) #define FILTER_ARM_OBJD(arm) ((arm->flag & ARM_DS_EXPAND)) #define FILTER_MESH_OBJD(me) ((me->flag & ME_DS_EXPAND)) +#define FILTER_LATTICE_OBJD(lt) ((lt->flag & LT_DS_EXPAND)) + /* 'Sub-object/Action' channels (flags stored in Action) */ #define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED)) #define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0) diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 6c5a0cc3bf3..78edcc05586 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -55,6 +55,10 @@ typedef struct tGPspoint { float pressure; /* pressure of tablet at this point */ } tGPspoint; + +/* Check if 'sketching sessions' are enabled */ +#define GPENCIL_SKETCH_SESSIONS_ON(scene) ((scene)->toolsettings->gpencil_flags & GP_TOOL_FLAG_PAINTSESSIONS_ON) + /* ----------- Grease Pencil Tools/Context ------------- */ struct bGPdata **gpencil_data_get_pointers(struct bContext *C, struct PointerRNA *ptr); diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 6dc2fe04227..72e87e2c9bc 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -51,6 +51,7 @@ struct ReportList; struct PointerRNA; struct PropertyRNA; +struct EnumPropertyItem; #include "RNA_types.h" @@ -204,6 +205,9 @@ struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const c /* 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, const char title[], const char op_name[]); +/* Dynamically populate an enum of Keying Sets */ +struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); + /* 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_markers.h b/source/blender/editors/include/ED_markers.h index e5e1f3cef10..b32fc1a48ef 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -51,6 +51,8 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short sel); +struct TimeMarker *ED_markers_get_first_selected(ListBase *markers); + /* Operators ------------------------------ */ /* called in screen_ops.c:ED_operatortypes_screen() */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index d1bce26dd45..386bbc0a236 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -193,12 +193,15 @@ int paintface_minmax(struct Object *ob, float *min, float *max); struct bDeformGroup *ED_vgroup_add(struct Object *ob); struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name); +void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup); void ED_vgroup_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); int ED_vgroup_copy_array(struct Object *ob, struct Object *ob_from); void ED_vgroup_mirror(struct Object *ob, int mirror_weights, int flip_vgroups); +int ED_vgroup_object_is_edit_mode(struct Object *ob); + void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode); void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum); float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum); diff --git a/source/blender/editors/include/ED_retopo.h b/source/blender/editors/include/ED_retopo.h deleted file mode 100644 index e8d74411871..00000000000 --- a/source/blender/editors/include/ED_retopo.h +++ /dev/null @@ -1,111 +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) 2006 by Nicholas Bishop - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef ED_RETOPO_H -#define ED_RETOPO_H - -#include "DNA_vec_types.h" - -/* For bglMats */ -#include "BIF_glutil.h" - -struct EditVert; -struct Mesh; -struct View3D; - -typedef struct RetopoViewData { - bglMats mats; - - char queue_matrix_update; -} RetopoViewData; - -typedef struct RetopoPaintPoint { - struct RetopoPaintPoint *next, *prev; - vec2s loc; - short index; - float co[3]; - struct EditVert *eve; -} RetopoPaintPoint; - -typedef struct RetopoPaintLine { - struct RetopoPaintLine *next, *prev; - ListBase points; - ListBase hitlist; /* RetopoPaintHit */ - RetopoPaintPoint *cyclic; -} RetopoPaintLine; - -typedef struct RetopoPaintSel { - struct RetopoPaintSel *next, *prev; - RetopoPaintLine *line; - char first; -} RetopoPaintSel; - -typedef struct RetopoPaintData { - char in_drag; - short sloc[2]; - - ListBase lines; - ListBase intersections; /* RetopoPaintPoint */ - - short seldist; - RetopoPaintSel nearest; - - struct View3D *paint_v3d; -} RetopoPaintData; - -RetopoPaintData *get_retopo_paint_data(void); - -char retopo_mesh_check(void); -char retopo_curve_check(void); - -void retopo_end_okee(void); - -void retopo_free_paint_data(RetopoPaintData *rpd); -void retopo_free_paint(void); - -char retopo_mesh_paint_check(void); -void retopo_paint_view_update(struct View3D *v3d); -void retopo_force_update(void); -void retopo_paint_toggle(void*,void*); -char retopo_paint(const unsigned short event); -void retopo_draw_paint_lines(void); -RetopoPaintData *retopo_paint_data_copy(RetopoPaintData *rpd); - -void retopo_toggle(void*,void*); -void retopo_do_vert(struct View3D *v3d, float *v); -void retopo_do_all(void); -void retopo_do_all_cb(void *, void *); -void retopo_queue_updates(struct View3D *v3d); - -void retopo_matrix_update(struct View3D *v3d); - -void retopo_free_view_data(struct View3D *v3d); - -#endif - diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index c9139a503f1..5864449a490 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -142,6 +142,7 @@ void BIF_selectOrientation(void); #define P_GEO_SNAP (P_SNAP|(1 << 4)) #define P_ALIGN_SNAP (P_GEO_SNAP|(1 << 5)) #define P_CONSTRAINT (1 << 6) +#define P_OPTIONS (1 << 7) void Transform_Properties(struct wmOperatorType *ot, int flags); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index e5a95f23ab6..337104e3737 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -109,7 +109,7 @@ void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]); void view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct RegionView3D *rv3d, struct View3D *v3d, struct rctf *viewborder_r, short do_shift); -/* drawobject.c itterators */ +/* drawobject.c iterators */ void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct EditVert *eve, int x, int y, int index), void *userData, int clipVerts); void mesh_foreachScreenEdge(struct ViewContext *vc, void (*func)(void *userData, struct EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts); void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, struct EditFace *efa, int x, int y, int index), void *userData); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4e3e9786a5a..d74a907d785 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -40,10 +40,12 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_library.h" #include "BKE_unit.h" +#include "BKE_utildefines.h" /* FILE_MAX */ #include "BIF_gl.h" @@ -1734,7 +1736,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16); } - if(BPY_eval_button(C, str_unit_convert, &value)) { + if(BPY_button_exec(C, str_unit_convert, &value)) { value = ui_get_but_val(but); /* use its original value */ if(str[0]) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 65261371329..b74165801ce 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -34,10 +34,11 @@ #include "BLI_math.h" #include "BLI_rect.h" +#include "BLI_utildefines.h" #include "BKE_colortools.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 2537b89d791..0f1e44aff1d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -38,6 +38,8 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "PIL_time.h" #include "BKE_colortools.h" @@ -646,13 +648,12 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) return BLI_in_rcti(&rect, x, y); } -#define UI_DRAG_THRESHOLD 3 static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { /* prevent other WM gestures to start while we try to drag */ WM_gestures_remove(C); - if( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > UI_DRAG_THRESHOLD ) { + if( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold ) { wmDrag *drag; button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -3756,13 +3757,13 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int Scopes *scopes = (Scopes *)but->poin; rcti rect; int changed= 1; - float dx, dy; + /* float dx, dy; */ rect.xmin= but->x1; rect.xmax= but->x2; rect.ymin= but->y1; rect.ymax= but->y2; - dx = mx - data->draglastx; - dy = my - data->draglasty; + /* dx = mx - data->draglastx; */ + /* dy = my - data->draglasty; */ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize vectorscope widget itself */ @@ -5673,8 +5674,11 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, case YKEY: case ZKEY: { - if(event->val == KM_PRESS) { - count= 0; + if( (event->val == KM_PRESS) && + (event->shift == FALSE) && + (event->ctrl == FALSE) && + (event->oskey == FALSE) + ) { for(but= block->buttons.first; but; but= but->next) { if(but->menu_key==event->type) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index b0ab90279f8..7d2f8e0d32a 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -28,7 +28,6 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #ifndef WIN32 #include <unistd.h> @@ -44,6 +43,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_storage_types.h" +#include "BLI_utildefines.h" #include "DNA_brush_types.h" #include "DNA_object_types.h" @@ -851,7 +851,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), /* sanity check */ if(w<=0 || h<=0 || w>2000 || h>2000) { printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h); - assert(!"invalid icon size"); + BKE_assert(!"invalid icon size"); return; } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 46dfd34d2ba..f39a0204dcb 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -35,6 +35,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 1c2b0f9e7f3..95c52d20c37 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -29,7 +29,6 @@ #include <math.h> #include <string.h> - #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -38,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math_color.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d6cb8161916..2b6c18c5635 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_userdef_types.h" @@ -798,7 +799,7 @@ void uiEndPanels(const bContext *C, ARegion *ar) if(block->active && block->panel) ui_offset_panel_block(block); - /* consistancy; are panels not made, whilst they have tabs */ + /* consistency; are panels not made, whilst they have tabs */ for(panot= ar->panels.first; panot; panot= panot->next) { if((panot->runtime_flag & PNL_ACTIVE)==0) { // not made diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 1da50e0a9bb..571a48a4100 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -35,6 +35,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_dynstr.h" #include "BLI_ghash.h" diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 14883400359..3f9c5cb6ca1 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -32,6 +32,7 @@ #include "DNA_userdef_types.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_colortools.h" @@ -1383,7 +1384,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname hist = (Histogram *)cptr.data; - hist->height= (hist->height<=0)?100:hist->height; + hist->height= (hist->height<=20)?20:hist->height; bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, hist->height, hist, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -1420,7 +1421,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) block= uiLayoutAbsoluteBlock(layout); - scopes->wavefrm_height= (scopes->wavefrm_height<=0)?100:scopes->wavefrm_height; + scopes->wavefrm_height= (scopes->wavefrm_height<=20)?20:scopes->wavefrm_height; bt= uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); @@ -1456,7 +1457,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna block= uiLayoutAbsoluteBlock(layout); - scopes->vecscope_height= (scopes->vecscope_height<=0)?100:scopes->vecscope_height; + scopes->vecscope_height= (scopes->vecscope_height<=20)?20:scopes->vecscope_height; bt= uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -1957,7 +1958,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, /************************* List Template **************************/ -static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon) +static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int big) { ID *id= NULL; int icon; @@ -1978,7 +1979,7 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon) /* get icon from ID */ if(id) { - icon= ui_id_icon_get(C, id, 1); + icon= ui_id_icon_get(C, id, big); if(icon) return icon; @@ -2007,7 +2008,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe sub= uiLayoutRow(overlap, 0); /* retrieve icon and name */ - icon= list_item_icon_get(C, itemptr, rnaicon); + icon= list_item_icon_get(C, itemptr, rnaicon, 0); if(icon == ICON_NULL || icon == ICON_DOT) icon= 0; @@ -2152,7 +2153,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if(i == 9) row= uiLayoutRow(col, 0); - icon= list_item_icon_get(C, &itemptr, rnaicon); + icon= list_item_icon_get(C, &itemptr, rnaicon, 1); but= uiDefIconButR(block, LISTROW, 0, icon, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); @@ -2176,7 +2177,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if(found) { /* create button */ name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); - icon= list_item_icon_get(C, &itemptr, rnaicon); + icon= list_item_icon_get(C, &itemptr, rnaicon, 0); uiItemL(row, (name)? name: "", icon); if(name) diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index dbe3697c76a..9a6a54bb8ef 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -30,8 +30,10 @@ #include "DNA_object_types.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" @@ -56,19 +58,11 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind switch(RNA_property_type(prop)) { case PROP_BOOLEAN: { - int value, length; if(arraylen && index == -1) return NULL; - - length= RNA_property_array_length(ptr, prop); - - if(length) - value= RNA_property_boolean_get_index(ptr, prop, index); - else - value= RNA_property_boolean_get(ptr, prop); - if(icon && name && strcmp(name, "") == 0) + if(icon && name && name[0] == '\0') but= uiDefIconButR(block, ICONTOG, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); else if(icon) but= uiDefIconTextButR(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index efdb2ef5f5e..cf29794434e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -36,6 +36,7 @@ #include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -747,7 +748,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) static void widget_draw_preview(BIFIconID icon, float aspect, float UNUSED(alpha), rcti *rect) { - int w, h, x, y, size; + int w, h, size; if(icon==ICON_NULL) return; @@ -756,11 +757,13 @@ static void widget_draw_preview(BIFIconID icon, float aspect, float UNUSED(alpha h = rect->ymax - rect->ymin; size = MIN2(w, h); size -= PREVIEW_PAD*2; /* padding */ - - x = rect->xmin + w/2 - size/2; - y = rect->ymin + h/2 - size/2; - - UI_icon_draw_preview_aspect_size(x, y, icon, aspect, size); + + if(size > 0) { + int x = rect->xmin + w/2 - size/2; + int y = rect->ymin + h/2 - size/2; + + UI_icon_draw_preview_aspect_size(x, y, icon, aspect, size); + } } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index fa36eed5911..9c5f4067204 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -36,7 +36,6 @@ #include "MEM_guardedalloc.h" - #include "DNA_curve_types.h" #include "DNA_userdef_types.h" #include "DNA_screen_types.h" @@ -44,13 +43,13 @@ #include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" - +#include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" @@ -1527,7 +1526,7 @@ void init_userdef_do_versions(void) U.dbl_click_time = 350; } if (U.anim_player_preset == 0) { - U.anim_player_preset =1 ; + U.anim_player_preset = 1 ; } if (U.scrcastfps == 0) { U.scrcastfps = 10; @@ -1536,6 +1535,8 @@ void init_userdef_do_versions(void) if (U.v2d_min_gridsize == 0) { U.v2d_min_gridsize= 35; } + if (U.dragthreshold == 0 ) + U.dragthreshold= 5; /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8faf528eb67..ae414c6e557 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -36,10 +36,11 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #include "WM_api.h" @@ -1109,7 +1110,6 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x View2DGrid *grid; float space, pixels, seconddiv; - int secondgrid; /* check that there are at least some workable args */ if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) @@ -1120,11 +1120,9 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x /* rule: gridstep is minimal GRIDSTEP pixels */ if (xunits == V2D_UNIT_SECONDS) { - secondgrid= 1; seconddiv= (float)(0.01 * FPS); } else { - secondgrid= 0; seconddiv= 1.0f; } @@ -1133,9 +1131,11 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x space= v2d->cur.xmax - v2d->cur.xmin; pixels= (float)(v2d->mask.xmax - v2d->mask.xmin); - grid->dx= (U.v2d_min_gridsize * space) / (seconddiv * pixels); - step_to_grid(&grid->dx, &grid->powerx, xunits); - grid->dx *= seconddiv; + if(pixels!=0.0f) { + grid->dx= (U.v2d_min_gridsize * space) / (seconddiv * pixels); + step_to_grid(&grid->dx, &grid->powerx, xunits); + grid->dx *= seconddiv; + } if (xclamp == V2D_GRID_CLAMP) { if (grid->dx < 0.1f) grid->dx= 0.1f; @@ -1573,6 +1573,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v state |= UI_SCROLL_ARROWS; } + UI_ThemeColor(TH_BACK); + glRecti(v2d->hor.xmin, v2d->hor.ymin, v2d->hor.xmax, v2d->hor.ymax); + uiWidgetScrollDraw(&wcol, &hor, &slider, state); } @@ -1681,6 +1684,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v state |= UI_SCROLL_ARROWS; } + UI_ThemeColor(TH_BACK); + glRecti(v2d->vert.xmin, v2d->vert.ymin, v2d->vert.xmax, v2d->vert.ymax); + uiWidgetScrollDraw(&wcol, &vert, &slider, state); } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index af63b9cf37e..fcc72cba321 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -32,6 +32,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" @@ -409,6 +410,11 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", -40); + if(RNA_boolean_get(op->ptr, "page")) { + ARegion *ar= CTX_wm_region(C); + RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymin - ar->v2d.mask.ymax); + } + /* apply movement, then we're done */ view_pan_apply(op); view_pan_exit(op); @@ -429,6 +435,7 @@ void VIEW2D_OT_scroll_down(wmOperatorType *ot) /* rna - must keep these in sync with the other operators */ RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX); + RNA_def_boolean(ot->srna, "page", 0, "Page", "Scroll down one page."); } @@ -453,6 +460,11 @@ static int view_scrollup_exec(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", 40); + if(RNA_boolean_get(op->ptr, "page")) { + ARegion *ar= CTX_wm_region(C); + RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymax - ar->v2d.mask.ymin); + } + /* apply movement, then we're done */ view_pan_apply(op); view_pan_exit(op); @@ -473,6 +485,7 @@ void VIEW2D_OT_scroll_up(wmOperatorType *ot) /* rna - must keep these in sync with the other operators */ RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "deltay", 0, INT_MIN, INT_MAX, "Delta Y", "", INT_MIN, INT_MAX); + RNA_def_boolean(ot->srna, "page", 0, "Page", "Scroll up one page."); } /* ********************************************************* */ @@ -1683,8 +1696,10 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", PAGEDOWNKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", PAGEUPKEY, KM_PRESS, 0, 0); + + RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "page", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "page", 1); + WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 945313a71e8..2a391f7bbaf 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -36,6 +36,7 @@ #include "BLI_heap.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 5f7ccd1441b..d010ab19048 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -43,6 +43,7 @@ #include "BLI_editVert.h" #include "BLI_dynstr.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_context.h" @@ -58,7 +59,6 @@ #include "ED_mesh.h" #include "ED_object.h" -#include "ED_retopo.h" #include "ED_screen.h" #include "ED_util.h" #include "ED_view3d.h" @@ -1607,7 +1607,6 @@ typedef struct UndoMesh { EditSelectionC *selected; int totvert, totedge, totface, totsel; int selectmode, shapenr; - RetopoPaintData *retopo_paint_data; char retopo_mode; CustomData vdata, edata, fdata; } UndoMesh; diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 5d6ed426152..d9db1e99bfa 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -44,6 +44,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -261,7 +262,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) EM_project_snap_verts(C, vc.ar, vc.obedit, vc.em); WM_event_add_notifier(C, NC_GEOM|ND_DATA, vc.obedit->data); - DAG_id_tag_update(vc.obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(vc.obedit->data, 0); return OPERATOR_FINISHED; } @@ -388,7 +389,7 @@ static int make_fgon_exec(bContext *C, wmOperator *op) EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data)); if( make_fgon(em, op, 1) ) { - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -420,7 +421,7 @@ static int clear_fgon_exec(bContext *C, wmOperator *op) EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data)); if( make_fgon(em, op, 0) ) { - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -709,7 +710,7 @@ void addfaces_from_edgenet(EditMesh *em) EM_select_flush(em); -// XXX DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// XXX DAG_id_tag_update(obedit->data, 0); } static void addedgeface_mesh(EditMesh *em, wmOperator *op) @@ -738,7 +739,7 @@ static void addedgeface_mesh(EditMesh *em, wmOperator *op) eed= addedgelist(em, neweve[0], neweve[1], NULL); EM_select_edge(eed, 1); - // XXX DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + // XXX DAG_id_tag_update(obedit->data, 0); return; } else if(amount > 4) { @@ -836,7 +837,7 @@ static int addedgeface_mesh_exec(bContext *C, wmOperator *op) addedgeface_mesh(em, op); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1371,7 +1372,7 @@ static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmod make_prim(obedit, type, mat, tot, seg, subdiv, dia, depth, ext, fill); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -1733,7 +1734,7 @@ static int mesh_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_end_editmesh(ob->data, em); - DAG_id_tag_update(ob->data, OB_RECALC_DATA); + DAG_id_tag_update(ob->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index e50f65256a7..11cf5dfa42c 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -48,12 +48,13 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_customdata.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" + #include "ED_mesh.h" #include "ED_screen.h" diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index 229a76f8ec8..4ffd458d66c 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -46,12 +46,14 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_mesh.h" +#include "BKE_array_mallocn.h" #include "PIL_time.h" @@ -376,7 +378,7 @@ void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcuts) EM_selectmode_set(em); } -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); return; } @@ -696,7 +698,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 661539d536b..54a3adc5da3 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -38,7 +38,6 @@ editmesh_mods.c, UI level access, no geometry changes #include "MEM_guardedalloc.h" - #include "DNA_material_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" @@ -49,6 +48,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_displist.h" @@ -143,7 +143,7 @@ void EM_automerge(Scene *scene, Object *obedit, int update) if (len) { em->totvert -= len; /* saves doing a countall */ if (update) { - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); } } } @@ -1427,7 +1427,7 @@ void EM_mesh_copy_edge(EditMesh *em, short type) } if (change) { -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); } } @@ -1555,7 +1555,7 @@ void EM_mesh_copy_face(EditMesh *em, wmOperator *op, short type) } if (change) { -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); } } @@ -1685,7 +1685,7 @@ void EM_mesh_copy_face_layer(EditMesh *em, wmOperator *op, short type) } if (change) { -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); } } @@ -2195,7 +2195,7 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2]) break; } - DAG_id_tag_update(vc.obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(vc.obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); } } @@ -2739,7 +2739,7 @@ void EM_hide_mesh(EditMesh *em, int swap) em->totedgesel= em->totfacesel= em->totvertsel= 0; // if(EM_texFaceCheck()) - // DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + // DAG_id_tag_update(obedit->data, 0); } static int hide_mesh_exec(bContext *C, wmOperator *op) @@ -2806,7 +2806,7 @@ void EM_reveal_mesh(EditMesh *em) EM_selectmode_flush(em); // if (EM_texFaceCheck()) -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); } static int reveal_mesh_exec(bContext *C, wmOperator *UNUSED(op)) @@ -3743,7 +3743,7 @@ static int editmesh_mark_seam(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -3795,7 +3795,7 @@ static int editmesh_mark_sharp(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -4021,7 +4021,7 @@ void EM_recalc_normal_direction(EditMesh *em, int inside, int select) /* makes f recalc_editnormals(em); -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); waitcursor(0); } @@ -4039,7 +4039,7 @@ static int normals_make_consistent_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); //TODO is this needed ? return OPERATOR_FINISHED; @@ -4379,7 +4379,7 @@ static int smooth_vertex(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -4466,7 +4466,7 @@ static int mesh_noise_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -4531,7 +4531,7 @@ static int flip_normals(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -4571,7 +4571,7 @@ static int solidify_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -4607,7 +4607,7 @@ static int mesh_select_nth_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index d00b5ac6070..0fde8d75990 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -52,6 +52,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_rand.h" #include "BLI_ghash.h" @@ -483,11 +484,12 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op) if(count) { recalc_editnormals(em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); } - BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", count); + BKE_reportf(op->reports, RPT_INFO, "Removed %d vert%s.", count, (count==1)?"ex":"ices"); + BKE_mesh_end_editmesh(obedit->data, em); return OPERATOR_FINISHED; @@ -646,7 +648,7 @@ static void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op, short typ * This shouldn't be necessary, derived queries should be * automatically building this data if invalid. Or something. */ - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); /* individual faces? */ // BIF_TransformSetUndo("Extrude"); @@ -677,7 +679,7 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -691,7 +693,7 @@ static int mesh_extrude_exec(bContext *C, wmOperator *op) extrude_mesh(obedit, em, op, RNA_int_get(op->ptr, "type")); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -813,7 +815,7 @@ static int split_mesh(bContext *C, wmOperator *UNUSED(op)) WM_cursor_wait(0); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -873,7 +875,7 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) EM_fgon_flags(em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -977,7 +979,7 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float EM_fgon_flags(em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } BKE_mesh_end_editmesh(obedit->data, em); @@ -995,7 +997,7 @@ static int spin_mesh_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -1096,7 +1098,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) } if(spin_mesh(C, op, dvec, turns*steps, 360.0f*turns, 0)) { - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1197,13 +1199,13 @@ static void delete_mesh(EditMesh *em, wmOperator *op, int event) EditVert *eve,*nextve; EditEdge *eed,*nexted; int count; - const char *str="Erase"; + /* const char *str="Erase"; */ if(event<1) return; if(event==10 ) { - str= "Erase Vertices"; + /* str= "Erase Vertices"; */ erase_edges(em, &em->edges); erase_faces(em, &em->faces); erase_vertices(em, &em->verts); @@ -1212,10 +1214,10 @@ static void delete_mesh(EditMesh *em, wmOperator *op, int event) if(!EdgeLoopDelete(em, op)) return; - str= "Erase Edge Loop"; + /* str= "Erase Edge Loop"; */ } else if(event==4) { - str= "Erase Edges & Faces"; + /* str= "Erase Edges & Faces"; */ efa= em->faces.first; while(efa) { nextvl= efa->next; @@ -1257,7 +1259,7 @@ static void delete_mesh(EditMesh *em, wmOperator *op, int event) } } else if(event==1) { - str= "Erase Edges"; + /* str= "Erase Edges"; */ // faces first efa= em->faces.first; while(efa) { @@ -1302,18 +1304,18 @@ static void delete_mesh(EditMesh *em, wmOperator *op, int event) } else if(event==2) { - str="Erase Faces"; + /* str="Erase Faces"; */ delfaceflag(em, SELECT); } else if(event==3) { - str= "Erase All"; + /* str= "Erase All"; */ if(em->verts.first) free_vertlist(em, &em->verts); if(em->edges.first) free_edgelist(em, &em->edges); if(em->faces.first) free_facelist(em, &em->faces); if(em->selected.first) BLI_freelistN(&(em->selected)); } else if(event==5) { - str= "Erase Only Faces"; + /* str= "Erase Only Faces"; */ efa= em->faces.first; while(efa) { nextvl= efa->next; @@ -1351,7 +1353,7 @@ static int delete_mesh_exec(bContext *C, wmOperator *op) delete_mesh(em, op, type); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1684,7 +1686,7 @@ static void fill_quad_double_op(EditMesh *em, EditFace *efa, struct GHash *gh, i EditEdge *cedge[2]={NULL, NULL}; EditVert *v[4], **verts[2]; EditFace *hold; - short start=0, end, left, right, vertsize,i; + short start=0, /*end,*/ left, /* right,*/ vertsize,i; v[0] = efa->v1; v[1] = efa->v2; @@ -1705,9 +1707,9 @@ static void fill_quad_double_op(EditMesh *em, EditFace *efa, struct GHash *gh, i // the array to the correct direction if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);} - end = (start+1)%4; + /* end = (start+1)%4; */ /* UNUSED */ left = (start+2)%4; - right = (start+3)%4; + /* right = (start+3)%4; */ /* UNUSED */ if(verts[1][0] != v[left]) {flipvertarray(verts[1],numcuts+2);} /* We should have something like this now @@ -2760,7 +2762,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float } } -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); // Now for each face in the mesh we need to figure out How many edges were cut // and which filling method to use for that face for(ef = em->faces.first;ef;ef = ef->next) { @@ -3803,7 +3805,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -4654,7 +4656,7 @@ useless: } else { draw = 0; } -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); } @@ -4674,7 +4676,7 @@ useless: if(!immediate) EM_automerge(0); -// DAG_id_tag_update(obedit->data, OB_RECALC_DATA); +// DAG_id_tag_update(obedit->data, 0); // scrarea_queue_winredraw(curarea); //BLI_ghash_free(edgesgh, freeGHash, NULL); @@ -4725,7 +4727,7 @@ int EdgeLoopDelete(EditMesh *UNUSED(em), wmOperator *UNUSED(op)) EM_select_more(em); removedoublesflag(em, 1,0, 0.001); EM_select_flush(em); - // DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + // DAG_id_tag_update(obedit->data, 0); return 1; #endif return 0; @@ -5034,7 +5036,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -5107,7 +5109,7 @@ static void shape_propagate(Object *obedit, EditMesh *em, wmOperator *op) } #endif - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); return; } @@ -5120,7 +5122,7 @@ static int shape_propagate_to_all_exec(bContext *C, wmOperator *op) shape_propagate(obedit, em, op); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; @@ -5182,7 +5184,7 @@ static int blend_from_shape_exec(bContext *C, wmOperator *op) if(!blended) return OPERATOR_CANCELLED; - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; @@ -5885,7 +5887,7 @@ static int merge_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -6465,7 +6467,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op) if(!change) return OPERATOR_CANCELLED; - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -6554,7 +6556,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op) if(!change) return OPERATOR_CANCELLED; - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -6610,7 +6612,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op) if(!change) return OPERATOR_CANCELLED; - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -6666,7 +6668,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op) if(!change) return OPERATOR_CANCELLED; - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -6764,7 +6766,7 @@ static int subdivide_exec(bContext *C, wmOperator *op) esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, corner_cut_pattern, 0); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -7046,7 +7048,7 @@ static int fill_mesh_exec(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -7077,7 +7079,7 @@ static int beautify_fill_exec(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -7241,7 +7243,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op) } MEM_freeN(index); - DAG_id_tag_update(ob->data, OB_RECALC_DATA); + DAG_id_tag_update(ob->data, 0); /* Return to editmode. */ ED_object_enter_editmode(C, 0); @@ -7285,7 +7287,7 @@ static int quads_convert_to_tris_exec(bContext *C, wmOperator *UNUSED(op)) convert_to_triface(em,0); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -7314,7 +7316,7 @@ static int tris_convert_to_quads_exec(bContext *C, wmOperator *UNUSED(op)) join_triangles(em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -7343,7 +7345,7 @@ static int edge_flip_exec(bContext *C, wmOperator *UNUSED(op)) edge_flip(em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -7390,7 +7392,7 @@ static int mesh_faces_shade_smooth_exec(bContext *C, wmOperator *UNUSED(op)) BKE_mesh_end_editmesh(obedit->data, em); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -7418,7 +7420,7 @@ static int mesh_faces_shade_flat_exec(bContext *C, wmOperator *UNUSED(op)) mesh_set_smooth_faces(em, 0); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 480f42f2973..42df009bb16 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -46,6 +46,7 @@ #include "BLI_dynstr.h" /*for WM_operator_pystring */ #include "BLI_editVert.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" @@ -54,6 +55,7 @@ #include "BKE_modifier.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_array_mallocn.h" #include "BIF_gl.h" #include "BIF_glutil.h" /* for paint cursor */ @@ -287,7 +289,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, CTX_data_scene(C)); } - DAG_id_tag_update(lcd->ob->data, OB_RECALC_DATA); + DAG_id_tag_update(lcd->ob->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, lcd->ob->data); } else { diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 42db085a0ca..7dd5196d32d 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -38,6 +38,11 @@ #include "DNA_scene_types.h" #include "DNA_view3d_types.h" +#include "BLI_math.h" +#include "BLI_editVert.h" +#include "BLI_edgehash.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" @@ -47,10 +52,6 @@ #include "BKE_mesh.h" #include "BKE_report.h" -#include "BLI_math.h" -#include "BLI_editVert.h" -#include "BLI_edgehash.h" - #include "RNA_access.h" #include "RNA_define.h" @@ -189,7 +190,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s mesh_update_customdata_pointers(me); } - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -208,7 +209,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) return 0; delete_customdata_layer(C, ob, cdl); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -252,7 +253,7 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha shadeMeshMCol(scene, ob, me); } - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -271,7 +272,7 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me) return 0; delete_customdata_layer(C, ob, cdl); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return 1; @@ -485,7 +486,7 @@ static int sticky_add_exec(bContext *C, wmOperator *UNUSED(op)) RE_make_sticky(scene, v3d); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; @@ -517,7 +518,7 @@ static int sticky_remove_exec(bContext *C, wmOperator *UNUSED(op)) CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); me->msticky= NULL; - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; @@ -614,7 +615,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges) mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL); - DAG_id_tag_update(&mesh->id, OB_RECALC_DATA); + DAG_id_tag_update(&mesh->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, mesh); } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 6cf0fe0874e..3e7b7604448 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -46,6 +46,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_rand.h" /* for randome face sorting */ diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index a9a673fdf20..b73f73820c7 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "DNA_meta_types.h" #include "DNA_object_types.h" @@ -282,7 +283,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) ml= ml->prev; } WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } return OPERATOR_FINISHED; @@ -341,7 +342,7 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) ml= next; } WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } return OPERATOR_FINISHED; @@ -391,7 +392,7 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op) } } WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } return OPERATOR_FINISHED; @@ -432,7 +433,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) ml= ml->next; } WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); } return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index fdf46ea19a7..2656db0ea9f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -1036,9 +1037,7 @@ static EnumPropertyItem convert_target_items[]= { static void curvetomesh(Scene *scene, Object *ob) { - Curve *cu= ob->data; - - if(cu->disp.first==0) + if(ob->disp.first==0) makeDispListCurveTypes(scene, ob, 0); /* force creation */ nurbs_to_mesh(ob); /* also does users */ @@ -1188,7 +1187,7 @@ static int convert_exec(bContext *C, wmOperator *op) cu= newob->data; - if (!cu->disp.first) + if (!newob->disp.first) makeDispListCurveTypes(scene, newob, 0); newob->type= OB_CURVE; @@ -1225,8 +1224,12 @@ static int convert_exec(bContext *C, wmOperator *op) for(nu=cu->nurb.first; nu; nu=nu->next) nu->charidx= 0; - if(target == OB_MESH) + if(target == OB_MESH) { curvetomesh(scene, newob); + + /* meshes doesn't use displist */ + freedisplist(&newob->disp); + } } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { ob->flag |= OB_DONE; @@ -1243,6 +1246,9 @@ static int convert_exec(bContext *C, wmOperator *op) newob->data= copy_curve(ob->data); } else { newob= ob; + + /* meshes doesn't use displist */ + freedisplist(&newob->disp); } curvetomesh(scene, newob); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 4af2e00ef69..0b3e116d266 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 5afba182cc0..5076fec4fa3 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 78163fa4e1d..1465c231f41 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_rand.h" @@ -524,7 +525,10 @@ static int editmode_toggle_poll(bContext *C) if(ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib) return 0; - return ob && (ob->type == OB_MESH || ob->type == OB_ARMATURE || + if (ob->restrictflag & OB_RESTRICT_VIEW) + return 0; + + return (ob->type == OB_MESH || ob->type == OB_ARMATURE || ob->type == OB_FONT || ob->type == OB_MBALL || ob->type == OB_LATTICE || ob->type == OB_SURF || ob->type == OB_CURVE); diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 3b504995e6a..c26affc24a2 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -29,8 +29,8 @@ #include <string.h> - #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_group_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index e04ec43dace..92a53b834b0 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -34,6 +34,7 @@ #include "BLI_editVert.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_lattice_types.h" diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ed75c4060a2..6c0a154090f 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -151,6 +151,7 @@ void OBJECT_OT_modifier_copy(struct wmOperatorType *ot); void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); void OBJECT_OT_multires_reshape(struct wmOperatorType *ot); void OBJECT_OT_multires_higher_levels_delete(struct wmOperatorType *ot); +void OBJECT_OT_multires_base_apply(struct wmOperatorType *ot); void OBJECT_OT_multires_external_save(struct wmOperatorType *ot); void OBJECT_OT_multires_external_pack(struct wmOperatorType *ot); void OBJECT_OT_meshdeform_bind(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 2eefad06d2f..1f70dd84d94 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -31,6 +31,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" + #include "DNA_curve_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" @@ -46,8 +49,6 @@ #include "BKE_lattice.h" #include "BKE_mesh.h" -#include "BLI_listbase.h" - #include "ED_screen.h" #include "ED_view3d.h" #include "ED_util.h" diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index ef6f450f2f4..57929b49839 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -43,6 +43,7 @@ #include "BLI_string.h" #include "BLI_path_util.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_curve.h" #include "BKE_context.h" @@ -1176,6 +1177,48 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/********************* multires apply base ***********************/ +static int multires_base_apply_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_active_context(C); + MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); + + if (!mmd) + return OPERATOR_CANCELLED; + + multiresModifier_base_apply(mmd, ob); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; +} + +static int multires_base_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (edit_modifier_invoke_properties(C, op)) + return multires_base_apply_exec(C, op); + else + return OPERATOR_CANCELLED; +} + + +void OBJECT_OT_multires_base_apply(wmOperatorType *ot) +{ + ot->name= "Multires Apply Base"; + ot->description= "Modify the base mesh to conform to the displaced mesh"; + ot->idname= "OBJECT_OT_multires_base_apply"; + + ot->poll= multires_poll; + ot->invoke= multires_base_apply_invoke; + ot->exec= multires_base_apply_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + edit_modifier_properties(ot); +} + + /************************ mdef bind operator *********************/ static int meshdeform_poll(bContext *C) diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 221d1211930..903c40026f7 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -29,12 +29,12 @@ #include <stdlib.h> #include <math.h> - #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" @@ -134,6 +134,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_multires_subdivide); WM_operatortype_append(OBJECT_OT_multires_reshape); WM_operatortype_append(OBJECT_OT_multires_higher_levels_delete); + WM_operatortype_append(OBJECT_OT_multires_base_apply); WM_operatortype_append(OBJECT_OT_multires_external_save); WM_operatortype_append(OBJECT_OT_multires_external_pack); WM_operatortype_append(OBJECT_OT_meshdeform_bind); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 5f8996f23fe..ab53a95a156 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -47,6 +47,7 @@ #include "BLI_editVert.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_animsys.h" @@ -279,10 +280,9 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) else if (ob->id.lib) { uiPopupMenu *pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION); uiLayout *layout= uiPupMenuLayout(pup); - PointerRNA props_ptr; /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO(layout, op->idname, op->type->name, ICON_NULL, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + uiItemFullO(layout, op->idname, op->type->name, ICON_NULL, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); /* present the menu and be done... */ uiPupMenuEnd(C, pup); @@ -571,7 +571,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) } } - /* context itterator */ + /* context iterator */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(ob!=par) { @@ -746,7 +746,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) par->recalc |= OB_RECALC_OB; - /* context itterator */ + /* context iterator */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if (ob != par) { if (test_parent_loop(par, ob)) { diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 265fd84d6da..3cb20ebbac0 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -42,6 +42,7 @@ #include "BLI_listbase.h" #include "BLI_rand.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_group.h" diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 125e3c68b09..d8e54a73500 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 1792cabd5f6..60ea557d36d 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -39,6 +39,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_curve.h" diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 6f4af03c87d..8501ee22031 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -68,6 +69,8 @@ /************************ Exported Functions **********************/ static void vgroup_remap_update_users(Object *ob, int *map); +static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup); +static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg); static Lattice *vgroup_edit_lattice(Object *ob) { @@ -79,6 +82,16 @@ static Lattice *vgroup_edit_lattice(Object *ob) return NULL; } +int ED_vgroup_object_is_edit_mode(Object *ob) +{ + if(ob->type == OB_MESH) + return (((Mesh*)ob->data)->edit_mesh != NULL); + else if(ob->type == OB_LATTICE) + return (((Lattice*)ob->data)->editlatt != NULL); + + return 0; +} + bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name) { bDeformGroup *defgroup; @@ -103,6 +116,25 @@ bDeformGroup *ED_vgroup_add(Object *ob) return ED_vgroup_add_name(ob, "Group"); } +void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) +{ + bDeformGroup *dg = (bDeformGroup *)ob->defbase.first; + + while (dg) { + if (dg == defgroup) + break; + dg = dg->next; + } + + if (dg == NULL) + return; + + if(ED_vgroup_object_is_edit_mode(ob)) + vgroup_delete_edit_mode(ob, dg); + else + vgroup_delete_object_mode(ob, dg); +} + void ED_vgroup_data_create(ID *id) { /* create deform verts */ @@ -508,7 +540,7 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) } if(dvert==NULL) - return 0.0f; + return -1; dvert += vertnum; @@ -516,17 +548,17 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) if(dvert->dw[i].def_nr == def_nr) return dvert->dw[i].weight; - return 0.0f; + return -1; } float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) { int def_nr; - if(!ob) return 0.0f; + if(!ob) return -1; def_nr = defgroup_find_index(ob, dg); - if(def_nr < 0) return 0.0f; + if(def_nr < 0) return -1; return get_vert_def_nr(ob, def_nr, vertnum); } @@ -555,9 +587,10 @@ static void vgroup_select_verts(Object *ob, int select) if(dvert && dvert->totweight){ for(i=0; i<dvert->totweight; i++){ if(dvert->dw[i].def_nr == (ob->actdef-1)){ - if(select) eve->f |= SELECT; - else eve->f &= ~SELECT; - + if(!eve->h) { + if(select) eve->f |= SELECT; + else eve->f &= ~SELECT; + } break; } } @@ -1093,16 +1126,11 @@ static void vgroup_delete_update_users(Object *ob, int id) } -static void vgroup_delete_object_mode(Object *ob) +static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) { - bDeformGroup *dg; MDeformVert *dvert, *dvert_array=NULL; int i, e, dvert_tot=0; - dg = BLI_findlink(&ob->defbase, (ob->actdef-1)); - if(!dg) - return; - ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot); if(dvert_array) { @@ -1198,18 +1226,13 @@ static void vgroup_active_remove_verts(Object *ob, int allverts) } } -static void vgroup_delete_edit_mode(Object *ob) +static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup) { - bDeformGroup *defgroup; int i; if(!ob->actdef) return; - defgroup = BLI_findlink(&ob->defbase, ob->actdef-1); - if(!defgroup) - return; - /* Make sure that no verts are using this group */ vgroup_active_remove_verts(ob, 1); @@ -1285,10 +1308,14 @@ static int vgroup_object_in_edit_mode(Object *ob) static void vgroup_delete(Object *ob) { + bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef-1); + if(!dg) + return; + if(vgroup_object_in_edit_mode(ob)) - vgroup_delete_edit_mode(ob); + vgroup_delete_edit_mode(ob, dg); else - vgroup_delete_object_mode(ob); + vgroup_delete_object_mode(ob, dg); } static void vgroup_delete_all(Object *ob) @@ -1339,7 +1366,6 @@ static void vgroup_assign_verts(Object *ob, float weight) dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); if(dvert && (eve->f & SELECT)){ - done=0; /* See if this vert already has a reference to this group */ /* If so: Change its weight */ done=0; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 84d9c0725bf..90e387a79c2 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -32,13 +32,15 @@ #include "DNA_particle_types.h" #include "DNA_scene_types.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" + #include "BKE_boids.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_particle.h" -#include "BLI_listbase.h" #include "RNA_access.h" #include "RNA_enum_types.h" #include "RNA_define.h" diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 238ace11c0d..4ac4bf9fa9b 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -41,6 +41,13 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_dynstr.h" +#include "BLI_kdtree.h" +#include "BLI_rand.h" +#include "BLI_utildefines.h" + #include "BKE_DerivedMesh.h" #include "BKE_depsgraph.h" @@ -52,15 +59,8 @@ #include "BKE_particle.h" #include "BKE_report.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" -#include "BKE_pointcache.h" - -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_dynstr.h" -#include "BLI_kdtree.h" -#include "BLI_rand.h" +#include "BKE_pointcache.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -3719,8 +3719,6 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) for(; pm; pm=pm->next) { for(i=0; i<BPHYS_TOT_DATA; i++) pm->data[i] = MEM_dupallocN(pm->data[i]); - - pm->index_array = MEM_dupallocN(pm->index_array); } } @@ -3795,8 +3793,6 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) for(i=0; i<BPHYS_TOT_DATA; i++) pm->data[i] = MEM_dupallocN(pm->data[i]); - pm->index_array = MEM_dupallocN(pm->index_array); - BKE_ptcache_mem_pointers_init(pm); LOOP_POINTS { @@ -4061,25 +4057,9 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, totframe++; for(pm=cache->mem_cache.first; pm; pm=pm->next) { - BKE_ptcache_mem_pointers_init(pm); - LOOP_POINTS { - if(psys) { - if(pm->index_array) { - if(pm->index_array[p]) - BKE_ptcache_mem_pointers_seek(p, pm); - else - continue; - } - else { - pa = psys->particles + p; - if((pm->next && pm->next->frame < pa->time) - || (pm->prev && pm->prev->frame >= pa->dietime)) { - BKE_ptcache_mem_pointers_incr(pm); - continue; - } - } - } + if(BKE_ptcache_mem_pointers_seek(p, pm) == 0) + continue; if(!point->totkey) { key = point->keys = MEM_callocN(totframe*sizeof(PTCacheEditKey),"ParticleEditKeys"); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 6e0ac82ebf3..6078f05ebd1 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -36,6 +36,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -45,7 +46,7 @@ #include "BKE_main.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" #include "RNA_define.h" diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index da8e7e063f4..4e08dd49703 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -53,6 +53,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_armature.h" diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index e0fc0d7318d..9aa879dad67 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -31,6 +31,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "DNA_scene_types.h" #include "BKE_context.h" @@ -41,13 +44,10 @@ #include "BKE_pointcache.h" #include "BKE_report.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" - -#include "BLI_blenlib.h" + #include "ED_particle.h" - #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 96e48631b09..96994ab1df4 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -34,6 +34,7 @@ #include "BLI_math.h" #include "BLI_threads.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index df5576c778d..8a4a0433eb8 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 2eac7c20350..d635a799ec1 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "DNA_world_types.h" #include "DNA_camera_types.h" @@ -151,6 +152,7 @@ typedef struct ShaderPreview { /* node materials need full copy during preview render, glsl uses it too */ Material *matcopy; + float col[4]; /* active object color */ int sizex, sizey; unsigned int *pr_rect; @@ -347,6 +349,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce= pr_main->scene.first; if(sce) { + /* this flag tells render to not execute depsgraph or ipos etc */ sce->r.scemode |= R_PREVIEWBUTS; /* set world always back, is used now */ @@ -358,9 +361,17 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } sce->r.color_mgt_flag = scene->r.color_mgt_flag; + + /* prevent overhead for small renders and icons (32) */ + if(id && sp->sizex < 40) + sce->r.xparts= sce->r.yparts= 1; + else + sce->r.xparts= sce->r.yparts= 4; + /* exception: don't color manage texture previews or icons */ if((id && sp->pr_method==PR_ICON_RENDER) || id_type == ID_TE) sce->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT; + if((id && sp->pr_method==PR_ICON_RENDER) && id_type != ID_WO) sce->r.alphamode= R_ALPHAPREMUL; else @@ -381,6 +392,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre init_render_material(mat, 0, NULL); /* call that retrieves mode_l */ end_render_material(mat); + /* un-useful option */ + if(sp->pr_method==PR_ICON_RENDER) + mat->shade_flag &= ~MA_OBCOLOR; + /* turn on raytracing if needed */ if(mat->mode_l & MA_RAYMIRROR) sce->r.mode |= R_RAYTRACE; @@ -443,6 +458,9 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre for(base= sce->base.first; base; base= base->next) { if(base->object->id.name[2]=='p') { + /* copy over object color, in case material uses it */ + copy_v4_v4(base->object->col, sp->col); + if(ELEM4(base->object->type, OB_MESH, OB_CURVE, OB_SURF, OB_MBALL)) { /* don't use assign_material, it changed mat->id.us, which shows in the UI */ Material ***matar= give_matarar(base->object); @@ -601,7 +619,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r sbuts->preview= 0; ok= 0; } - + if(ok==0) { ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER); } @@ -937,7 +955,7 @@ static void shader_preview_draw(void *spv, RenderResult *UNUSED(rr), volatile st static int shader_preview_break(void *spv) { ShaderPreview *sp= spv; - + return *(sp->stop); } @@ -962,7 +980,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs short idtype= GS(id->name); char name[32]; int sizex; - + /* get the stuff from the builtin preview dbase */ sce= preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex if(sce==NULL) return; @@ -986,7 +1004,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs else if(sp->pr_method==PR_NODE_RENDER) { if(idtype == ID_MA) sce->r.scemode |= R_MATNODE_PREVIEW; else if(idtype == ID_TE) sce->r.scemode |= R_TEXNODE_PREVIEW; - sce->r.mode |= R_OSA; + sce->r.mode &= ~R_OSA; } else { /* PR_BUTS_RENDER */ sce->r.mode |= R_OSA; @@ -1021,6 +1039,8 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* handle results */ if(sp->pr_method==PR_ICON_RENDER) { + // char *rct= (char *)(sp->pr_rect + 32*16 + 16); + if(sp->pr_rect) RE_ResultGet32(re, sp->pr_rect); } @@ -1219,8 +1239,9 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r { wmJob *steve; ShaderPreview *sp; - - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER); + + /* suspended start means it starts after 1 timer step, see WM_jobs_timer below */ + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER|WM_JOB_SUSPEND); sp= MEM_callocN(sizeof(ShaderPreview), "shader preview"); /* customdata for preview thread */ @@ -1231,10 +1252,10 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r sp->pr_method= PR_ICON_RENDER; sp->pr_rect= rect; sp->id = id; - + /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); - WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL); + WM_jobs_timer(steve, 0.25, NC_MATERIAL, NC_MATERIAL); WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL, common_preview_endjob); WM_jobs_start(CTX_wm_manager(C), steve); @@ -1242,6 +1263,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method) { + Object *ob= CTX_data_active_object(C); wmJob *steve; ShaderPreview *sp; @@ -1257,6 +1279,8 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M sp->id = id; sp->parent= parent; sp->slot= slot; + if(ob && ob->totcol) copy_v4_v4(sp->col, ob->col); + else sp->col[0]= sp->col[1]= sp->col[2]= sp->col[3]= 1.0f; /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 289c1a5d028..bdb38557ae2 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -38,6 +38,12 @@ #include "DNA_space_types.h" #include "DNA_world_types.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_editVert.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" + #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -58,11 +64,6 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_editVert.h" -#include "BLI_listbase.h" - #include "GPU_material.h" #include "FRS_freestyle.h" diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index fd8afd63bb8..5ea5fe06c46 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" @@ -959,7 +960,6 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar) ScrArea *sa= CTX_wm_area(C); ar->flag ^= RGN_FLAG_HIDDEN; - ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ if(ar->flag & RGN_FLAG_HIDDEN) WM_event_remove_handlers(C, &ar->handlers); @@ -1103,10 +1103,12 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) /*send space change notifyer*/ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); - - ED_area_tag_redraw(sa); + ED_area_tag_refresh(sa); } + + /* also redraw when re-used */ + ED_area_tag_redraw(sa); } void ED_area_prevspace(bContext *C, ScrArea *sa) diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 6a9fc1489f1..9b3a51805e9 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -32,7 +32,8 @@ #include "DNA_vec_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + #include "BKE_colortools.h" #include "BLI_math.h" diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 82f5f2597dd..7374b579cab 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -33,7 +33,9 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_context.h" #include "BKE_object.h" #include "BKE_action.h" diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 7c30d113132..376e70f6ea2 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -34,6 +34,7 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 6f6b13a3309..d891b025241 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -33,6 +33,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_armature_types.h" #include "DNA_lattice_types.h" @@ -2094,6 +2095,44 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) RNA_def_int(ot->srna, "max_y", -100, INT_MIN, INT_MAX, "Y 2", "", INT_MIN, INT_MAX); } + +static int spacedata_cleanup(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + bScreen *screen; + ScrArea *sa; + int tot= 0; + + for(screen= bmain->screen.first; screen; screen= screen->id.next) { + for(sa= screen->areabase.first; sa; sa= sa->next) { + if(sa->spacedata.first != sa->spacedata.last) { + SpaceLink *sl= sa->spacedata.first; + + BLI_remlink(&sa->spacedata, sl); + tot+= BLI_countlist(&sa->spacedata); + BKE_spacedata_freelist(&sa->spacedata); + BLI_addtail(&sa->spacedata, sl); + } + } + } + BKE_reportf(op->reports, RPT_INFO, "Removed amount of editors: %d", tot); + + return OPERATOR_FINISHED; +} + +static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Clean-up space-data"; + ot->description= "Remove unused settings for invisible editors"; + ot->idname= "SCREEN_OT_spacedata_cleanup"; + + /* api callbacks */ + ot->exec= spacedata_cleanup; + ot->poll= WM_operator_winactive; + +} + /* ************** repeat last operator ***************************** */ static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) @@ -3030,6 +3069,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_screen_set); WM_operatortype_append(SCREEN_OT_screen_full_area); WM_operatortype_append(SCREEN_OT_back_to_previous); + WM_operatortype_append(SCREEN_OT_spacedata_cleanup); WM_operatortype_append(SCREEN_OT_screenshot); WM_operatortype_append(SCREEN_OT_screencast); WM_operatortype_append(SCREEN_OT_userpref_show); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index a536b4ea1a4..1fbcd7e61fd 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -70,29 +71,31 @@ static int screenshot_exec(bContext *C, wmOperator *op) { ScreenshotData *scd= op->customdata; - if(scd && scd->dumprect) { - Scene *scene= CTX_data_scene(C); - ImBuf *ibuf; - char path[FILE_MAX]; - - RNA_string_get(op->ptr, "filepath", path); - - strcpy(G.ima, path); - BLI_path_abs(path, G.main->name); + if(scd) { + if(scd->dumprect) { + Scene *scene= CTX_data_scene(C); + ImBuf *ibuf; + char path[FILE_MAX]; - /* BKE_add_image_extension() checks for if extension was already set */ - if(scene->r.scemode & R_EXTENSION) - if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5) - BKE_add_image_extension(path, scene->r.imtype); + RNA_string_get(op->ptr, "filepath", path); - ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); - ibuf->rect= scd->dumprect; - - BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); + strcpy(G.ima, path); + BLI_path_abs(path, G.main->name); + + /* BKE_add_image_extension() checks for if extension was already set */ + if(scene->r.scemode & R_EXTENSION) + if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5) + BKE_add_image_extension(path, scene->r.imtype); + + ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); + ibuf->rect= scd->dumprect; + + BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); - IMB_freeImBuf(ibuf); + IMB_freeImBuf(ibuf); - MEM_freeN(scd->dumprect); + MEM_freeN(scd->dumprect); + } MEM_freeN(scd); op->customdata= NULL; } @@ -159,6 +162,18 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) return OPERATOR_CANCELLED; } +static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op) +{ + ScreenshotData *scd= op->customdata; + + if(scd) { + if(scd->dumprect) + MEM_freeN(scd->dumprect); + MEM_freeN(scd); + op->customdata= NULL; + } + return OPERATOR_CANCELLED; +} void SCREEN_OT_screenshot(wmOperatorType *ot) { @@ -168,6 +183,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->invoke= screenshot_invoke; ot->exec= screenshot_exec; ot->poll= WM_operator_winactive; + ot->cancel= screenshot_cancel; ot->flag= 0; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index c4bf3a20235..82c2f614af1 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -44,8 +44,10 @@ #include "BLI_dynstr.h" #include "BLI_linklist.h" #include "BLI_memarena.h" -#include "PIL_time.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" + +#include "PIL_time.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -1140,6 +1142,7 @@ static void project_face_seams_init(const ProjPaintState *ps, const int face_ind /* TODO - move to arithb.c */ /* little sister we only need to know lambda */ +#ifndef PROJ_DEBUG_NOSEAMBLEED static float lambda_cp_line2(const float p[2], const float l1[2], const float l2[2]) { float h[2], u[2]; @@ -1152,6 +1155,7 @@ static float lambda_cp_line2(const float p[2], const float l1[2], const float l2 return(dot_v2v2(u, h)/dot_v2v2(u, u)); } +#endif // PROJ_DEBUG_NOSEAMBLEED /* Converts a UV location to a 3D screenspace location @@ -1624,6 +1628,7 @@ static int line_clip_rect2f( /* scale the quad & tri about its center * scaling by PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on the * edge of the face but slightly inside it occlusion tests dont return hits on adjacent faces */ +#ifndef PROJ_DEBUG_NOSEAMBLEED static void scale_quad(float insetCos[4][3], float *origCos[4], const float inset) { float cent[3]; @@ -1667,7 +1672,7 @@ static void scale_tri(float insetCos[4][3], float *origCos[4], const float inset add_v3_v3(insetCos[1], cent); add_v3_v3(insetCos[2], cent); } - +#endif //PROJ_DEBUG_NOSEAMBLEED static float Vec2Lenf_nosqrt(const float *v1, const float *v2) { @@ -2497,26 +2502,32 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* Only bother calculating the weights if we intersect */ if (ps->do_mask_normal || ps->dm_mtface_clone) { -#if 0 - /* This is not QUITE correct since UV is not inside the UV's but good enough for seams */ +#if 1 + /* get the UV on the line since we want to copy the pixels from there for bleeding */ + float uv_close[2]; + float fac= closest_to_line_v2(uv_close, uv, tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2]); + if (fac < 0.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx1]); + else if (fac > 1.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx2]); + if (side) { - barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], uv, w); + barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], uv_close, w); } else { - barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[1], tf_uv_pxoffset[2], uv, w); + barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[1], tf_uv_pxoffset[2], uv_close, w); } -#endif -#if 1 +#else /* this is buggy with quads, dont use for now */ + /* Cheat, we know where we are along the edge so work out the weights from that */ fac = fac1 + (fac * (fac2-fac1)); + w[0]=w[1]=w[2]= 0.0; if (side) { - w[fidx1?fidx1-1:0] = fac; - w[fidx2?fidx2-1:0] = 1.0f-fac; + w[fidx1?fidx1-1:0] = 1.0f-fac; + w[fidx2?fidx2-1:0] = fac; } else { - w[fidx1] = fac; - w[fidx2] = 1.0f-fac; + w[fidx1] = 1.0f-fac; + w[fidx2] = fac; } #endif } diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 6232a8f2de1..821df3028e1 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -29,19 +29,21 @@ #ifndef ED_PAINT_INTERN_H #define ED_PAINT_INTERN_H +struct ARegion; struct bContext; -struct Scene; -struct Object; +struct bglMats; +struct Brush; +struct ListBase; struct Mesh; +struct Object; struct PaintStroke; struct PointerRNA; +struct Scene; +struct VPaint; struct ViewContext; struct wmEvent; struct wmOperator; struct wmOperatorType; -struct ARegion; -struct VPaint; -struct ListBase; /* paint_stroke.c */ typedef int (*StrokeGetLocation)(struct bContext *C, struct PaintStroke *stroke, float location[3], float mouse[2]); @@ -98,6 +100,9 @@ void PAINT_OT_image_from_view(struct wmOperatorType *ot); /* paint_utils.c */ +void projectf(struct bglMats *mats, const float v[3], float p[2]); +float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius); +float paint_get_tex_pixel(struct Brush* br, float u, float v); int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index); void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, int *xy, float *uv); @@ -111,11 +116,11 @@ void PAINT_OT_face_select_all(struct wmOperatorType *ot); int facemask_paint_poll(struct bContext *C); /* stroke operator */ -typedef enum wmBrushStrokeMode { - WM_BRUSHSTROKE_NORMAL, - WM_BRUSHSTROKE_INVERT, - WM_BRUSHSTROKE_SMOOTH, -} wmBrushStrokeMode; +typedef enum BrushStrokeMode { + BRUSH_STROKE_NORMAL, + BRUSH_STROKE_INVERT, + BRUSH_STROKE_SMOOTH, +} BrushStrokeMode; /* paint_undo.c */ typedef void (*UndoRestoreCb)(struct bContext *C, struct ListBase *lb); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 8b010b6dcdb..1ba0891751e 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -19,6 +19,8 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include "BLI_utildefines.h" + #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -315,11 +317,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", WM_BRUSHSTROKE_NORMAL); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_BRUSHSTROKE_INVERT); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_BRUSHSTROKE_SMOOTH); - - //stroke_mode_modal_keymap(keyconf); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH); for(i=0; i<=5; i++) RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index ea99844bfac..125e570946b 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -28,6 +28,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_brush_types.h" @@ -41,9 +44,6 @@ #include "WM_api.h" #include "WM_types.h" -#include "BLI_math.h" - - #include "BIF_gl.h" #include "BIF_glutil.h" @@ -51,8 +51,9 @@ #include "ED_view3d.h" #include "paint_intern.h" -#include "sculpt_intern.h" // XXX, for expedience in getting this working, refactor later (or this just shows that this needs unification) - +/* still needed for sculpt_stroke_get_location, should be + removed eventually (TODO) */ +#include "sculpt_intern.h" #include <float.h> #include <math.h> @@ -100,109 +101,6 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata glDisable(GL_LINE_SMOOTH); } -#if 0 - -// grid texture for testing - -#define GRID_WIDTH 8 -#define GRID_LENGTH 8 - -#define W (0xFFFFFFFF) -#define G (0x00888888) -#define E (0xE1E1E1E1) -#define C (0xC3C3C3C3) -#define O (0xB4B4B4B4) -#define Q (0xA9A9A9A9) - -static unsigned grid_texture0[256] = -{ - W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W, - W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W, -}; - -static unsigned grid_texture1[64] = -{ - C,C,C,C,C,C,C,C, - C,G,G,G,G,G,G,C, - C,G,G,G,G,G,G,C, - C,G,G,G,G,G,G,C, - C,G,G,G,G,G,G,C, - C,G,G,G,G,G,G,C, - C,G,G,G,G,G,G,C, - C,C,C,C,C,C,C,C, -}; - -static unsigned grid_texture2[16] = -{ - O,O,O,O, - O,G,G,O, - O,G,G,O, - O,O,O,O, -}; - -static unsigned grid_texture3[4] = -{ - Q,Q, - Q,Q, -}; - -static unsigned grid_texture4[1] = -{ - Q, -}; - -#undef W -#undef G -#undef E -#undef C -#undef O -#undef Q - -static void load_grid() -{ - static GLuint overlay_texture; - - if (!overlay_texture) { - //GLfloat largest_supported_anisotropy; - - glGenTextures(1, &overlay_texture); - glBindTexture(GL_TEXTURE_2D, overlay_texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture0); - glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture1); - glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture2); - glTexImage2D(GL_TEXTURE_2D, 3, GL_RGB, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture3); - glTexImage2D(GL_TEXTURE_2D, 4, GL_RGB, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, grid_texture4); - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); - - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - - //glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy); - //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy); - } -} - -#endif - -extern float get_tex_pixel(Brush* br, float u, float v); - typedef struct Snapshot { float size[3]; float ofs[3]; @@ -373,7 +271,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc) x += br->mtex.ofs[0]; y += br->mtex.ofs[1]; - avg = br->mtex.tex ? get_tex_pixel(br, x, y) : 1; + avg = br->mtex.tex ? paint_get_tex_pixel(br, x, y) : 1; avg += br->texture_sample_bias; @@ -424,18 +322,6 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc) return 1; } -/* Convert a point in model coordinates to 2D screen coordinates. */ -// XXX duplicated from sculpt.c, deal with this later. -static void projectf(bglMats *mats, const float v[3], float p[2]) -{ - double ux, uy, uz; - - gluProject(v[0],v[1],v[2], mats->modelview, mats->projection, - (GLint *)mats->viewport, &ux, &uy, &uz); - p[0]= ux; - p[1]= uy; -} - static int project_brush_radius(RegionView3D* rv3d, float radius, float location[3], bglMats* mats) { float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2]; @@ -476,7 +362,8 @@ static int project_brush_radius(RegionView3D* rv3d, float radius, float location return len_v2v2(p1, p2); } -int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, float location[3], float modelview[16], float projection[16], int viewport[4]) +int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, + float location[3]) { struct PaintStroke *stroke; float window[2]; @@ -487,12 +374,11 @@ int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, floa window[0] = x + stroke->vc.ar->winrct.xmin; window[1] = y + stroke->vc.ar->winrct.ymin; - memcpy(modelview, stroke->vc.rv3d->viewmat, sizeof(float[16])); - memcpy(projection, stroke->vc.rv3d->winmat, sizeof(float[16])); - memcpy(viewport, stroke->mats.viewport, sizeof(int[4])); - - if (stroke->vc.obact->sculpt && stroke->vc.obact->sculpt->pbvh && sculpt_stroke_get_location(C, stroke, location, window)) { - *pixel_radius = project_brush_radius(stroke->vc.rv3d, brush_unprojected_radius(stroke->brush), location, &stroke->mats); + if(stroke->vc.obact->sculpt && stroke->vc.obact->sculpt->pbvh && + sculpt_stroke_get_location(C, stroke, location, window)) { + *pixel_radius = project_brush_radius(stroke->vc.rv3d, + brush_unprojected_radius(stroke->brush), + location, &stroke->mats); if (*pixel_radius == 0) *pixel_radius = brush_size(stroke->brush); @@ -514,58 +400,174 @@ int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, floa return hit; } -// XXX duplicated from sculpt.c -float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset) +/* Draw an overlay that shows what effect the brush's texture will + have on brush strength */ +/* TODO: sculpt only for now */ +static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, + ViewContext *vc, int x, int y) { - float delta[3], scale, loc[3]; + rctf quad; + + /* check for overlay mode */ + if(!(brush->flag & BRUSH_TEXTURE_OVERLAY) || + !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED))) + return; + + /* save lots of GL state + TODO: check on whether all of these are needed? */ + glPushAttrib(GL_COLOR_BUFFER_BIT| + GL_CURRENT_BIT| + GL_DEPTH_BUFFER_BIT| + GL_ENABLE_BIT| + GL_LINE_BIT| + GL_POLYGON_BIT| + GL_STENCIL_BUFFER_BIT| + GL_TRANSFORM_BIT| + GL_VIEWPORT_BIT| + GL_TEXTURE_BIT); + + if(load_tex(sd, brush, vc)) { + glEnable(GL_BLEND); - mul_v3_m4v3(loc, ob->obmat, center); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glDepthMask(GL_FALSE); + glDepthFunc(GL_ALWAYS); + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + + if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + /* brush rotation */ + glTranslatef(0.5f, 0.5f, 0); + glRotatef(((brush->flag & BRUSH_RAKE) ? + sd->last_angle : sd->special_rotation) * (180.0f/M_PI), + 0, 0, 1); + glTranslatef(-0.5f, -0.5f, 0); + + /* scale based on tablet pressure */ + if(sd->draw_pressure && brush_use_size_pressure(brush)) { + glTranslatef(0.5f, 0.5f, 0); + glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1); + glTranslatef(-0.5f, -0.5f, 0); + } - initgrabz(vc->rv3d, loc[0], loc[1], loc[2]); - window_to_3d_delta(vc->ar, delta, offset, 0); + if(sd->draw_anchored) { + const float *aim = sd->anchored_initial_mouse; + const rcti *win = &vc->ar->winrct; + quad.xmin = aim[0]-sd->anchored_size - win->xmin; + quad.ymin = aim[1]-sd->anchored_size - win->ymin; + quad.xmax = aim[0]+sd->anchored_size - win->xmin; + quad.ymax = aim[1]+sd->anchored_size - win->ymin; + } + else { + const int radius= brush_size(brush); + quad.xmin = x - radius; + quad.ymin = y - radius; + quad.xmax = x + radius; + quad.ymax = y + radius; + } + } + else { + quad.xmin = 0; + quad.ymin = 0; + quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin; + quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin; + } - scale= fabsf(mat4_to_scale(ob->obmat)); - scale= (scale == 0.0f)? 1.0f: scale; + /* set quad color */ + glColor4f(U.sculpt_paint_overlay_col[0], + U.sculpt_paint_overlay_col[1], + U.sculpt_paint_overlay_col[2], + brush->texture_overlay_alpha / 100.0f); + + /* draw textured quad */ + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(quad.xmin, quad.ymin); + glTexCoord2f(1, 0); + glVertex2f(quad.xmax, quad.ymin); + glTexCoord2f(1, 1); + glVertex2f(quad.xmax, quad.ymax); + glTexCoord2f(0, 1); + glVertex2f(quad.xmin, quad.ymax); + glEnd(); + + glPopMatrix(); + } - return len_v3(delta)/scale; + glPopAttrib(); } -// XXX paint cursor now does a lot of the same work that is needed during a sculpt stroke -// problem: all this stuff was not intended to be used at this point, so things feel a -// bit hacked. I've put lots of stuff in Brush that probably better goes in Paint -// Functions should be refactored so that they can be used between sculpt.c and -// paint_stroke.c clearly and optimally and the lines of communication between the -// two modules should be more clearly defined. -static void paint_draw_cursor(bContext *C, int x, int y, void *unused) +/* Special actions taken when paint cursor goes over mesh */ +/* TODO: sculpt only for now */ +static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, + float location[3], float *visual_strength) { - ViewContext vc; + float unprojected_radius, projected_radius; - (void)unused; - - view3d_set_viewcontext(C, &vc); + /* TODO: check whether this should really only be done when + brush is over mesh? */ + if(sd->draw_pressure && brush_use_alpha_pressure(brush)) + (*visual_strength) *= sd->pressure_value; - if (vc.obact->sculpt) { - Paint *paint = paint_get_active(CTX_data_scene(C)); - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - Brush *brush = paint_brush(paint); - - int pixel_radius, viewport[4]; - float location[3], modelview[16], projection[16]; + if(sd->draw_anchored) + projected_radius = sd->anchored_size; + else { + if(brush->flag & BRUSH_ANCHORED) + projected_radius = 8; + else + projected_radius = brush_size(brush); + } + unprojected_radius = paint_calc_object_space_radius(vc, location, + projected_radius); - int hit; + if(sd->draw_pressure && brush_use_size_pressure(brush)) + unprojected_radius *= sd->pressure_value; - int flip; - int sign; + if(!brush_use_locked_size(brush)) + brush_set_unprojected_radius(brush, unprojected_radius); +} - float* col; - float alpha; +static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) +{ + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(paint); + ViewContext vc; + float final_radius; + float translation[2]; + float outline_alpha, *outline_col; + + /* set various defaults */ + translation[0] = x; + translation[1] = y; + outline_alpha = 0.5; + outline_col = brush->add_col; + final_radius = brush_size(brush); + + /* check that brush drawing is enabled */ + if(!(paint->flags & PAINT_SHOW_BRUSH)) + return; + + /* can't use stroke vc here because this will be called during + mouse over too, not just during a stroke */ + view3d_set_viewcontext(C, &vc); + /* TODO: as sculpt and other paint modes are unified, this + special mode of drawing will go away */ + if(vc.obact->sculpt) { + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + float location[3]; + int pixel_radius, hit; const float root_alpha = brush_alpha(brush); float visual_strength = root_alpha*root_alpha; - const float min_alpha = 0.20f; const float max_alpha = 0.80f; + /* this is probably here so that rake takes into + account the brush movements before the stroke + starts, but this doesn't really belong in draw code + (TODO) */ { const float u = 0.5f; const float v = 1 - u; @@ -574,7 +576,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused) const float dx = sd->last_x - x; const float dy = sd->last_y - y; - if (dx*dx + dy*dy >= r*r) { + if(dx*dx + dy*dy >= r*r) { sd->last_angle = atan2(dx, dy); sd->last_x = u*sd->last_x + v*x; @@ -582,252 +584,106 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused) } } - if(!brush_use_locked_size(brush) && !(paint->flags & PAINT_SHOW_BRUSH)) - return; + /* test if brush is over the mesh */ + hit = sculpt_get_brush_geometry(C, x, y, &pixel_radius, location); - hit = sculpt_get_brush_geometry(C, x, y, &pixel_radius, location, modelview, projection, viewport); + /* draw overlay */ + paint_draw_alpha_overlay(sd, brush, &vc, x, y); - if (brush_use_locked_size(brush)) + if(brush_use_locked_size(brush)) brush_set_size(brush, pixel_radius); - // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke - flip = 1; - - sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1); - - if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) - col = brush->sub_col; - else - col = brush->add_col; - - alpha = (paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) ? min_alpha + (visual_strength*(max_alpha-min_alpha)) : 0.50f; - - if (ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED) && brush->flag & BRUSH_TEXTURE_OVERLAY) { - glPushAttrib( - GL_COLOR_BUFFER_BIT| - GL_CURRENT_BIT| - GL_DEPTH_BUFFER_BIT| - GL_ENABLE_BIT| - GL_LINE_BIT| - GL_POLYGON_BIT| - GL_STENCIL_BUFFER_BIT| - GL_TRANSFORM_BIT| - GL_VIEWPORT_BIT| - GL_TEXTURE_BIT); - - if (load_tex(sd, brush, &vc)) { - glEnable(GL_BLEND); - - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glDepthMask(GL_FALSE); - glDepthFunc(GL_ALWAYS); - - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glLoadIdentity(); - - if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { - glTranslatef(0.5f, 0.5f, 0); - - if (brush->flag & BRUSH_RAKE) { - glRotatef(sd->last_angle*(float)(180.0/M_PI), 0, 0, 1); - } - else { - glRotatef(sd->special_rotation*(float)(180.0/M_PI), 0, 0, 1); - } - - glTranslatef(-0.5f, -0.5f, 0); - - if (sd->draw_pressure && brush_use_size_pressure(brush)) { - glTranslatef(0.5f, 0.5f, 0); - glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1); - glTranslatef(-0.5f, -0.5f, 0); - } - } - - glColor4f( - U.sculpt_paint_overlay_col[0], - U.sculpt_paint_overlay_col[1], - U.sculpt_paint_overlay_col[2], - brush->texture_overlay_alpha / 100.0f); - - glBegin(GL_QUADS); - if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { - if (sd->draw_anchored) { - glTexCoord2f(0, 0); - glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]-sd->anchored_size - vc.ar->winrct.ymin); - - glTexCoord2f(1, 0); - glVertex2f(sd->anchored_initial_mouse[0]+sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]-sd->anchored_size - vc.ar->winrct.ymin); - - glTexCoord2f(1, 1); - glVertex2f(sd->anchored_initial_mouse[0]+sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc.ar->winrct.ymin); - - glTexCoord2f(0, 1); - glVertex2f(sd->anchored_initial_mouse[0]-sd->anchored_size - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1]+sd->anchored_size - vc.ar->winrct.ymin); - } - else { - const int radius= brush_size(brush); - - glTexCoord2f(0, 0); - glVertex2f((float)x-radius, (float)y-radius); - - glTexCoord2f(1, 0); - glVertex2f((float)x+radius, (float)y-radius); - - glTexCoord2f(1, 1); - glVertex2f((float)x+radius, (float)y+radius); - - glTexCoord2f(0, 1); - glVertex2f((float)x-radius, (float)y+radius); - } - } - else { - glTexCoord2f(0, 0); - glVertex2f(0, 0); - - glTexCoord2f(1, 0); - glVertex2f(viewport[2], 0); - - glTexCoord2f(1, 1); - glVertex2f(viewport[2], viewport[3]); - - glTexCoord2f(0, 1); - glVertex2f(0, viewport[3]); - } - glEnd(); - - glPopMatrix(); - } - - glPopAttrib(); + /* check if brush is subtracting, use different color then */ + /* TODO: no way currently to know state of pen flip or + invert key modifier without starting a stroke */ + if((!(brush->flag & BRUSH_INVERTED) ^ + !(brush->flag & BRUSH_DIR_IN)) && + ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW, + SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, + SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE)) + outline_col = brush->sub_col; + + /* only do if brush is over the mesh */ + if(hit) + paint_cursor_on_hit(sd, brush, &vc, location, &visual_strength); + + /* don't show effect of strength past the soft limit */ + if(visual_strength > 1) + visual_strength = 1; + + outline_alpha = ((paint->flags & PAINT_SHOW_BRUSH_ON_SURFACE) ? + min_alpha + (visual_strength*(max_alpha-min_alpha)) : 0.50f); + + if(sd->draw_anchored) { + final_radius = sd->anchored_size; + translation[0] = sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin; + translation[1] = sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin; } + } - if (hit) { - float unprojected_radius; - - // XXX duplicated from brush_strength & paint_stroke_add_step, refactor later - //wmEvent* event = CTX_wm_window(C)->eventstate; - - if (sd->draw_pressure && brush_use_alpha_pressure(brush)) - visual_strength *= sd->pressure_value; - - // don't show effect of strength past the soft limit - if (visual_strength > 1) visual_strength = 1; - - if (sd->draw_anchored) { - unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, sd->anchored_size); - } - else { - if (brush->flag & BRUSH_ANCHORED) - unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, 8); - else - unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, brush_size(brush)); - } - - if (sd->draw_pressure && brush_use_size_pressure(brush)) - unprojected_radius *= sd->pressure_value; - - if (!brush_use_locked_size(brush)) - brush_set_unprojected_radius(brush, unprojected_radius); - - if(!(paint->flags & PAINT_SHOW_BRUSH)) - return; - - } + /* make lines pretty */ + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); - glPushAttrib( - GL_COLOR_BUFFER_BIT| - GL_CURRENT_BIT| - GL_DEPTH_BUFFER_BIT| - GL_ENABLE_BIT| - GL_LINE_BIT| - GL_POLYGON_BIT| - GL_STENCIL_BUFFER_BIT| - GL_TRANSFORM_BIT| - GL_VIEWPORT_BIT| - GL_TEXTURE_BIT); + /* set brush color */ + glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha); - glColor4f(col[0], col[1], col[2], alpha); + /* draw brush outline */ + glTranslatef(translation[0], translation[1], 0); + glutil_draw_lined_arc(0.0, M_PI*2.0, final_radius, 40); + glTranslatef(-translation[0], -translation[1], 0); - glEnable(GL_BLEND); + /* restore GL state */ + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); +} - glEnable(GL_LINE_SMOOTH); +/* if this is a tablet event, return tablet pressure and set *pen_flip + to 1 if the eraser tool is being used, 0 otherwise */ +static float event_tablet_data(wmEvent *event, int *pen_flip) +{ + int erasor = 0; + float pressure = 1; - if (sd->draw_anchored) { - glTranslatef(sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin, sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, sd->anchored_size, 40); - glTranslatef(-sd->anchored_initial_mouse[0] + vc.ar->winrct.xmin, -sd->anchored_initial_mouse[1] + vc.ar->winrct.xmin, 0.0f); - } - else { - glTranslatef((float)x, (float)y, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, brush_size(brush), 40); - glTranslatef(-(float)x, -(float)y, 0.0f); - } + if(event->custom == EVT_DATA_TABLET) { + wmTabletData *wmtab= event->customdata; - glPopAttrib(); + erasor = (wmtab->Active == EVT_TABLET_ERASER); + pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1; } - else { - Paint *paint = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(paint); - - if(!(paint->flags & PAINT_SHOW_BRUSH)) - return; - - glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], 0.5f); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glTranslatef((float)x, (float)y, 0.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, brush_size(brush), 40); // XXX: for now use the brushes size instead of potentially using the unified size because the feature has been enabled for sculpt - glTranslatef((float)-x, (float)-y, 0.0f); + if(pen_flip) + (*pen_flip) = erasor; - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); - } + return pressure; } /* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2]) { - Paint *paint = paint_get_active(CTX_data_scene(C)); // XXX - Brush *brush = paint_brush(paint); // XXX - + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(paint); + PaintStroke *stroke = op->customdata; float mouse[3]; - PointerRNA itemptr; - float location[3]; - float pressure; - int pen_flip; - - ViewContext vc; // XXX - - PaintStroke *stroke = op->customdata; - - view3d_set_viewcontext(C, &vc); // XXX - - /* Tablet */ - if(event->custom == EVT_DATA_TABLET) { - wmTabletData *wmtab= event->customdata; + int pen_flip; - pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1; - pen_flip = (wmtab->Active == EVT_TABLET_ERASER); - } - else { - pressure = 1; - pen_flip = 0; - } + /* see if tablet affects event */ + pressure = event_tablet_data(event, &pen_flip); - // XXX: temporary check for sculpt mode until things are more unified - if (vc.obact->sculpt) { + /* TODO: as sculpt and other paint modes are unified, this + separation will go away */ + if(stroke->vc.obact->sculpt) { float delta[3]; brush_jitter_pos(brush, mouse_in, mouse); - // XXX: meh, this is round about because brush_jitter_pos isn't written in the best way to be reused here - if (brush->flag & BRUSH_JITTER_PRESSURE) { + /* XXX: meh, this is round about because + brush_jitter_pos isn't written in the best way to + be reused here */ + if(brush->flag & BRUSH_JITTER_PRESSURE) { sub_v3_v3v3(delta, mouse, mouse_in); mul_v3_fl(delta, pressure); add_v3_v3v3(mouse, mouse_in, delta); @@ -836,7 +692,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev else copy_v3_v3(mouse, mouse_in); - /* XXX: can remove the if statement once all modes have this */ + /* TODO: can remove the if statement once all modes have this */ if(stroke->get_location) stroke->get_location(C, stroke, location, mouse); else @@ -845,10 +701,10 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* Add to stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - RNA_float_set_array(&itemptr, "location", location); - RNA_float_set_array(&itemptr, "mouse", mouse); - RNA_boolean_set (&itemptr, "pen_flip", pen_flip); - RNA_float_set (&itemptr, "pressure", pressure); + RNA_float_set_array(&itemptr, "location", location); + RNA_float_set_array(&itemptr, "mouse", mouse); + RNA_boolean_set(&itemptr, "pen_flip", pen_flip); + RNA_float_set(&itemptr, "pressure", pressure); stroke->last_mouse_position[0] = mouse[0]; stroke->last_mouse_position[1] = mouse[1]; @@ -910,15 +766,9 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const if(length > FLT_EPSILON) { int steps; int i; - float pressure = 1; - - // XXX duplicate code - if(event->custom == EVT_DATA_TABLET) { - wmTabletData *wmtab= event->customdata; - if(wmtab->Active != EVT_TABLET_NONE) - pressure = brush_use_size_pressure(stroke->brush) ? wmtab->Pressure : 1; - } + float pressure; + pressure = event_tablet_data(event, NULL); scale = (brush_size(stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length; mul_v2_fl(vec, scale); diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index 643e2cd6915..758ef2a2fc1 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -27,11 +27,12 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" + #include "DNA_userdef_types.h" -#include "BLI_listbase.h" -#include "BKE_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 6e158fe2e66..da8eff6c581 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -9,18 +9,22 @@ #include "DNA_scene_types.h" #include "DNA_brush_types.h" -#include "RNA_access.h" -#include "RNA_define.h" - #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_brush.h" #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_paint.h" +#include "RNA_access.h" +#include "RNA_define.h" #include "BIF_gl.h" +/* TODO: remove once projectf goes away */ +#include "BIF_glutil.h" + +#include "RE_shader_ext.h" #include "ED_view3d.h" #include "ED_screen.h" @@ -33,6 +37,55 @@ #include "paint_intern.h" +/* convert a point in model coordinates to 2D screen coordinates */ +/* TODO: can be deleted once all calls are replaced with + view3d_project_float() */ +void projectf(bglMats *mats, const float v[3], float p[2]) +{ + double ux, uy, uz; + + gluProject(v[0],v[1],v[2], mats->modelview, mats->projection, + (GLint *)mats->viewport, &ux, &uy, &uz); + p[0]= ux; + p[1]= uy; +} + +float paint_calc_object_space_radius(ViewContext *vc, float center[3], + float pixel_radius) +{ + Object *ob = vc->obact; + float delta[3], scale, loc[3]; + + mul_v3_m4v3(loc, ob->obmat, center); + + initgrabz(vc->rv3d, loc[0], loc[1], loc[2]); + window_to_3d_delta(vc->ar, delta, pixel_radius, 0); + + scale= fabsf(mat4_to_scale(ob->obmat)); + scale= (scale == 0.0f)? 1.0f: scale; + + return len_v3(delta)/scale; +} + +float paint_get_tex_pixel(Brush* br, float u, float v) +{ + TexResult texres; + float co[3]; + int hasrgb; + + co[0] = u; + co[1] = v; + co[2] = 0; + + memset(&texres, 0, sizeof(TexResult)); + hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 1, &texres); + + if (hasrgb & TEX_RGB) + texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb)*texres.ta; + + return texres.tin; +} + /* 3D Paint */ static void imapaint_project(Object *ob, float *model, float *proj, float *co, float *pco) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 39768a010a8..a62f01e88f0 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "IMB_imbuf.h" @@ -273,7 +274,7 @@ static void make_vertexcol(Object *ob) /* single ob */ memset(me->mcol, 255, 4*sizeof(MCol)*me->totface); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); } @@ -334,7 +335,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol) } } - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); } @@ -448,7 +449,7 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) MEM_freeN(indexar); copy_wpaint_prev(wp, NULL, 0); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); } /* XXX: should be re-implemented as a vertex/weight paint 'color correct' operator @@ -925,7 +926,7 @@ void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int mode) val= 0; // XXX pupmenu(str); if(val>=0) { ob->actdef= val+1; - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); } MEM_freeN(str); } @@ -1080,7 +1081,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ * exit (exit needs doing regardless because we * should redeform). */ - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); if(ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par; @@ -1588,7 +1589,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); - DAG_id_tag_update(ob->data, OB_RECALC_DATA); + DAG_id_tag_update(ob->data, 0); ED_region_tag_redraw(vc->ar); } @@ -1627,7 +1628,7 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) } } - DAG_id_tag_update(ob->data, OB_RECALC_DATA); + DAG_id_tag_update(ob->data, 0); } @@ -1729,7 +1730,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ if (me) /* update modifier stack for mapping requirements */ - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_SCENE|ND_MODE, scene); @@ -1905,7 +1906,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P ED_region_tag_redraw(vc->ar); - DAG_id_tag_update(ob->data, OB_RECALC_DATA); + DAG_id_tag_update(ob->data, 0); } static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke) @@ -1975,7 +1976,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); - DAG_id_tag_update(&me->id, OB_RECALC_DATA); + DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); return OPERATOR_FINISHED; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 55c7247650a..6429a70515b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -34,6 +34,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_dynstr.h" #include "BLI_ghash.h" #include "BLI_pbvh.h" @@ -58,7 +59,6 @@ #include "BKE_paint.h" #include "BKE_report.h" -#include "BIF_gl.h" #include "BIF_glutil.h" #include "WM_api.h" @@ -71,9 +71,7 @@ #include "RNA_access.h" #include "RNA_define.h" - #include "RE_render_ext.h" -#include "RE_shader_ext.h" #include "GPU_buffers.h" @@ -85,10 +83,6 @@ #include <omp.h> #endif -/* ==== FORWARD DEFINITIONS ===== - * - */ - void ED_sculpt_force_update(bContext *C) { Object *ob= CTX_data_active_object(C); @@ -152,10 +146,6 @@ int sculpt_modifiers_active(Scene *scene, Object *ob) return 0; } -/* ===== STRUCTS ===== - * - */ - typedef enum StrokeFlags { CLIP_X = 1, CLIP_Y = 2, @@ -226,32 +216,6 @@ typedef struct StrokeCache { float plane_trim_squared; } StrokeCache; -/* ===== OPENGL ===== - * - * Simple functions to get data from the GL - */ - -/* Convert a point in model coordinates to 2D screen coordinates. */ -static void projectf(bglMats *mats, const float v[3], float p[2]) -{ - double ux, uy, uz; - - gluProject(v[0],v[1],v[2], mats->modelview, mats->projection, - (GLint *)mats->viewport, &ux, &uy, &uz); - p[0]= ux; - p[1]= uy; -} - -/*XXX: static void project(bglMats *mats, const float v[3], short p[2]) -{ - float f[2]; - projectf(mats, v, f); - - p[0]= f[0]; - p[1]= f[1]; -} -*/ - /*** BVH Tree ***/ /* Get a screen-space rectangle of the modified area */ @@ -648,66 +612,6 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) } } -float get_tex_pixel(Brush* br, float u, float v) -{ - TexResult texres; - float co[3]; - int hasrgb; - - co[0] = u; - co[1] = v; - co[2] = 0; - - memset(&texres, 0, sizeof(TexResult)); - hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 1, &texres); - - if (hasrgb & TEX_RGB) - texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb)*texres.ta; - - return texres.tin; -} - -#if 0 - -/* Get a pixel from the texcache at (px, py) */ -static unsigned char get_texcache_pixel(const SculptSession *ss, int px, int py) -{ - unsigned *p; - p = ss->texcache + py * ss->texcache_side + px; - return ((unsigned char*)(p))[0]; -} - -static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float v) -{ - unsigned x, y, x2, y2; - const int tc_max = ss->texcache_side - 1; - float urat, vrat, uopp; - - if(u < 0) u = 0; - else if(u >= ss->texcache_side) u = tc_max; - if(v < 0) v = 0; - else if(v >= ss->texcache_side) v = tc_max; - - x = floor(u); - y = floor(v); - x2 = x + 1; - y2 = y + 1; - - if(x2 > ss->texcache_side) x2 = tc_max; - if(y2 > ss->texcache_side) y2 = tc_max; - - urat = u - x; - vrat = v - y; - uopp = 1 - urat; - - return ((get_texcache_pixel(ss, x, y) * uopp + - get_texcache_pixel(ss, x2, y) * urat) * (1 - vrat) + - (get_texcache_pixel(ss, x, y2) * uopp + - get_texcache_pixel(ss, x2, y2) * urat) * vrat) / 255.0; -} - -#endif - /* Return a multiplier for brush strength on a particular vertex. */ static float tex_strength(SculptSession *ss, Brush *br, float *point, const float len) { @@ -791,7 +695,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa x += br->mtex.ofs[0]; y += br->mtex.ofs[1]; - avg = get_tex_pixel(br, x, y); + avg = paint_get_tex_pixel(br, x, y); } avg += br->texture_sample_bias; @@ -2813,21 +2717,6 @@ static void SCULPT_OT_radial_control(wmOperatorType *ot) /**** Operator for applying a stroke (various attributes including mouse path) using the current brush. ****/ -static float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset) -{ - float delta[3], scale, loc[3]; - - mul_v3_m4v3(loc, ob->obmat, center); - - initgrabz(vc->rv3d, loc[0], loc[1], loc[2]); - window_to_3d_delta(vc->ar, delta, offset, 0); - - scale= fabsf(mat4_to_scale(ob->obmat)); - scale= (scale == 0.0f)? 1.0f: scale; - - return len_v3(delta)/scale; -} - static void sculpt_cache_free(StrokeCache *cache) { if(cache->face_norms) @@ -2901,8 +2790,13 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio } mode = RNA_int_get(op->ptr, "mode"); - cache->invert = mode == WM_BRUSHSTROKE_INVERT; - cache->alt_smooth = mode == WM_BRUSHSTROKE_SMOOTH; + cache->invert = mode == BRUSH_STROKE_INVERT; + cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH; + + /* not very nice, but with current events system implementation + we can't handle brush appearance inversion hotkey separately (sergey) */ + if(cache->invert) brush->flag |= BRUSH_INVERTED; + else brush->flag &= ~BRUSH_INVERTED; /* Alt-Smooth */ if (ss->cache->alt_smooth) { @@ -3075,7 +2969,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession if(cache->first_time) { if (!brush_use_locked_size(brush)) { - cache->initial_radius= unproject_brush_radius(ss->ob, cache->vc, cache->true_location, brush_size(brush)); + cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(brush)); brush_set_unprojected_radius(brush, cache->initial_radius); } else { @@ -3137,7 +3031,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession if (!hit) copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); - cache->radius= unproject_brush_radius(ss->ob, paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius); + cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius); cache->radius_squared = cache->radius*cache->radius; copy_v3_v3(sd->anchored_location, cache->true_location); @@ -3452,14 +3346,17 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *unused) /* Finished */ if(ss->cache) { + Brush *brush= paint_brush(&sd->paint); + brush->flag &= ~BRUSH_INVERTED; + sculpt_stroke_modifiers_check(C, ss); /* Alt-Smooth */ if (ss->cache->alt_smooth) { Paint *p= &sd->paint; - Brush *br= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); - if(br) { - paint_brush_set(p, br); + brush= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); + if(brush) { + paint_brush_set(p, brush); } } @@ -3541,10 +3438,10 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) static void SCULPT_OT_brush_stroke(wmOperatorType *ot) { static EnumPropertyItem stroke_mode_items[] = { - { WM_BRUSHSTROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally" }, - { WM_BRUSHSTROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke" }, - { WM_BRUSHSTROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke" }, - { 0 } + {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"}, + {BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"}, + {BRUSH_STROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke"}, + {0} }; /* identifiers */ @@ -3565,7 +3462,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); - RNA_def_enum(ot->srna, "mode", stroke_mode_items, WM_BRUSHSTROKE_NORMAL, + RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Sculpt Stroke Mode", "Action taken when a sculpt stroke is made"); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 7c6db939a11..a48d6d8d9c9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -55,7 +55,6 @@ void sculpt_radialcontrol_start(int mode); struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob); struct Brush *sculptmode_brush(void); -//void do_symmetrical_brush_actions(struct Sculpt *sd, struct wmOperator *wm, struct BrushAction *a, short *, short *); void sculpt(Sculpt *sd); @@ -70,9 +69,6 @@ void sculpt_stroke_apply(struct Sculpt *sd, struct SculptStroke *); void sculpt_stroke_apply_all(struct Sculpt *sd, struct SculptStroke *); int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float out[3], float mouse[2]); -/* Partial Mesh Visibility */ -void sculptmode_pmv(int mode); - /* Undo */ typedef struct SculptUndoNode { @@ -110,6 +106,4 @@ void sculpt_undo_push_end(void); int sculpt_modifiers_active(Scene *scene, Object *ob); void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]); -void brush_jitter_pos(struct Brush *brush, float *pos, float *jitterpos); - #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c9912936399..a8fee6ea39d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -33,6 +33,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_threads.h" diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 80d0b0f8815..cd6c7e4305d 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -32,6 +32,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "DNA_packedFile_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" @@ -45,9 +48,6 @@ #include "BKE_packedFile.h" #include "BKE_sound.h" -#include "BLI_blenlib.h" - - #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index cf515a25020..4dc77e13192 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -34,9 +34,9 @@ #include <string.h> #include <float.h> - #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" /* Types --------------------------------------------------------------- */ @@ -45,7 +45,7 @@ #include "BKE_action.h" #include "BKE_context.h" -#include "BKE_utildefines.h" + /* Everything from source (BIF, BDR, BSE) ------------------------------ */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index afda04d1c45..7756075b292 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -57,6 +58,7 @@ #include "ED_keyframes_edit.h" #include "ED_screen.h" #include "ED_transform.h" +#include "ED_markers.h" #include "WM_api.h" #include "WM_types.h" @@ -1298,13 +1300,7 @@ static void mirror_action_keys(bAnimContext *ac, short mode) TimeMarker *marker= NULL; /* find first selected marker */ - if (ac->markers) { - for (marker= ac->markers->first; marker; marker=marker->next) { - if (marker->flag & SELECT) { - break; - } - } - } + marker= ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 2d47424dc99..26990878e46 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -34,6 +34,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 678558e6450..031743953ec 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -456,7 +457,7 @@ void ED_spacetype_action(void) art->init= action_main_area_init; art->draw= action_main_area_draw; art->listener= action_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D/*|ED_KEYMAP_MARKERS*/|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 0d0d3713723..0aac167fed2 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -25,12 +25,14 @@ #include <stdlib.h> #include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_object_types.h" #include "DNA_windowmanager_types.h" -#include "BKE_utildefines.h" + #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 2d16bb6bc81..b0b1c23cbc0 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -30,6 +30,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" + #include "DNA_armature_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" @@ -38,8 +41,6 @@ #include "DNA_world_types.h" #include "DNA_brush_types.h" -#include "BLI_listbase.h" - #include "BKE_context.h" #include "BKE_action.h" #include "BKE_material.h" @@ -48,7 +49,7 @@ #include "BKE_particle.h" #include "BKE_screen.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 9071d9f27d9..bd1674aa307 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -29,11 +29,10 @@ #include <string.h> #include <stdio.h> - - #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_context.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 18e906e7dc2..b7c9bdde0e8 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -36,6 +36,7 @@ #include "BLI_path_util.h" #include "BLI_storage.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 87c50936f90..b33231f190c 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -29,12 +29,12 @@ #include <string.h> #include <stdio.h> - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -69,7 +69,7 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) BLI_addtail(&sbuts->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->alignment= RGN_ALIGN_TOP; #if 0 /* context area */ @@ -259,6 +259,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) switch(wmn->data) { case ND_TRANSFORM: buttons_area_redraw(sa, BCONTEXT_OBJECT); + buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ break; case ND_POSE: case ND_BONE_ACTIVE: @@ -347,6 +348,10 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) break; } break; + case NC_NODE: + if(wmn->action==NA_SELECTED) + ED_area_tag_redraw(sa); + break; /* Listener for preview render, when doing an global undo. */ case NC_WINDOW: ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 0bb0d78a497..2d4501e6005 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -28,17 +28,16 @@ #include <sys/stat.h> #include <limits.h> - #include "BLF_api.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" -// #include "BKE_suggestions.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 405c965ecce..05c3561d25e 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -33,6 +33,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_text.h" /* only for character utility funcs */ @@ -657,11 +658,12 @@ static int scrollback_append_exec(bContext *C, wmOperator *op) { SpaceConsole *sc= CTX_wm_space_console(C); ARegion *ar= CTX_wm_region(C); - - ConsoleLine *ci= console_history_verify(C); + ConsoleLine *ci; char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */ int type= RNA_enum_get(op->ptr, "type"); + + console_history_verify(C); ci= console_scrollback_add_str(sc, str, 1); /* own the string */ ci->type= type; @@ -702,7 +704,6 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot) static int copy_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceConsole *sc= CTX_wm_space_console(C); - int buf_len; DynStr *buf_dyn= BLI_dynstr_new(); char *buf_str; @@ -755,7 +756,7 @@ static int copy_exec(bContext *C, wmOperator *UNUSED(op)) } buf_str= BLI_dynstr_get_cstring(buf_dyn); - buf_len= BLI_dynstr_get_len(buf_dyn); + BLI_dynstr_free(buf_dyn); WM_clipboard_text_set(buf_str, 0); @@ -792,7 +793,6 @@ static int paste_exec(bContext *C, wmOperator *UNUSED(op)) if(buf_str==NULL) return OPERATOR_CANCELLED; - buf_next= buf_str; buf_step= buf_str; while((buf_next=buf_step) && buf_next[0] != '\0') { diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 4fbe96c0e54..c44d13aa058 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -33,6 +33,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -42,7 +43,6 @@ #include "BIF_gl.h" - #include "RNA_access.h" #include "WM_api.h" diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index ece227494c6..84090c88abc 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -30,6 +30,7 @@ #include <string.h> #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_dynstr.h" #include "BLI_storage_types.h" #ifdef WIN32 diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 2e8db0dc998..dc550d84e4d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -33,6 +33,7 @@ #include "BKE_main.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_storage_types.h" #ifdef WIN32 #include "BLI_winstuff.h" @@ -260,7 +261,6 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); SpaceFile *sfile= CTX_wm_space_file(C); - short val; rcti rect; int extend = RNA_boolean_get(op->ptr, "extend"); int fill = RNA_boolean_get(op->ptr, "fill"); @@ -270,7 +270,6 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) rect.xmin = rect.xmax = event->x - ar->winrct.xmin; rect.ymin = rect.ymax = event->y - ar->winrct.ymin; - val = event->val; if(!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 4d9bd9bf54a..f9c467a039d 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -30,6 +30,7 @@ #include "BKE_screen.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index ce4b5bdd4de..e16b2f650eb 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -46,6 +46,7 @@ #include "BLI_linklist.h" #include "BLI_storage_types.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #ifdef WIN32 #include "BLI_winstuff.h" diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index d55fcd7d8ba..9e29967a792 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -62,6 +62,7 @@ #include "BLI_path_util.h" #include "BLI_storage_types.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 12cca144d80..b8ffc73caf0 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -42,6 +42,7 @@ #include "BLI_math.h" #include "BLI_rand.h" #include "BLI_storage_types.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index d34ef74b66a..c937ebca547 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_depsgraph.h" diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 08e3870f8a2..b2e9f93685e 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -48,7 +49,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_fcurve.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 3602977bfa3..154c955c48e 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -60,6 +61,7 @@ #include "ED_keyframes_edit.h" #include "ED_screen.h" #include "ED_transform.h" +#include "ED_markers.h" #include "WM_api.h" #include "WM_types.h" @@ -1769,13 +1771,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) TimeMarker *marker= NULL; /* find first selected marker */ - if (ac->markers) { - for (marker= ac->markers->first; marker; marker=marker->next) { - if (marker->flag & SELECT) { - break; - } - } - } + marker= ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 1939de69e14..4f529df24dc 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -29,11 +29,11 @@ #include <stdlib.h> #include <math.h> - #include "DNA_scene_types.h" #include "DNA_anim_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_sound.h" diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 05fcb3c6bf8..58a5f4b113e 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -33,6 +33,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index ff2d233ccdb..37d58e5591b 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" @@ -538,24 +539,22 @@ static void graph_refresh(const bContext *C, ScrArea *sa) /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. * TODO: find a way to module the hue so that not all curves have same color... */ - - /* standard table of colors to use */ - const float _colorsets[4][3]= - { - {1.0f, 0.0f, 0.0f}, /* red */ - {0.0f, 1.0f, 0.0f}, /* green */ - {0.0f, 0.0f, 1.0f}, /* blue */ - {0.3f, 0.8f, 1.0f}, /* 'unknown' color - bluish so as to not conflict with handles */ - }; - - /* simply copy the relevant color over to the F-Curve */ - if ((fcu->array_index >= 0) && (fcu->array_index < 3)) { - /* if the index is within safe bounds, use index to access table */ - VECCOPY(fcu->color, _colorsets[fcu->array_index]); - } - else { - /* use the 'unknown' color... */ - VECCOPY(fcu->color, _colorsets[3]); + float *col= fcu->color; + + switch(fcu->array_index) { + case 0: + col[0]= 1.0f; col[1]= 0.0f; col[2]= 0.0f; + break; + case 1: + col[0]= 0.0f; col[1]= 1.0f; col[2]= 0.0f; + break; + case 2: + col[0]= 0.0f; col[1]= 0.0f; col[2]= 1.0f; + break; + default: + /* 'unknown' color - bluish so as to not conflict with handles */ + col[0]= 0.3f; col[1]= 0.8f; col[2]= 1.0f; + break; } } break; @@ -601,7 +600,7 @@ void ED_spacetype_ipo(void) art->init= graph_main_area_init; art->draw= graph_main_area_draw; art->listener= graph_region_listener; - art->keymapflag= ED_KEYMAP_VIEW2D/*|ED_KEYMAP_MARKERS*/|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 756be43ccc9..7509903246b 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -40,6 +40,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_colortools.h" #include "BKE_context.h" @@ -349,6 +350,8 @@ static void image_panel_curves(const bContext *C, Panel *pa) #if 0 /* 0: disable preview otherwise refresh preview + + XXX if you put this back, also check XXX in image_main_area_draw() */ */ void image_preview_event(int event) { diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 6e7af2cb196..e2d58b1df5f 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -39,7 +39,9 @@ #include "DNA_brush_types.h" #include "PIL_time.h" + #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index 772592875c2..ceb7cda2316 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -33,22 +33,18 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" - #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_context.h" - #include "ED_image.h" #include "WM_types.h" - #include "UI_interface.h" - - #include "image_intern.h" /********************** toolbox operator *********************/ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2b6958e436e..69bbfb78d81 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -32,6 +32,10 @@ #include "MEM_guardedalloc.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "DNA_object_types.h" #include "DNA_node_types.h" #include "DNA_packedFile_types.h" @@ -48,9 +52,6 @@ #include "BKE_report.h" #include "BKE_screen.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" - #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_image/image_render.c b/source/blender/editors/space_image/image_render.c index 5fa0a2de202..d80801f8868 100644 --- a/source/blender/editors/space_image/image_render.c +++ b/source/blender/editors/space_image/image_render.c @@ -28,6 +28,8 @@ #include <stdlib.h> #include <stdio.h> +#include "BLI_utildefines.h" + #include "DNA_screen_types.h" #include "DNA_space_types.h" diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 8b8772c6e28..c911adb0c16 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -39,6 +39,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_colortools.h" #include "BKE_context.h" @@ -391,6 +392,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) simage->iuser.frames= 100; scopes_new(&simage->scopes); + simage->sample_line_hist.height= 100; /* header */ ar= MEM_callocN(sizeof(ARegion), "header for image"); @@ -766,6 +768,9 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) //View2DScrollers *scrollers; float col[3]; + /* XXX not supported yet, disabling for now */ + scene->r.scemode &= ~R_COMP_CROP; + /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index cc5e02c6266..71424bb8384 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -32,17 +32,17 @@ #include <sys/stat.h> #include <limits.h> - #include "BLF_api.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" // #include "BKE_suggestions.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 190814a4da0..a20d3b961c0 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_bpath.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 787d70805c6..46c4c8c2dfe 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -28,9 +28,9 @@ #include "MEM_guardedalloc.h" - #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 7a6e5dad017..cf3607e8fba 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -34,13 +34,14 @@ #include "DNA_meta_types.h" #include "DNA_scene_types.h" +#include "BLI_utildefines.h" + #include "BKE_anim.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_key.h" #include "BKE_mesh.h" #include "BKE_particle.h" -#include "BKE_utildefines.h" #include "ED_armature.h" #include "ED_mesh.h" @@ -91,13 +92,12 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) case OB_SURF: case OB_CURVE: case OB_FONT: { - Curve *cu= ob->data; int tot= 0, totf= 0; stats->totcurve += totob; - if(cu->disp.first) - count_displist(&cu->disp, &tot, &totf); + if(ob->disp.first) + count_displist(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 8bfcad4bab7..80040f55a08 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -29,12 +29,12 @@ #include <string.h> #include <stdio.h> - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index a8452731d68..0f11dee7d5a 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -30,7 +30,9 @@ #include "BLF_api.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 61cb3018424..2148dd289ca 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -23,21 +23,18 @@ * ***** END GPL LICENSE BLOCK ***** */ - #include <string.h> #include <stdio.h> - - #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" - #include "RNA_access.h" #include "RNA_define.h" diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 5c498a59884..cda2aea23fa 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -33,6 +33,7 @@ #include "DNA_actuator_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_main.h" diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index d5450a1369c..b0634ff25c7 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -45,6 +45,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" @@ -5038,9 +5039,9 @@ void logic_buttons(bContext *C, ARegion *ar) else { set_col_actuator(act->type, 1); glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19)); - but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator type"); + /* but= */ uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator type"); // uiButSetFunc(but, old_sca_move_actuator, act, NULL); - but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator name"); + /* but= */ uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act, 0, 0, 0, 0, "Actuator name"); // uiButSetFunc(but, old_sca_move_actuator, act, NULL); uiBlockBeginAlign(block); diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 9a3cac02c50..a945af502a0 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -34,6 +34,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 8d5b981df1a..8069bf74bce 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -33,6 +33,8 @@ #include "DNA_anim_types.h" +#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" #include "BLI_math.h" @@ -211,7 +213,7 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) static void nla_panel_animdata (const bContext *C, Panel *pa) { PointerRNA adt_ptr; - AnimData *adt; + /* AnimData *adt; */ uiLayout *layout= pa->layout; uiLayout *row; uiBlock *block; @@ -219,7 +221,8 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* check context and also validity of pointer */ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) return; - adt= adt_ptr.data; + + /* adt= adt_ptr.data; */ block= uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index cdc51215d85..8f6f5082877 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -35,10 +35,10 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" - #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_nla.h" @@ -173,6 +173,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho case ANIMTYPE_DSARM: case ANIMTYPE_DSMESH: case ANIMTYPE_DSTEX: + case ANIMTYPE_DSLAT: case ANIMTYPE_DSLINESTYLE: { /* sanity checking... */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index eebca82b8d1..43a64f07de5 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -37,11 +37,11 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" - #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "BKE_fcurve.h" #include "BKE_nla.h" diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index e04ef99e6fe..d1417d69ae3 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_fcurve.h" diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 3bff1d4159f..db9255a867b 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" @@ -514,7 +515,7 @@ void ED_spacetype_nla(void) art->init= nla_main_area_init; art->draw= nla_main_area_draw; art->listener= nla_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D/*|ED_KEYMAP_MARKERS*/|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 5ee2b172c7c..85b52312f56 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -33,6 +33,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_node_types.h" #include "DNA_material_types.h" diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 954018bfd4f..69a6029e140 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -31,20 +31,20 @@ #include <math.h> #include <float.h> +#include "MEM_guardedalloc.h" + #include "DNA_node_types.h" #include "DNA_scene_types.h" -#include "MEM_guardedalloc.h" - #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_node.h" #include "BKE_screen.h" - #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 9019b1815a4..5028d1ca1d7 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -40,6 +40,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_depsgraph.h" diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 7db20966a8b..dc2396f0d15 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -40,6 +40,11 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_storage_types.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" #include "BKE_global.h" #include "BKE_image.h" @@ -51,11 +56,6 @@ #include "BKE_texture.h" #include "BKE_report.h" - -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_storage_types.h" - #include "RE_pipeline.h" #include "IMB_imbuf_types.h" @@ -211,6 +211,8 @@ bNode *editnode_get_active(bNodeTree *ntree) void snode_notify(bContext *C, SpaceNode *snode) { + WM_event_add_notifier(C, NC_NODE|NA_EDITED, NULL); + if(snode->treetype==NTREE_SHADER) WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); else if(snode->treetype==NTREE_COMPOSIT) @@ -328,6 +330,7 @@ void ED_node_texture_default(Tex *tx) ntreeSolveOrder(tx->nodetree); /* needed for pointers */ } +/* id is supposed to contain a node tree */ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype) { bNode *node= NULL; @@ -345,6 +348,10 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre *ntree= ((Tex*)id)->nodetree; if(treetype) *treetype= NTREE_TEXTURE; } + else { + if(treetype) *treetype= 0; + return; + } /* find editable group */ if(edittree) { @@ -1464,7 +1471,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float /* generics */ if(node) { node->locx= locx; - node->locy= locy + 60.0f; // arbitrary.. so its visible + node->locy= locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node node->flag |= SELECT; gnode= node_tree_get_editgroup(snode->nodetree); @@ -1515,6 +1522,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ntreeCopyTree(snode->edittree, 1); /* 1 == internally selected nodes */ + /* to ensure redraws or rerenders happen */ + for(node= snode->edittree->nodes.first; node; node= node->next) + if(node->flag & SELECT) + if(node->id) + ED_node_changed_update(snode->id, node); + ntreeSolveOrder(snode->edittree); node_tree_verify_groups(snode->nodetree); snode_notify(C, snode); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 1ad5954b56e..147a0825229 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -37,13 +37,13 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" #include "BKE_node.h" #include "BKE_main.h" - #include "WM_api.h" #include "WM_types.h" @@ -58,8 +58,22 @@ static void do_node_add(bContext *C, void *UNUSED(arg), int event) { SpaceNode *snode= CTX_wm_space_node(C); + ScrArea *sa= CTX_wm_area(C); + ARegion *ar; bNode *node; + /* get location to add node at mouse */ + for(ar=sa->regionbase.first; ar; ar=ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + wmWindow *win= CTX_wm_window(C); + int x= win->eventstate->x - ar->winrct.xmin; + int y= win->eventstate->y - ar->winrct.ymin; + + if(y < 60) y+= 60; + UI_view2d_region_to_view(&ar->v2d, x, y, &snode->mx, &snode->my); + } + } + /* store selection in temp test flag */ for(node= snode->edittree->nodes.first; node; node= node->next) { if(node->flag & NODE_SELECT) node->flag |= NODE_TEST; @@ -152,20 +166,8 @@ static void node_auto_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclas static void node_menu_add(const bContext *C, Menu *menu) { - uiLayout *layout= menu->layout; SpaceNode *snode= CTX_wm_space_node(C); - ScrArea *sa= CTX_wm_area(C); - ARegion *ar; - - /* get location to add node at mouse */ - for(ar=sa->regionbase.first; ar; ar=ar->next) { - if(ar->regiontype == RGN_TYPE_WINDOW) { - wmWindow *win= CTX_wm_window(C); - UI_view2d_region_to_view(&ar->v2d, - win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, - &snode->mx, &snode->my); - } - } + uiLayout *layout= menu->layout; if(!snode->nodetree) uiLayoutSetActive(layout, 0); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index e07eaa85bed..748ba847f22 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -34,6 +34,7 @@ #include "BKE_context.h" #include "BLI_rect.h" +#include "BLI_utildefines.h" #include "ED_screen.h" #include "ED_types.h" @@ -108,13 +109,6 @@ static int node_select_exec(bContext *C, wmOperator *op) /* perform the select */ node= node_mouse_select(snode, ar, mval, extend); - - /* WATCH THIS, there are a few other ways to change the active material */ - if(node) { - if (node->id && ELEM(GS(node->id->name), ID_MA, ID_TE)) { - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, node->id); - } - } /* send notifiers */ WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index cdb04ec373c..4f2f204fbe6 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -31,11 +31,12 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" +#include "BLI_rect.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" #include "BKE_node.h" -#include "BLI_rect.h" - #include "ED_screen.h" #include "RNA_access.h" diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index d38e2af734b..eb8c34fe8bd 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -39,6 +39,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -118,15 +119,15 @@ static SpaceLink *node_new(const bContext *UNUSED(C)) BLI_addtail(&snode->regionbase, ar); ar->regiontype= RGN_TYPE_WINDOW; - ar->v2d.tot.xmin= -10.0f; - ar->v2d.tot.ymin= -10.0f; - ar->v2d.tot.xmax= 512.0f; - ar->v2d.tot.ymax= 512.0f; + ar->v2d.tot.xmin= -256.0f; + ar->v2d.tot.ymin= -256.0f; + ar->v2d.tot.xmax= 768.0f; + ar->v2d.tot.ymax= 768.0f; - ar->v2d.cur.xmin= 0.0f; - ar->v2d.cur.ymin= 0.0f; - ar->v2d.cur.xmax= 512.0f; - ar->v2d.cur.ymax= 512.0f; + ar->v2d.cur.xmin= -256.0f; + ar->v2d.cur.ymin= -256.0f; + ar->v2d.cur.xmax= 768.0f; + ar->v2d.cur.ymax= 768.0f; ar->v2d.min[0]= 1.0f; ar->v2d.min[1]= 1.0f; @@ -160,9 +161,9 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static void node_area_listener(ScrArea *sa, wmNotifier *wmn) { /* note, ED_area_tag_refresh will re-execute compositor */ - /* XXX, should edit some to check for the nodeTree type, especially NC_NODE|NA_EDITED which refreshes all types */ SpaceNode *snode= sa->spacedata.first; - + int type= snode->treetype; + /* preview renders */ switch(wmn->category) { case NC_SCENE: @@ -180,14 +181,18 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) /* future: add ID checks? */ case NC_MATERIAL: - if(wmn->data==ND_SHADING) - ED_area_tag_refresh(sa); - else if(wmn->data==ND_SHADING_DRAW) - ED_area_tag_refresh(sa); + if(type==NTREE_SHADER) { + if(wmn->data==ND_SHADING) + ED_area_tag_refresh(sa); + else if(wmn->data==ND_SHADING_DRAW) + ED_area_tag_refresh(sa); + } break; case NC_TEXTURE: - if(wmn->data==ND_NODES) - ED_area_tag_refresh(sa); + if(type==NTREE_SHADER || type==NTREE_TEXTURE) { + if(wmn->data==ND_NODES) + ED_area_tag_refresh(sa); + } break; case NC_TEXT: /* pynodes */ diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 57d37059da8..fe587bd98d6 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -51,6 +51,7 @@ #include "DNA_object_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #if defined WIN32 && !defined _LIBC # include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ @@ -187,7 +188,7 @@ static void check_persistant(SpaceOops *soops, TreeElement *te, ID *id, short ty /* case 1; no TreeStore */ if(soops->treestore==NULL) { - ts= soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); + soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); } ts= soops->treestore; @@ -1509,6 +1510,42 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) /* **************** INTERACTIVE ************* */ + +static int outliner_scroll_page_exec(bContext *C, wmOperator *op) +{ + ARegion *ar= CTX_wm_region(C); + int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int up= 0; + + if(RNA_boolean_get(op->ptr, "up")) + up= 1; + + if(up == 0) dy= -dy; + ar->v2d.cur.ymin+= dy; + ar->v2d.cur.ymax+= dy; + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + + +void OUTLINER_OT_scroll_page(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Scroll Page"; + ot->idname= "OUTLINER_OT_scroll_page"; + ot->description= "Scroll page up or down"; + + /* callbacks */ + ot->exec= outliner_scroll_page_exec; + ot->poll= ED_operator_outliner_active; + + /* properties */ + RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page."); +} + + static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) { TreeElement *te; @@ -2496,19 +2533,7 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { - Object *obedit= CTX_data_edit_object(C); - if(obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - else { - Object *ob= CTX_data_active_object(C); - - /* Don't allow edit mode if the object is hide! - * check the bug #22153 and #21609 - */ - if (ob && (!(ob->restrictflag & OB_RESTRICT_VIEW))) - ED_object_enter_editmode(C, EM_WAITCURSOR); - // XXX extern_set_butspace(F9KEY, 0); - } + WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); } else { // rest of types tree_element_active(C, scene, soops, te, 1); } @@ -4144,12 +4169,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa if (ksp) { /* free path's data */ - // TODO: we probably need an API method for this - if (ksp->rna_path) MEM_freeN(ksp->rna_path); + BKE_keyingset_free_path(ks, ksp); + ks->active_path= 0; - - /* remove path from set */ - BLI_freelinkN(&ks->paths, ksp); } } break; diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 256bf3f936b..cf29bfb4371 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -131,6 +131,8 @@ void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot); void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot); void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot); +void OUTLINER_OT_scroll_page(struct wmOperatorType *ot); + void OUTLINER_OT_renderability_toggle(struct wmOperatorType *ot); void OUTLINER_OT_selectability_toggle(struct wmOperatorType *ot); void OUTLINER_OT_visibility_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 8b2c288e400..f7dd03ec545 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -56,6 +56,7 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_show_one_level); WM_operatortype_append(OUTLINER_OT_show_active); WM_operatortype_append(OUTLINER_OT_show_hierarchy); + WM_operatortype_append(OUTLINER_OT_scroll_page); WM_operatortype_append(OUTLINER_OT_selected_toggle); WM_operatortype_append(OUTLINER_OT_expanded_toggle); @@ -91,6 +92,9 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PERIODKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEDOWNKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "up", 1); + WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADPLUSKEY, KM_PRESS, 0, 0); /* open */ RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0)->ptr, "open", 0); /* close */ diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 8bb49b85271..74c2dd5db1c 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -29,12 +29,12 @@ #include <string.h> #include <stdio.h> - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 4e65c216cd3..3da5b48db8e 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -29,9 +29,8 @@ #include <string.h> #include <stdio.h> - - #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" @@ -47,7 +46,7 @@ #include "script_intern.h" // own include #ifdef WITH_PYTHON -#include "BPY_extern.h" /* BPY_run_python_script */ +#include "BPY_extern.h" /* BPY_script_exec */ #endif static int run_pyfile_exec(bContext *C, wmOperator *op) @@ -55,7 +54,7 @@ static int run_pyfile_exec(bContext *C, wmOperator *op) char path[512]; RNA_string_get(op->ptr, "filepath", path); #ifdef WITH_PYTHON - if(BPY_run_python_script(C, path, NULL, op->reports)) { + if(BPY_filepath_exec(C, path, op->reports)) { ARegion *ar= CTX_wm_region(C); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -88,7 +87,7 @@ static int script_reload_exec(bContext *C, wmOperator *UNUSED(op)) /* TODO, this crashes on netrender and keying sets, need to look into why * disable for now unless running in debug mode */ WM_cursor_wait(1); - BPY_eval_string(C, "__import__('bpy').utils.load_scripts(reload_scripts=True)"); + BPY_string_exec(C, "__import__('bpy').utils.load_scripts(reload_scripts=True)"); WM_cursor_wait(0); WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_script/script_header.c b/source/blender/editors/space_script/script_header.c index 1159139eff5..545be69af54 100644 --- a/source/blender/editors/space_script/script_header.c +++ b/source/blender/editors/space_script/script_header.c @@ -29,25 +29,22 @@ #include <string.h> #include <stdio.h> +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" -#include "BLI_blenlib.h" -#include "BKE_utildefines.h" #include "BKE_context.h" #include "ED_screen.h" #include "ED_types.h" #include "ED_util.h" - - #include "UI_interface.h" #include "UI_resources.h" #include "UI_view2d.h" #include "script_intern.h" - /* ************************ header area region *********************** */ static void do_viewmenu(bContext *UNUSED(C), void *UNUSED(arg), int UNUSED(event)) diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 57d7bba8e3b..d0631f5651a 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -29,12 +29,12 @@ #include <string.h> #include <stdio.h> - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -148,12 +148,11 @@ static void script_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* data... */ - // BPY_run_python_script(C, "/root/blender-svn/blender25/test.py", NULL); + // BPY_script_exec(C, "/root/blender-svn/blender25/test.py", NULL); #ifdef WITH_PYTHON if (sscript->script) { - //BPY_run_python_script_space(scpt->script.filename, NULL); - BPY_run_script_space_draw(C, sscript); + // BPY_run_script_space_draw(C, sscript); } #else (void)sscript; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index adf1de8a125..eb7ae1d8011 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -40,7 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_storage_types.h" - +#include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index aa0686bc9bb..ee0a5d69113 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -31,14 +31,13 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" - #include "ED_screen.h" - #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3cf747a0779..635e261b26e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -32,6 +32,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" @@ -44,7 +45,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_sequencer.h" -#include "BKE_utildefines.h" + #include "BKE_sound.h" #include "IMB_imbuf.h" diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index eb20ce6ed3c..47dff6face4 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -41,7 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_storage_types.h" - +#include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" @@ -1781,7 +1781,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq, *seq_new, *seq_next_iter; + Sequence *seq, *seq_new; Strip *strip_new; StripElem *se, *se_new; int start_ofs, cfra, frame_end; @@ -1793,7 +1793,6 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) if((seq->flag & SELECT) && (seq->type == SEQ_IMAGE) && (seq->len > 1)) { /* remove seq so overlap tests dont conflict, see seq_free_sequence below for the real free'ing */ - seq_next_iter = seq->next; BLI_remlink(ed->seqbasep, seq); /* if(seq->ipo) seq->ipo->id.us--; */ /* XXX, remove fcurve and assign to split image strips */ @@ -1818,7 +1817,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) /* new stripdata */ strip_new->stripdata= se_new= MEM_callocN(sizeof(StripElem)*1, "stripelem"); - strncpy(se_new->name, se->name, FILE_MAXFILE-1); + BLI_strncpy(se_new->name, se->name, sizeof(se_new->name)); calc_sequence(scene, seq_new); if(step > 1) { diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index f5c8388bf67..b8b34eacdc0 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -26,7 +26,9 @@ #include <math.h> #include <string.h> -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index a2eefe6ee54..a20d2d7680e 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -35,9 +35,9 @@ #endif #include <sys/types.h> - #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 179db47ae12..ed280d765f0 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_path_util.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -518,7 +519,7 @@ void ED_spacetype_sequencer(void) art->init= sequencer_main_area_init; art->draw= sequencer_main_area_draw; art->listener= sequencer_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_ANIMATION; + art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_FRAMES|ED_KEYMAP_ANIMATION; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_sound/sound_header.c b/source/blender/editors/space_sound/sound_header.c index c857d33bcab..60bf0775f5e 100644 --- a/source/blender/editors/space_sound/sound_header.c +++ b/source/blender/editors/space_sound/sound_header.c @@ -33,15 +33,15 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_context.h" #include "ED_screen.h" #include "ED_types.h" #include "ED_util.h" - #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c index 99b24479967..200f15f6109 100644 --- a/source/blender/editors/space_sound/space_sound.c +++ b/source/blender/editors/space_sound/space_sound.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 0acdbfb9ccc..75001b9514c 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -221,9 +222,21 @@ static void text_keymap(struct wmKeyConfig *keyconf) #ifdef __APPLE__ RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); - RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", PREV_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", NEXT_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", UPARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", FILE_TOP); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", DOWNARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", FILE_BOTTOM); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); - RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0)->ptr, "type", LINE_END); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0)->ptr, "type", PREV_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0)->ptr, "type", NEXT_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0)->ptr, "type", FILE_TOP); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0)->ptr, "type", FILE_BOTTOM); + + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", DEL_PREV_WORD); + WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT|KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_OSKEY, 0); @@ -317,7 +330,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); - + WM_keymap_add_item(keymap, "TEXT_OT_overwrite_toggle", INSERTKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll", MIDDLEMOUSE, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 4307945129b..318c64f87a7 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -36,6 +36,7 @@ #include "BLF_api.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_text_types.h" #include "DNA_space_types.h" @@ -45,7 +46,7 @@ #include "BKE_context.h" #include "BKE_suggestions.h" #include "BKE_text.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" @@ -601,7 +602,6 @@ void wrap_offset_in_line(SpaceText *st, ARegion *ar, TextLine *linein, int cursi start= 0; end= max; chop= 1; - chars= 0; *offc= 0; for(i=0, j=0; linein->line[j]!='\0'; j++) { @@ -1050,7 +1050,7 @@ static TextLine *first_visible_line(SpaceText *st, ARegion *ar, int *wrap_top) } } } else { - for(i=st->top, pline= text->lines.first; pline->next && i>0; i--) + for(i=st->top; pline->next && i>0; i--) pline= pline->next; } @@ -1059,7 +1059,7 @@ static TextLine *first_visible_line(SpaceText *st, ARegion *ar, int *wrap_top) /************************ draw scrollbar *****************************/ -static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll) +static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) { int lhlstart, lhlend, ltexth, sell_off, curl_off; short barheight, barstart, hlstart, hlend, blank_lines; @@ -1072,8 +1072,11 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll) blank_lines = st->viewlines / 2; /* nicer code: use scroll rect for entire bar */ - //scroll->xmin= 5; - //scroll->xmax= 17; + back->xmin= ar->winx -18; + back->xmax= ar->winx; + back->ymin= 0; + back->ymax= ar->winy; + scroll->xmin= ar->winx - 17; scroll->xmax= ar->winx - 5; scroll->ymin= 4; @@ -1169,13 +1172,16 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll) CLAMP(st->txtscroll.ymax, pix_bottom_margin, ar->winy - pix_top_margin); } -static void draw_textscroll(SpaceText *st, rcti *scroll) +static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back) { bTheme *btheme= U.themes.first; uiWidgetColors wcol= btheme->tui.wcol_scroll; unsigned char col[4]; float rad; + UI_ThemeColor(TH_BACK); + glRecti(back->xmin, back->ymin, back->xmax, back->ymax); + uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT)?UI_SCROLL_PRESSED:0); uiSetRoundBox(15); @@ -1278,7 +1284,7 @@ static void draw_documentation(SpaceText *st, ARegion *ar) { TextLine *tmp; char *docs, buf[DOC_WIDTH+1], *p; - int len, i, br, lines; + int i, br, lines; int boxw, boxh, l, x, y, top; if(!st || !st->text) return; @@ -1303,7 +1309,6 @@ static void draw_documentation(SpaceText *st, ARegion *ar) } top= y= ar->winy - st->lheight*l - 2; - len= strlen(docs); boxw= DOC_WIDTH*st->cwidth + 20; boxh= (DOC_HEIGHT+1)*st->lheight; @@ -1673,7 +1678,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) { Text *text= st->text; TextLine *tmp; - rcti scroll; + rcti scroll, back; char linenr[12]; int i, x, y, winx, linecount= 0, lineno= 0; int wraplinecount= 0, wrap_skip= 0; @@ -1692,7 +1697,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) else st->viewlines= 0; /* update rects for scroll */ - calc_text_rcts(st, ar, &scroll); /* scroll will hold the entire bar size */ + calc_text_rcts(st, ar, &scroll, &back); /* scroll will hold the entire bar size */ /* update syntax formatting if needed */ tmp= text->lines.first; @@ -1780,7 +1785,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) draw_brackets(st, ar); draw_markers(st, ar); glTranslatef(0.375f, 0.375f, 0.0f); /* XXX scroll requires exact pixel space */ - draw_textscroll(st, &scroll); + draw_textscroll(st, &scroll, &back); draw_documentation(st, ar); draw_suggestion_list(st, ar); diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index 8ad4d6fa890..1287f68dc04 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -47,6 +47,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 8dc67ca4774..061a60440f4 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -38,6 +38,8 @@ #include "DNA_userdef_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "PIL_time.h" #include "BKE_context.h" @@ -314,7 +316,7 @@ static int reload_exec(bContext *C, wmOperator *op) #ifdef WITH_PYTHON if(text->compiled) - BPY_free_compiled_text(text); + BPY_text_free_code(text); #endif text_update_edited(text); @@ -569,7 +571,7 @@ static int run_script_exec(bContext *C, wmOperator *op) Text *text= CTX_data_edit_text(C); SpaceText *st= CTX_wm_space_text(C); - if (BPY_run_python_script(C, NULL, text, op->reports)) + if (BPY_text_exec(C, text, op->reports)) return OPERATOR_FINISHED; /* Dont report error messages while live editing */ @@ -1344,16 +1346,17 @@ static EnumPropertyItem move_type_items[]= { /* get cursor position in line by relative wrapped line and column positions */ static int text_get_cursor_rel(SpaceText* st, ARegion *ar, TextLine *linein, int rell, int relc) { - int i, j, start, end, chars, max, chop, curs, loop, endj, found, selc; + int i, j, start, end, max, chop, curs, loop, endj, found, selc; char ch; max= wrap_width(st, ar); - selc= start= chars= endj= curs= found= 0; + selc= start= endj= curs= found= 0; end= max; chop= loop= 1; for(i=0, j=0; loop; j++) { + int chars; /* Mimic replacement of tabs */ ch= linein->line[j]; if(ch=='\t') { @@ -1509,7 +1512,7 @@ static void wrap_move_bol(SpaceText *st, ARegion *ar, short sel) Text *text= st->text; TextLine **linep; int *charp; - int oldl, oldc, i, j, max, start, end, chars, endj, chop, loop; + int oldl, oldc, i, j, max, start, end, endj, chop, loop; char ch; text_update_character_width(st); @@ -1522,12 +1525,13 @@ static void wrap_move_bol(SpaceText *st, ARegion *ar, short sel) max= wrap_width(st, ar); - start= chars= endj= 0; + start= endj= 0; end= max; chop= loop= 1; *charp= 0; for(i=0, j=0; loop; j++) { + int chars; /* Mimic replacement of tabs */ ch= (*linep)->line[j]; if(ch=='\t') { @@ -1576,7 +1580,7 @@ static void wrap_move_eol(SpaceText *st, ARegion *ar, short sel) Text *text= st->text; TextLine **linep; int *charp; - int oldl, oldc, i, j, max, start, end, chars, endj, chop, loop; + int oldl, oldc, i, j, max, start, end, endj, chop, loop; char ch; text_update_character_width(st); @@ -1589,12 +1593,13 @@ static void wrap_move_eol(SpaceText *st, ARegion *ar, short sel) max= wrap_width(st, ar); - start= chars= endj= 0; + start= endj= 0; end= max; chop= loop= 1; *charp= 0; for(i=0, j=0; loop; j++) { + int chars; /* Mimic replacement of tabs */ ch= (*linep)->line[j]; if(ch=='\t') { @@ -2241,7 +2246,7 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel) x = (x/st->cwidth) + st->left; if(st->wordwrap) { - int i, j, endj, curs, max, chop, start, end, chars, loop, found; + int i, j, endj, curs, max, chop, start, end, loop, found; char ch; /* Point to first visible line */ @@ -2267,10 +2272,10 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel) start= 0; end= max; chop= 1; - chars= 0; curs= 0; endj= 0; for(i=0, j=0; loop; j++) { + int chars; /* Mimic replacement of tabs */ ch= (*linep)->line[j]; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 9a1fc201564..4a45b6b6cbb 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index edb3da5a06e..5bc59f06a19 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -29,21 +29,18 @@ #include <stdlib.h> #include <math.h> - #include "DNA_scene_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" - #include "ED_screen.h" - #include "WM_api.h" #include "WM_types.h" - /* ****************** Start/End Frame Operators *******************************/ static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index a59c03ad17d..6f155fc3b99 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -33,13 +33,13 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" - #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 27cb305f78f..18a83e16ca1 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -43,6 +43,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dlrbTree.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_action.h" @@ -50,7 +51,7 @@ #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_nla.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index e38e9309611..c6cbfe44df4 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -34,7 +34,7 @@ #include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" - +#include "BLI_utildefines.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" @@ -50,7 +50,7 @@ #include "BKE_material.h" #include "BKE_paint.h" #include "BKE_property.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 1f1acef02db..17e8b09ad68 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -47,6 +47,7 @@ #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" //for the where_on_path function #include "BKE_constraint.h" // for the get_constraint_target function @@ -67,7 +68,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_unit.h" -#include "BKE_utildefines.h" + #include "smoke_API.h" #include "BIF_gl.h" @@ -919,11 +920,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, float lampsize; float imat[4][4], curcol[4]; unsigned char col[4]; - int drawcone= (dt>OB_WIRE && !(G.f & G_PICKSEL) && la->type == LA_SPOT && (la->mode & LA_SHOW_CONE)); - /* cone can't be drawn for duplicated lamps, because duplilist would be freed to */ /* the moment of view3d_draw_transp() call */ - drawcone&= (base->flag & OB_FROMDUPLI)==0; + const short is_view= (rv3d->persp==RV3D_CAMOB && v3d->camera == base->object); + const short drawcone= (dt>OB_WIRE && !(G.f & G_PICKSEL) && (la->type == LA_SPOT) && (la->mode & LA_SHOW_CONE) && !(base->flag & OB_FROMDUPLI) && !is_view); if(drawcone && !v3d->transp) { /* in this case we need to draw delayed */ @@ -1028,7 +1028,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glPopMatrix(); /* back in object space */ zero_v3(vec); - if ((la->type==LA_SPOT) || (la->type==LA_YF_PHOTON)) { + if(is_view) { + /* skip drawing extra info */ + } + else if ((la->type==LA_SPOT) || (la->type==LA_YF_PHOTON)) { lvec[0]=lvec[1]= 0.0; lvec[2] = 1.0; x = rv3d->persmat[0][2]; @@ -1171,7 +1174,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, setlinestyle(0); - if(la->type==LA_SPOT && (la->mode & LA_SHAD_BUF) ) { + if((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == FALSE)) { drawshadbuflimits(la, ob->obmat); } @@ -3144,7 +3147,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas case OB_CURVE: cu= ob->data; - lb= &cu->disp; + lb= &ob->disp; if(solid) { dl= lb->first; @@ -3191,7 +3194,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas break; case OB_SURF: - lb= &((Curve *)ob->data)->disp; + lb= &ob->disp; if(solid) { dl= lb->first; @@ -5434,7 +5437,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (dm) { hasfaces= dm->getNumFaces(dm); } else { - hasfaces= displist_has_faces(&cu->disp); + hasfaces= displist_has_faces(&ob->disp); } if (hasfaces && boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -5442,7 +5445,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (dm) { draw_mesh_object_outline(v3d, ob, dm); } else { - drawDispListwire(&cu->disp); + drawDispListwire(&ob->disp); } draw_index_wire= 1; } @@ -5497,7 +5500,7 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) if (ob->derivedFinal) { drawCurveDMWired(ob); } else { - drawDispListwire(&cu->disp); + drawDispListwire(&ob->disp); } if (ob->type==OB_CURVE) @@ -5818,9 +5821,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* bad exception, solve this! otherwise outline shows too late */ if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - cu= ob->data; /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0); + if (ob->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0); } /* draw outline for selected objects, mesh does itself */ diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 89bb0044eaf..0f6e0bdc834 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -31,10 +31,6 @@ #include "MEM_guardedalloc.h" - - - - #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" @@ -44,6 +40,7 @@ #include "BLI_editVert.h" #include "BLI_edgehash.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_curve.h" #include "BKE_constraint.h" // for the get_constraint_target function @@ -65,7 +62,7 @@ #include "BKE_particle.h" #include "BKE_property.h" #include "BKE_smoke.h" -#include "BKE_utildefines.h" + #include "smoke_API.h" #include "BIF_gl.h" diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5c54791b2a0..9ec68d62364 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_object.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 85900435112..53a4981661f 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_context.h" @@ -56,7 +57,6 @@ #include "BKE_screen.h" #include "BKE_deform.h" - #include "WM_api.h" #include "WM_types.h" @@ -282,12 +282,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if(block) { // buttons uiBut *but; - int but_y; - if((ob->parent) && (ob->partype == PARBONE)) but_y = 135; - else but_y = 150; - - - + memcpy(tfp->ve_median, median, sizeof(tfp->ve_median)); uiBlockBeginAlign(block); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 29629165661..6afe2791ff9 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 8dfbe982ede..35cddda5362 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_image.h" @@ -52,6 +53,7 @@ #include "BIF_gl.h" +#include "BIF_glutil.h" #include "WM_api.h" #include "WM_types.h" @@ -60,7 +62,6 @@ #include "RNA_define.h" #include "ED_particle.h" -#include "ED_retopo.h" #include "ED_screen.h" #include "ED_transform.h" #include "ED_mesh.h" @@ -324,7 +325,7 @@ static void calctrackballvec(rcti *rect, int mx, int my, float *vec) static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) { static float lastofs[3] = {0,0,0}; - View3D *v3d = CTX_wm_view3d(C); + View3D *v3d; RegionView3D *rv3d; ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data"); @@ -332,6 +333,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) op->customdata= vod; vod->sa= CTX_wm_area(C); vod->ar= CTX_wm_region(C); + v3d= vod->sa->spacedata.first; vod->rv3d= rv3d= vod->ar->regiondata; vod->dist0= rv3d->dist; copy_qt_qt(vod->oldquat, rv3d->viewquat); @@ -404,19 +406,26 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) static void viewops_data_free(bContext *C, wmOperator *op) { + ARegion *ar; Paint *p = paint_get_active(CTX_data_scene(C)); - ViewOpsData *vod= op->customdata; - vod->rv3d->rflag &= ~RV3D_NAVIGATING; + if(op->customdata) { + ViewOpsData *vod= op->customdata; + ar= vod->ar; + vod->rv3d->rflag &= ~RV3D_NAVIGATING; - if(p && (p->flags & PAINT_FAST_NAVIGATE)) - ED_region_tag_redraw(vod->ar); + if(vod->timer) + WM_event_remove_timer(CTX_wm_manager(C), vod->timer->win, vod->timer); - if(vod->timer) - WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vod->timer); + MEM_freeN(vod); + op->customdata= NULL; + } + else { + ar= CTX_wm_region(C); + } - MEM_freeN(vod); - op->customdata= NULL; + if(p && (p->flags & PAINT_FAST_NAVIGATE)) + ED_region_tag_redraw(ar); } /* ************************** viewrotate **********************************/ @@ -1194,11 +1203,30 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event) static int viewzoom_exec(bContext *C, wmOperator *op) { - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + View3D *v3d; + RegionView3D *rv3d; + ScrArea *sa; + ARegion *ar; + int delta= RNA_int_get(op->ptr, "delta"); - int mx = RNA_int_get(op->ptr, "mx"); - int my = RNA_int_get(op->ptr, "my"); + int mx, my; + + if(op->customdata) { + ViewOpsData *vod= op->customdata; + + sa= vod->sa; + ar= vod->ar; + } + else { + sa= CTX_wm_area(C); + ar= CTX_wm_region(C); + } + + v3d= sa->spacedata.first; + rv3d= ar->regiondata; + + mx= RNA_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : ar->winx / 2; + my= RNA_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : ar->winy / 2; if(delta < 0) { /* this min and max is also in viewmove() */ @@ -1207,7 +1235,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if(rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN; } else if(rv3d->dist<10.0*v3d->far) { - view_zoom_mouseloc(CTX_wm_region(C), 1.2f, mx, my); + view_zoom_mouseloc(ar, 1.2f, mx, my); } } else { @@ -1216,16 +1244,16 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if(rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX; } else if(rv3d->dist> 0.001*v3d->grid) { - view_zoom_mouseloc(CTX_wm_region(C), .83333f, mx, my); + view_zoom_mouseloc(ar, .83333f, mx, my); } } if(rv3d->viewlock & RV3D_BOXVIEW) - view3d_boxview_sync(CTX_wm_area(C), CTX_wm_region(C)); + view3d_boxview_sync(sa, ar); request_depth_update(rv3d); - ED_region_tag_redraw(CTX_wm_region(C)); - + ED_region_tag_redraw(ar); + viewops_data_free(C, op); return OPERATOR_FINISHED; @@ -1233,8 +1261,6 @@ static int viewzoom_exec(bContext *C, wmOperator *op) static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { - int delta= RNA_int_get(op->ptr, "delta"); - /* if one or the other zoom position aren't set, set from event */ if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { @@ -1242,7 +1268,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "my", event->y); } - if(delta) { + if(RNA_property_is_set(op->ptr, "delta")) { /* makes op->customdata */ viewops_data_create(C, op, event); viewzoom_exec(C, op); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 6b600f277f0..1e856ad49f7 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -32,6 +32,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_object.h" diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 0f2f182e951..a481fdb59f6 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -37,6 +37,11 @@ #include "MEM_guardedalloc.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_editVert.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_effect.h" @@ -58,11 +63,6 @@ #include "RNA_define.h" #include "RNA_enum_types.h" - -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_editVert.h" - #include "UI_interface.h" #include "UI_resources.h" diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 6043db6a02f..cb6eee26df5 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -38,7 +38,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" - +#include "BLI_utildefines.h" #include "RNA_access.h" diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index d26137bd115..4bb263d3ed9 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -47,6 +47,7 @@ #include "BLI_editVert.h" #include "BLI_rand.h" #include "BLI_linklist.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_paint.h" @@ -54,6 +55,7 @@ #include "BIF_gl.h" +#include "BIF_glutil.h" #include "WM_api.h" #include "WM_types.h" @@ -66,7 +68,6 @@ #include "ED_particle.h" #include "ED_mesh.h" #include "ED_object.h" -#include "ED_retopo.h" #include "ED_screen.h" #include "ED_mball.h" diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 64aa21d6ad8..e90998da21c 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_linklist.h" +#include "BLI_utildefines.h" #include "BKE_armature.h" #include "BKE_context.h" @@ -87,7 +88,7 @@ static void special_transvert_update(Object *obedit) if(obedit) { - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); if(obedit->type==OB_MESH) { Mesh *me= obedit->data; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index c87eecb4220..730cc553ff3 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_idprop.h" diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c63bb7919a6..a259e29e9a0 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -36,6 +36,7 @@ #include "BLI_math.h" #include "BLI_rect.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_action.h" diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e7f02de2645..d17de267cf7 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -89,11 +89,11 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_linklist.h" - #include "UI_resources.h" //#include "blendef.h" @@ -604,20 +604,22 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case TFM_MODAL_ROTATE: /* only switch when... */ - if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { - - resetTransRestrictions(t); - - if (t->mode == TFM_ROTATION) { - restoreTransObjects(t); - initTrackball(t); - } - else { - restoreTransObjects(t); - initRotation(t); + if(!(t->options & CTX_TEXTURE)) { + if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { + + resetTransRestrictions(t); + + if (t->mode == TFM_ROTATION) { + restoreTransObjects(t); + initTrackball(t); + } + else { + restoreTransObjects(t); + initRotation(t); + } + initSnapping(t, NULL); // need to reinit after mode change + t->redraw |= TREDRAW_HARD; } - initSnapping(t, NULL); // need to reinit after mode change - t->redraw |= TREDRAW_HARD; } break; case TFM_MODAL_RESIZE: @@ -736,6 +738,8 @@ int transformEvent(TransInfo *t, wmEvent *event) case TFM_MODAL_PROPSIZE_UP: if(t->flag & T_PROP_EDIT) { t->prop_size*= 1.1f; + if(t->spacetype==SPACE_VIEW3D) + t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } t->redraw |= TREDRAW_HARD; @@ -855,20 +859,22 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case RKEY: /* only switch when... */ - if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { + if(!(t->options & CTX_TEXTURE)) { + if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { - resetTransRestrictions(t); + resetTransRestrictions(t); - if (t->mode == TFM_ROTATION) { - restoreTransObjects(t); - initTrackball(t); - } - else { - restoreTransObjects(t); - initRotation(t); + if (t->mode == TFM_ROTATION) { + restoreTransObjects(t); + initTrackball(t); + } + else { + restoreTransObjects(t); + initRotation(t); + } + initSnapping(t, NULL); // need to reinit after mode change + t->redraw |= TREDRAW_HARD; } - initSnapping(t, NULL); // need to reinit after mode change - t->redraw |= TREDRAW_HARD; } break; case CKEY: @@ -972,6 +978,8 @@ int transformEvent(TransInfo *t, wmEvent *event) case PADPLUSKEY: if(event->alt && t->flag & T_PROP_EDIT) { t->prop_size *= 1.1f; + if(t->spacetype==SPACE_VIEW3D) + t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } t->redraw= 1; @@ -1496,6 +1504,10 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->state = TRANS_STARTING; + if(RNA_struct_find_property(op->ptr, "texture_space")) + if(RNA_boolean_get(op->ptr, "texture_space")) + options |= CTX_TEXTURE; + t->options = options; t->mode = mode; @@ -2536,6 +2548,9 @@ static void headerResize(TransInfo *t, float vec[3], char *str) { else sprintf(str, "Scale X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext); } + + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) + sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); } #define SIGN(a) (a<-FLT_EPSILON?1:a>FLT_EPSILON?2:3) @@ -3159,6 +3174,9 @@ int Rotation(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext); } + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) + sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); + t->values[0] = final; applyRotation(t, final, t->axis); @@ -3380,6 +3398,9 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { else sprintf(str, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); } + + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) + sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); } static void applyTranslation(TransInfo *t, float vec[3]) { diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 32792754434..d5700db8c57 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -49,12 +49,13 @@ #include "BIF_glutil.h" #include "BKE_context.h" -#include "BKE_utildefines.h" + #include "ED_image.h" #include "ED_view3d.h" #include "BLI_math.h" +#include "BLI_utildefines.h" //#include "blendef.h" // diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index df267254d8f..75458335b05 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -89,6 +89,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "RNA_access.h" @@ -268,6 +269,7 @@ static void createTransTexspace(TransInfo *t) invert_m3_m3(td->smtx, td->mtx); if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { + ob->dtx |= OB_TEXSPACE; *texflag &= ~AUTOSPACE; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 83b85ce257c..11fd02b340e 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -87,7 +87,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_rand.h" - +#include "BLI_utildefines.h" #include "WM_types.h" #include "WM_api.h" @@ -616,7 +616,7 @@ void recalcData(TransInfo *t) if(sima->flag & SI_LIVE_UNWRAP) ED_uvedit_live_unwrap_re_solve(); - DAG_id_tag_update(t->obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(t->obedit->data, 0); } } else if (t->spacetype == SPACE_VIEW3D) { @@ -632,7 +632,7 @@ void recalcData(TransInfo *t) applyProject(t); } - DAG_id_tag_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */ + DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ if (t->state == TRANS_CANCEL) { while(nu) { @@ -655,7 +655,7 @@ void recalcData(TransInfo *t) applyProject(t); } - DAG_id_tag_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */ + DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt); } @@ -669,7 +669,7 @@ void recalcData(TransInfo *t) if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) editmesh_apply_to_mirror(t); - DAG_id_tag_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */ + DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ recalc_editnormals(em); } @@ -760,7 +760,7 @@ void recalcData(TransInfo *t) if(t->state != TRANS_CANCEL) { applyProject(t); } - DAG_id_tag_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */ + DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ } } else if( (t->flag & T_POSE) && t->poseobj) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index ce0888b6a30..a06e5ab21e6 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -28,6 +28,7 @@ #include "DNA_screen_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "WM_types.h" diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index ca106c0e88a..b4fe38b41ac 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -59,6 +59,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BIF_gl.h" diff --git a/source/blender/editors/transform/transform_ndofinput.c b/source/blender/editors/transform/transform_ndofinput.c index 1ff16dd5f5f..ae12daa29ad 100644 --- a/source/blender/editors/transform/transform_ndofinput.c +++ b/source/blender/editors/transform/transform_ndofinput.c @@ -27,9 +27,10 @@ #include <math.h> /* fabs */ #include <stdio.h> /* for sprintf */ -#include "BKE_global.h" /* for G */ -#include "BKE_utildefines.h" /* ABS */ +#include "BLI_utildefines.h" +#include "BKE_global.h" /* for G */ + /* ABS */ #include "WM_types.h" diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 322bb7cb7db..55699a345c2 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -31,6 +31,7 @@ #include "RNA_enum_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" @@ -319,7 +320,10 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event) TransInfo *t = op->customdata; + /* XXX insert keys are called here, and require context */ + t->context= C; exit_code = transformEvent(t, event); + t->context= NULL; transformApply(C, t); @@ -444,6 +448,11 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } } } + + if (flags & P_OPTIONS) + { + RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Object data texture space", ""); + } // Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button"); @@ -467,7 +476,7 @@ void TRANSFORM_OT_translate(struct wmOperatorType *ot) RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_ALIGN_SNAP); + Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_ALIGN_SNAP|P_OPTIONS); } void TRANSFORM_OT_resize(struct wmOperatorType *ot) @@ -487,7 +496,7 @@ void TRANSFORM_OT_resize(struct wmOperatorType *ot) RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_GEO_SNAP); + Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_GEO_SNAP|P_OPTIONS); } @@ -854,6 +863,13 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac RNA_string_set(km->ptr, "data_path", "tool_settings.use_snap"); km = WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + + km = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(km->ptr, "texture_space", 1); + + km = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); + RNA_boolean_set(km->ptr, "texture_space", 1); + break; case SPACE_ACTION: diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 5cd57147a1f..45c8a60f4e4 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -34,7 +34,7 @@ #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BKE_utildefines.h" + #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_report.h" @@ -42,6 +42,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" //#include "BIF_editmesh.h" //#include "BIF_interface.h" diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 0828ceeaa52..3eae81d52f1 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -48,6 +48,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" //#include "BDR_drawobject.h" // diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 0b5c563a741..a2e0525cb0e 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -62,7 +62,6 @@ set(SRC ../include/ED_particle.h ../include/ED_physics.h ../include/ED_render.h - ../include/ED_retopo.h ../include/ED_screen.h ../include/ED_screen_types.h ../include/ED_sculpt.h diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 6b0d5b7f172..cff30f12369 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -37,15 +37,15 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" -#include "BKE_utildefines.h" -#include "BKE_context.h" -#include "BKE_depsgraph.h" -#include "BKE_global.h" - #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" +#include "BKE_context.h" +#include "BKE_depsgraph.h" +#include "BKE_global.h" + #include "ED_mesh.h" #include "UI_interface.h" diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 868aa8ac6af..ccdbe7dfd4e 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -30,6 +30,7 @@ #include <math.h> /* fabs */ #include <stdio.h> /* for sprintf */ +#include "BLI_utildefines.h" #include "WM_types.h" diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 0165cf5a03d..60f526b940a 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -36,15 +36,15 @@ #include "DNA_object_types.h" -#include "BKE_blender.h" -#include "BKE_context.h" -#include "BKE_global.h" -#include "BKE_screen.h" - #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" +#include "BKE_blender.h" +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_screen.h" #include "ED_armature.h" #include "ED_particle.h" diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 209b1d7e066..fc217411386 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -35,12 +35,13 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BLI_math.h" +#include "BLI_editVert.h" +#include "BLI_utildefines.h" + #include "BKE_DerivedMesh.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" -#include "BLI_math.h" -#include "BLI_editVert.h" #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 4ae7ae85eff..033cfdc2912 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -40,6 +40,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -135,7 +136,7 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre /* and update depdency graph */ if(update) - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); BKE_mesh_end_editmesh(obedit->data, em); } @@ -168,7 +169,7 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile) tf->tile= curtile; /* set tile index */ } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); BKE_mesh_end_editmesh(obedit->data, em); return 1; @@ -1018,7 +1019,7 @@ static void weld_align_uv(bContext *C, int tool) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1241,7 +1242,7 @@ static int stitch_exec(bContext *C, wmOperator *op) MEM_freeN(uv_average); } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1702,7 +1703,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1854,7 +1855,7 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i select_linked(scene, ima, em, limit, hit_p, extend); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1943,7 +1944,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -2624,7 +2625,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op) if(!change) return OPERATOR_CANCELLED; - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 259b7a95492..f812de692e2 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -6,8 +6,9 @@ #include "BLI_rand.h" #include "BLI_heap.h" #include "BLI_boxpack2d.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "ONL_opennl.h" diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 5136c50a16b..6f123200dd3 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -38,17 +38,18 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_math.h" +#include "BLI_edgehash.h" +#include "BLI_editVert.h" +#include "BLI_uvproject.h" +#include "BLI_utildefines.h" + #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" #include "BKE_image.h" #include "BKE_mesh.h" -#include "BLI_math.h" -#include "BLI_edgehash.h" -#include "BLI_editVert.h" -#include "BLI_uvproject.h" - #include "PIL_time.h" #include "ED_image.h" @@ -286,7 +287,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact ms->lasttime = PIL_check_seconds_timer(); - DAG_id_tag_update(ms->obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(ms->obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ms->obedit->data); } } @@ -309,7 +310,7 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel) param_stretch_end(ms->handle); param_delete(ms->handle); - DAG_id_tag_update(ms->obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(ms->obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ms->obedit->data); MEM_freeN(ms); @@ -437,7 +438,7 @@ static int pack_islands_exec(bContext *C, wmOperator *UNUSED(op)) param_flush(handle); param_delete(handle); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -470,7 +471,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op)) param_flush(handle); param_delete(handle); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -496,7 +497,7 @@ static ParamHandle *liveHandle = NULL; void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit) { EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); - short abf = scene->toolsettings->unwrapper == 1; + short abf = scene->toolsettings->unwrapper == 0; short fillholes = scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES; if(!ED_uvedit_test(obedit)) { @@ -822,6 +823,9 @@ static int unwrap_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + /* remember last method for live unwrap */ + scene->toolsettings->unwrapper = method; + handle= construct_param_handle(scene, em, 0, fill_holes, 1, correct_aspect); param_lscm_begin(handle, PARAM_FALSE, method == 0); @@ -834,7 +838,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) param_delete(handle); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -940,7 +944,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) uv_map_clip_correct(em, op); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1007,7 +1011,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) } } - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1095,7 +1099,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op) uv_map_clip_correct(em, op); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1167,7 +1171,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op) uv_map_clip_correct(em, op); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); @@ -1254,7 +1258,7 @@ static int cube_project_exec(bContext *C, wmOperator *op) uv_map_clip_correct(em, op); - DAG_id_tag_update(obedit->data, OB_RECALC_DATA); + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh(obedit->data, em); diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 934755b8231..379e9a0fdef 100755 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -74,12 +74,12 @@ class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter BKE_reports_clear(reports); char *fn = const_cast<char*>(filename.c_str()); #if 0 - int status = BPY_run_python_script(_context, fn, NULL, reports); + int status = BPY_filepath_exec(_context, fn, reports); #else int status; Text *text = add_text(fn, G.main->name); if (text) { - status = BPY_run_python_script(_context, NULL, text, reports); + status = BPY_text_exec(_context, text, reports); unlink_text(G.main, text); free_libblock(&G.main->text, text); } else { @@ -110,7 +110,7 @@ class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter BKE_reports_clear(reports); - if (!BPY_run_python_script(_context, NULL, text, reports)) { + if (!BPY_text_exec(_context, text, reports)) { cout << "\nError executing Python script from PythonInterpreter::interpretText" << endl; cout << "Name: " << name << endl; cout << "Errors: " << endl; @@ -163,7 +163,7 @@ private: } } - BPY_run_python_script(_context, NULL, text, NULL); + BPY_text_exec(_context, text, NULL); // cleaning up unlink_text(G.main, text); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 00644eb02f7..f7ca1c5bfe0 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -38,8 +38,9 @@ #include "MEM_guardedalloc.h" -#include "BLI_ghash.h" #include "BLI_math.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "BLI_threads.h" #include "DNA_meshdata_types.h" @@ -241,7 +242,7 @@ void GPU_buffer_free( GPUBuffer *buffer, GPUBufferPool *pool ) if( pool == 0 ) pool = globalPool; if( pool == 0 ) - globalPool = GPU_buffer_pool_new(); + pool = globalPool = GPU_buffer_pool_new(); /* free the last used buffer in the queue if no more space, but only if we are in the main thread. for e.g. rendering or baking it can @@ -268,7 +269,6 @@ void GPU_buffer_free( GPUBuffer *buffer, GPUBufferPool *pool ) GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) { GPUDrawObject *object; - MVert *mvert; MFace *mface; int numverts[32768]; /* material number is an 16-bit short so there's at most 32768 materials */ int redir[32768]; /* material number is an 16-bit short so there's at most 32768 materials */ @@ -290,7 +290,6 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) /*object->legacy = 1;*/ memset(numverts,0,sizeof(int)*32768); - mvert = dm->getVertArray(dm); mface = dm->getFaceArray(dm); numfaces= dm->getNumFaces(dm); @@ -1115,14 +1114,12 @@ void GPU_buffer_copy_edge(DerivedMesh *dm, float *varray, int *UNUSED(index), in { int i; - MVert *mvert; MEdge *medge; unsigned int *varray_ = (unsigned int *)varray; int numedges; DEBUG_VBO("GPU_buffer_copy_edge\n"); - mvert = dm->getVertArray(dm); medge = dm->getEdgeArray(dm); numedges= dm->getNumEdges(dm); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 62a7d399377..9f0bbda91bb 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -38,12 +38,12 @@ #include "DNA_image_types.h" #include "DNA_material_types.h" -#include "BLI_dynstr.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_dynstr.h" #include "BLI_ghash.h" #include "BLI_heap.h" - #include "GPU_material.h" #include "GPU_extensions.h" diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index e54002a85db..dfaf251f4c5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -35,6 +35,7 @@ #include "GL/glew.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" @@ -58,7 +59,7 @@ #include "BKE_material.h" #include "BKE_node.h" #include "BKE_object.h" -#include "BKE_utildefines.h" + #include "BLI_threads.h" #include "BLI_blenlib.h" @@ -901,7 +902,7 @@ static struct GPUMaterialState { } GMS = {NULL}; /* fixed function material, alpha handed by caller */ -static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma) +static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob) { if (bmat->mode & MA_SHLESS) { copy_v3_v3(smat->diff, &bmat->r); @@ -915,6 +916,9 @@ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit); smat->diff[3]= 1.0; /* caller may set this to bmat->alpha */ + if(bmat->shade_flag & MA_OBCOLOR) + mul_v3_v3(smat->diff, ob->col); + mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec); smat->spec[3]= 1.0; /* always 1 */ smat->hard= CLAMPIS(bmat->har, 0, 128); @@ -979,7 +983,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O /* no materials assigned? */ if(ob->totcol==0) { - gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0); + gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob); /* do material 1 too, for displists! */ memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed)); @@ -1009,7 +1013,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O } else { /* fixed function opengl materials */ - gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma); + gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob); blendmode = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA; if(do_alpha_pass && GMS.alphapass) diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 82a8ac8a62a..bff4287bd75 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -37,10 +37,10 @@ #include "MEM_guardedalloc.h" #include "BKE_global.h" -#include "BKE_utildefines.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "GPU_draw.h" #include "GPU_extensions.h" diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index b9da22b36a7..6f8719c60d3 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -40,6 +40,10 @@ #include "DNA_scene_types.h" #include "DNA_world_types.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "BKE_anim.h" #include "BKE_colortools.h" #include "BKE_DerivedMesh.h" @@ -48,10 +52,7 @@ #include "BKE_node.h" #include "BKE_scene.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" #include "GPU_extensions.h" #include "GPU_material.h" diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c index c3310e77ad6..1604f591bda 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.c +++ b/source/blender/ikplugin/intern/ikplugin_api.c @@ -33,7 +33,7 @@ #include "BLI_math.h" #include "BKE_armature.h" -#include "BKE_utildefines.h" + #include "DNA_object_types.h" #include "DNA_action_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index c0c4cd9bc6c..11be240ab76 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -32,10 +32,11 @@ #include "BIK_api.h" #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_armature.h" #include "BKE_constraint.h" -#include "BKE_utildefines.h" + #include "DNA_object_types.h" #include "DNA_action_types.h" #include "DNA_constraint_types.h" diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 7bdc327afa1..c3b2ad0804d 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -49,6 +49,7 @@ extern "C" { #include "BIK_api.h" #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_armature.h" diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 8c241824bdb..45a8986f835 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -60,10 +60,13 @@ #include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail BLI_countlist BLI_stringdec */ +#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" #include "DNA_userdef_types.h" -#include "BKE_utildefines.h" + + #include "BKE_global.h" #include "BKE_depsgraph.h" diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c index ef8cc913459..23f0dd87b1a 100644 --- a/source/blender/imbuf/intern/cache.c +++ b/source/blender/imbuf/intern/cache.c @@ -22,12 +22,13 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_listbase.h" #include "BLI_memarena.h" #include "BLI_threads.h" -#include "BKE_utildefines.h" + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 65a6ada43fa..1ea11432025 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -32,12 +32,13 @@ #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "BKE_utildefines.h" + #include "BKE_colortools.h" #include "MEM_guardedalloc.h" @@ -277,9 +278,9 @@ void IMB_convert_profile(struct ImBuf *ibuf, int profile) } if(ibuf->rect) { for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) { - rctf[0]= (unsigned char)((srgb_to_linearrgb((float)rctf[0]/255.0f) * 255.0f) + 0.5f); - rctf[1]= (unsigned char)((srgb_to_linearrgb((float)rctf[1]/255.0f) * 255.0f) + 0.5f); - rctf[2]= (unsigned char)((srgb_to_linearrgb((float)rctf[2]/255.0f) * 255.0f) + 0.5f); + rct[0]= (unsigned char)((srgb_to_linearrgb((float)rct[0]/255.0f) * 255.0f) + 0.5f); + rct[1]= (unsigned char)((srgb_to_linearrgb((float)rct[1]/255.0f) * 255.0f) + 0.5f); + rct[2]= (unsigned char)((srgb_to_linearrgb((float)rct[2]/255.0f) * 255.0f) + 0.5f); } } ok= TRUE; @@ -296,9 +297,9 @@ void IMB_convert_profile(struct ImBuf *ibuf, int profile) } if(ibuf->rect) { for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) { - rctf[0]= (unsigned char)((linearrgb_to_srgb((float)rctf[0]/255.0f) * 255.0f) + 0.5f); - rctf[1]= (unsigned char)((linearrgb_to_srgb((float)rctf[1]/255.0f) * 255.0f) + 0.5f); - rctf[2]= (unsigned char)((linearrgb_to_srgb((float)rctf[2]/255.0f) * 255.0f) + 0.5f); + rct[0]= (unsigned char)((linearrgb_to_srgb((float)rct[0]/255.0f) * 255.0f) + 0.5f); + rct[1]= (unsigned char)((linearrgb_to_srgb((float)rct[1]/255.0f) * 255.0f) + 0.5f); + rct[2]= (unsigned char)((linearrgb_to_srgb((float)rct[2]/255.0f) * 255.0f) + 0.5f); } } ok= TRUE; diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 13c0e6cf632..42f87049c2a 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -29,9 +29,12 @@ * $Id$ */ -#include "BKE_utildefines.h" #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" + + + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_filter.h" diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 53385743bb8..eba32c73688 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -30,13 +30,14 @@ */ #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "BKE_utildefines.h" + /* blend modes */ diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 4edb7ac7877..d4e1a45f0fa 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -30,7 +30,9 @@ */ #include "BLI_blenlib.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "MEM_guardedalloc.h" #include "imbuf.h" diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index cd9bf9c7a3a..1158a3d9491 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -26,6 +26,8 @@ #include "zlib.h" +#include "BLI_utildefines.h" + #include "BKE_utildefines.h" #include "BKE_global.h" diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index c086a55a70a..4e5dc5923fe 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -45,12 +45,13 @@ #include <string.h> #include "imbuf.h" - -#include "BKE_global.h" -#include "BKE_utildefines.h" #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "BKE_global.h" + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/makesdna/CMakeLists.txt b/source/blender/makesdna/CMakeLists.txt index e02b33b92c1..b1e1b589c6e 100644 --- a/source/blender/makesdna/CMakeLists.txt +++ b/source/blender/makesdna/CMakeLists.txt @@ -24,4 +24,67 @@ # # ***** END GPL LICENSE BLOCK ***** +# Use PARENT_SCOPE so makesrna can access. +set(SRC_DNA_INC + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_ID.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_action_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_actuator_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_anim_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_armature_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_boid_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_brush_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_camera_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_cloth_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_color_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_constraint_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_controller_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_curve_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_customdata_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_documentation.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_effect_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_fileglobal_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_genfile.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_gpencil_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_group_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_image_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_ipo_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_key_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_lamp_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_lattice_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_listBase.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_material_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_mesh_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_meshdata_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_meta_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_modifier_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_nla_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_node_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_object_fluidsim.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_object_force.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_object_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_outliner_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_packedFile_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_particle_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_property_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_scene_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_screen_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_sdna_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_sensor_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_sequence_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_smoke_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_sound_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_space_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_text_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_texture_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_userdef_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_vec_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_vfont_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_view2d_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_view3d_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_windowmanager_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/DNA_world_types.h + + PARENT_SCOPE +) + add_subdirectory(intern) diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index f201fa6d9b8..7b53dd9ef77 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -200,6 +200,11 @@ typedef struct PreviewImage { #define ID_REAL_USERS(id) (((ID *)id)->us - ((((ID *)id)->flag & LIB_FAKEUSER) ? 1:0)) +#ifdef GS +#undef GS +#endif +#define GS(a) (*((short *)(a))) + /* id->flag: set frist 8 bits always at zero while reading */ #define LIB_LOCAL 0 #define LIB_EXTERN 1 diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 109430a8b62..9cb9ed851ba 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -530,7 +530,7 @@ typedef enum eDopeSheet_FilterFlag { ADS_FILTER_NOSHAPEKEYS = (1<<6), ADS_FILTER_NOMESH = (1<<7), ADS_FILTER_NOOBJ = (1<<8), /* for animdata on object level, if we only want to concentrate on materials/etc. */ - // NOTE: there are a few more spaces for datablock filtering here... + ADS_FILTER_NOLAT = (1<<9), ADS_FILTER_NOCAM = (1<<10), ADS_FILTER_NOMAT = (1<<11), ADS_FILTER_NOLAM = (1<<12), diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 8fca829101b..37c6200b91f 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -130,6 +130,10 @@ typedef struct Brush { #define BRUSH_FRONTFACE (1<<27) #define BRUSH_CUSTOM_ICON (1<<28) +/* temporary flag which sets up autmatically for correct + brush drawing when inverted modal operator is running */ +#define BRUSH_INVERTED (1<<29) + /* Brush.sculpt_tool */ #define SCULPT_TOOL_DRAW 1 #define SCULPT_TOOL_SMOOTH 2 diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index de6416e4488..08d5258f34b 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -171,7 +171,7 @@ typedef struct Curve { struct BoundBox *bb; ListBase nurb; /* actual data, called splines in rna */ - ListBase disp; + ListBase disp; /* undeformed display list, used mostly for texture space calculation */ EditNurb *editnurb; /* edited data, not in file, use pointer so we can check for it */ diff --git a/source/blender/makesdna/DNA_lattice_types.h b/source/blender/makesdna/DNA_lattice_types.h index 253846dfae5..bf2ada51155 100644 --- a/source/blender/makesdna/DNA_lattice_types.h +++ b/source/blender/makesdna/DNA_lattice_types.h @@ -77,5 +77,7 @@ typedef struct Lattice { #define LT_GRID 1 #define LT_OUTSIDE 2 +#define LT_DS_EXPAND 4 + #endif diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 3f6124c7fa1..1c8610461be 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -550,6 +550,7 @@ typedef struct MeshDeformModifierData { typedef enum { eParticleSystemFlag_Pars = (1<<0), eParticleSystemFlag_psys_updated = (1<<1), + eParticleSystemFlag_file_loaded = (1<<2), } ParticleSystemModifierFlag; typedef struct ParticleSystemModifierData { diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 96f2c1ccc79..1d1ad6ad021 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -152,7 +152,6 @@ typedef struct PTCacheMem { struct PTCacheMem *next, *prev; int frame, totpoint; unsigned int data_types, flag; - int *index_array; /* quick access to stored points with index */ void *data[8]; /* BPHYS_TOT_DATA */ void *cur[8]; /* BPHYS_TOT_DATA */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 87f03aec06a..6d92b1d09a5 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -198,7 +198,7 @@ typedef struct Object { float bbsize[3]; short index; /* custom index, for renderpasses */ unsigned short actdef; /* current deformation group, note: index starts at 1 */ - float col[4]; /* object color, adjusted via IPO's only */ + float col[4]; /* object color */ /** * Settings for game objects * bit 0: Object has dynamic behaviour diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index e336d3056ea..cbc9e0f1c29 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -163,7 +163,7 @@ typedef struct ParticleSettings { /* initial velocity factors */ float normfac, obfac, randfac, partfac, tanfac, tanphase, reactfac; - float ob_vel[3], rt; + float ob_vel[3]; float avefac, phasefac, randrotfac, randphasefac; /* physical properties */ float mass, size, randsize, reactshape; @@ -178,13 +178,17 @@ typedef struct ParticleSettings { /* clumping */ float clumpfac, clumppow; /* kink */ - float kink_amp, kink_freq, kink_shape; + float kink_amp, kink_freq, kink_shape, kink_flat; + float kink_amp_clump; /* rough */ float rough1, rough1_size; float rough2, rough2_size, rough2_thres; float rough_end, rough_end_shape; /* length */ float clength, clength_thres; + /* parting */ + float parting_fac; + float parting_min, parting_max; /* branching */ float branch_thres; /* drawing stuff */ @@ -232,7 +236,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in float imat[4][4]; /* used for duplicators */ float cfra, tree_frame; - int seed, rt; + int seed, child_seed; int flag, totpart, totchild, totcached, totchildcache; short recalc, target_psys, totkeyed, bakespace; @@ -294,18 +298,18 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in #define PART_BOIDS_2D (1<<19) -#define PART_BRANCHING (1<<20) -#define PART_ANIM_BRANCHING (1<<21) -#define PART_SYMM_BRANCHING (1<<24) +//#define PART_BRANCHING (1<<20) +//#define PART_ANIM_BRANCHING (1<<21) +//#define PART_SYMM_BRANCHING (1<<24) #define PART_HAIR_BSPLINE 1024 #define PART_GRID_INVERT (1<<26) -#define PART_CHILD_EFFECT (1<<27) -#define PART_CHILD_SEAMS (1<<28) -#define PART_CHILD_RENDER (1<<29) -#define PART_CHILD_GUIDE (1<<30) +#define PART_CHILD_EFFECT (1<<27) +#define PART_CHILD_LONG_HAIR (1<<28) +#define PART_CHILD_RENDER (1<<29) +#define PART_CHILD_GUIDE (1<<30) #define PART_SELF_EFFECT (1<<22) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 3a8dd13a941..685d8bca30d 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -662,8 +662,11 @@ typedef struct ToolSettings { short uvcalc_mapalign; short uvcalc_flag; short uv_flag, uv_selectmode; - short uv_pad[2]; - + short uv_pad; + + /* Grease Pencil */ + short gpencil_flags; + /* Auto-IK */ short autoik_chainlen; @@ -1199,6 +1202,9 @@ typedef enum SculptFlags { #define EDGE_MODE_TAG_CREASE 3 #define EDGE_MODE_TAG_BEVEL 4 +/* toolsettings->gpencil_flags */ +#define GP_TOOL_FLAG_PAINTSESSIONS_ON (1<<0) + /* toolsettings->particle flag */ #define PE_KEEP_LENGTHS 1 #define PE_LOCK_FIRST 2 diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index f9ba1c2a471..cdb52c83b0a 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -350,7 +350,7 @@ typedef struct UserDef { short tw_hotspot, tw_flag, tw_handlesize, tw_size; short textimeout,texcollectrate; short wmdrawmethod; /* removed wmpad */ - short pad2; + short dragthreshold; int memcachelimit; int prefetchframes; short frameserverport; diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 55a6a3c0879..ba9e7d30e80 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -44,65 +44,7 @@ if(WIN32 AND NOT UNIX) ) endif() -set(SRC_DNA_INC - ../DNA_ID.h - ../DNA_action_types.h - ../DNA_actuator_types.h - ../DNA_anim_types.h - ../DNA_armature_types.h - ../DNA_boid_types.h - ../DNA_brush_types.h - ../DNA_camera_types.h - ../DNA_cloth_types.h - ../DNA_color_types.h - ../DNA_constraint_types.h - ../DNA_controller_types.h - ../DNA_curve_types.h - ../DNA_customdata_types.h - ../DNA_documentation.h - ../DNA_effect_types.h - ../DNA_fileglobal_types.h - ../DNA_genfile.h - ../DNA_gpencil_types.h - ../DNA_group_types.h - ../DNA_image_types.h - ../DNA_ipo_types.h - ../DNA_key_types.h - ../DNA_lamp_types.h - ../DNA_lattice_types.h - ../DNA_listBase.h - ../DNA_material_types.h - ../DNA_mesh_types.h - ../DNA_meshdata_types.h - ../DNA_meta_types.h - ../DNA_modifier_types.h - ../DNA_nla_types.h - ../DNA_node_types.h - ../DNA_object_fluidsim.h - ../DNA_object_force.h - ../DNA_object_types.h - ../DNA_outliner_types.h - ../DNA_packedFile_types.h - ../DNA_particle_types.h - ../DNA_property_types.h - ../DNA_scene_types.h - ../DNA_screen_types.h - ../DNA_sdna_types.h - ../DNA_sensor_types.h - ../DNA_sequence_types.h - ../DNA_smoke_types.h - ../DNA_sound_types.h - ../DNA_space_types.h - ../DNA_text_types.h - ../DNA_texture_types.h - ../DNA_userdef_types.h - ../DNA_vec_types.h - ../DNA_vfont_types.h - ../DNA_view2d_types.h - ../DNA_view3d_types.h - ../DNA_windowmanager_types.h - ../DNA_world_types.h -) +# SRC_DNA_INC is defined in the parent dir add_executable(makesdna ${SRC} ${SRC_DNA_INC}) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 068336a1717..cd14acd520c 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -869,6 +869,10 @@ static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, const cha mul= len/oldsize; mul*= (cursize < oldsize)? cursize: oldsize; memcpy(curdata, olddata, mul); + + /* terminate strings */ + if(oldsize > cursize && strcmp(type, "char")==0) + curdata[mul-1]= 0; } else { if(cursize>oldsize) cast_elem(type, otype, oname, curdata, olddata); diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index 83484f655e9..46b77ea7ec2 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -49,9 +49,6 @@ if env['WITH_BF_LCMS']: if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') -if env['WITH_BF_COLLADA']: - defs.append('WITH_COLLADA') - if env['BF_UNIT_TEST']: defs.append('UNIT_TEST') diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 6e31f874283..94e924f203e 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -38,6 +38,12 @@ list(REMOVE_ITEM DEFSRC ${APISRC}) string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") set_source_files_properties(GENSRC PROPERTIES GENERATED true) +set(SRC_RNA_INC + ../RNA_access.h + ../RNA_define.h + ../RNA_enum_types.h + ../RNA_types.h +) set(SRC makesrna.c @@ -48,28 +54,9 @@ set(SRC ../../../../intern/guardedalloc/intern/mmap_win.c ) -blender_include_dirs( - ../../../../intern/audaspace/intern - ../../../../intern/guardedalloc - ../../../../intern/memutil - .. - ../../makesdna - ../../blenkernel - ../../blenlib - ../../blenfont - ../../ikplugin - ../../windowmanager - ../../editors/include - ../../gpu - ../../imbuf - ../../render/extern/include - ../../../../extern/glew/include - ../../freestyle - . +set(INC ) -file(GLOB INC_FILES ../*.h ../../makesdna/*.h) - if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() @@ -137,12 +124,28 @@ if(WITH_JACK) add_definitions(-DWITH_JACK) endif() -if(WITH_OPENCOLLADA) - add_definitions(-DWITH_COLLADA) -endif() - # Build makesrna executable -add_executable(makesrna ${SRC} ${INC_FILES}) +blender_include_dirs( + . + .. + ../../blenkernel + ../../blenlib + ../../blenfont + ../../gpu + ../../imbuf + ../../ikplugin + ../../makesdna + ../../windowmanager + ../../editors/include + ../../render/extern/include + ../../freestyle + ../../../../extern/glew/include + ../../../../intern/audaspace/intern + ../../../../intern/guardedalloc + ../../../../intern/memutil +) + +add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC}) target_link_libraries(makesrna bf_dna) # Output rna_*_gen.c @@ -158,11 +161,7 @@ set(SRC rna_access.c ${GENSRC} - ../RNA_access.h - ../RNA_define.h - ../RNA_enum_types.h - ../RNA_types.h - + ${SRC_RNA_INC} rna_internal.h rna_internal_types.h rna_nodetree_types.h diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index ac71e292552..5d49b626f54 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -88,9 +88,6 @@ if env['BF_UNIT_TEST']: if env['WITH_BF_PYTHON']: defs.append('WITH_PYTHON') -if env['WITH_BF_COLLADA']: - defs.append('WITH_COLLADA') - if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 5670c0a7945..9f30f2c1d8c 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -68,7 +68,18 @@ static int replace_if_different(char *tmpfile, const char *dep_files[]) // return 0; // use for testing had edited rna #define REN_IF_DIFF \ - remove(orgfile); \ + { \ + FILE *file_test= fopen(orgfile, "rb"); \ + if(file_test) { \ + fclose(file_test); \ + if(fp_org) fclose(fp_org); \ + if(fp_new) fclose(fp_new); \ + if(remove(orgfile) != 0) { \ + fprintf(stderr, "%s:%d, Remove Error (%s): \"%s\"\n", __FILE__, __LINE__, strerror(errno), orgfile); \ + return -1; \ + } \ + } \ + } \ if(rename(tmpfile, orgfile) != 0) { \ fprintf(stderr, "%s:%d, Rename Error (%s): \"%s\" -> \"%s\"\n", __FILE__, __LINE__, strerror(errno), tmpfile, orgfile); \ return -1; \ @@ -78,7 +89,7 @@ static int replace_if_different(char *tmpfile, const char *dep_files[]) /* end REN_IF_DIFF */ - FILE *fp_new, *fp_org; + FILE *fp_new= NULL, *fp_org= NULL; int len_new, len_org; char *arr_new, *arr_org; int cmp; @@ -954,16 +965,16 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property func= rna_alloc_function_name(srna->identifier, prop->identifier, "lookup_int"); - fprintf(f, "PointerRNA %s(PointerRNA *ptr, int index)\n", func); + fprintf(f, "int %s(PointerRNA *ptr, int index, PointerRNA *r_ptr)\n", func); fprintf(f, "{\n"); if(manualfunc) { - fprintf(f, "\n return %s(ptr, index);\n", manualfunc); + fprintf(f, "\n return %s(ptr, index, r_ptr);\n", manualfunc); fprintf(f, "}\n\n"); return func; } - fprintf(f, " PointerRNA r_ptr;\n"); + fprintf(f, " int found= 0;\n"); fprintf(f, " CollectionPropertyIterator iter;\n\n"); fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, prop->identifier); @@ -973,9 +984,9 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property fprintf(f, " ArrayIterator *internal= iter.internal;\n"); fprintf(f, " if(index < 0 || index >= internal->length) {\n"); fprintf(f, "#ifdef __GNUC__\n"); - fprintf(f, " printf(\"Array itterator out of range: %%s (index %%d range %%d)\\n\", __func__, index, internal->length); \n"); + fprintf(f, " printf(\"Array iterator out of range: %%s (index %%d range %%d)\\n\", __func__, index, internal->length); \n"); fprintf(f, "#else\n"); - fprintf(f, " printf(\"Array itterator out of range: (index %%d range %%d)\\n\", index, internal->length); \n"); + fprintf(f, " printf(\"Array iterator out of range: (index %%d range %%d)\\n\", index, internal->length); \n"); fprintf(f, "#endif\n"); fprintf(f, " }\n"); fprintf(f, " else if(internal->skip) {\n"); @@ -984,9 +995,11 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property fprintf(f, " internal->ptr += internal->itemsize;\n"); fprintf(f, " } while(internal->skip(&iter, internal->ptr));\n"); fprintf(f, " }\n"); + fprintf(f, " found= 1;\n"); fprintf(f, " }\n"); fprintf(f, " else {\n"); fprintf(f, " internal->ptr += internal->itemsize*index;\n"); + fprintf(f, " found= 1;\n"); fprintf(f, " }\n"); } else if(strcmp(nextfunc, "rna_iterator_listbase_next") == 0) { @@ -1002,14 +1015,15 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property fprintf(f, " while(index-- > 0 && internal->link)\n"); fprintf(f, " internal->link= internal->link->next;\n"); fprintf(f, " }\n"); + fprintf(f, " found= (index == -1);\n"); } fprintf(f, " }\n\n"); - fprintf(f, " r_ptr = %s_%s_get(&iter);\n", srna->identifier, prop->identifier); + fprintf(f, " if(found) *r_ptr = %s_%s_get(&iter);\n", srna->identifier, prop->identifier); fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, prop->identifier); - fprintf(f, " return r_ptr;\n"); + fprintf(f, " return found;\n"); #if 0 rna_print_data_get(f, dp); @@ -1485,6 +1499,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA PropertyType type; const char *funcname, *valstr; const char *ptrstr; + const short has_data= (dfunc->cont.properties.first != NULL); int flag, pout, cptr, first; srna= dsrna->srna; @@ -1538,10 +1553,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier); } - fprintf(f, "\tchar *_data"); - if(func->c_ret) fprintf(f, ", *_retdata"); - fprintf(f, ";\n"); - fprintf(f, "\t\n"); + if(has_data) { + fprintf(f, "\tchar *_data"); + if(func->c_ret) fprintf(f, ", *_retdata"); + fprintf(f, ";\n"); + fprintf(f, "\t\n"); + } /* assign self */ if(func->flag & FUNC_USE_SELF_ID) { @@ -1553,7 +1570,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier); } - fprintf(f, "\t_data= (char *)_parms->data;\n"); + if(has_data) { + fprintf(f, "\t_data= (char *)_parms->data;\n"); + } dparm= dfunc->cont.properties.first; for(; dparm; dparm= dparm->next) { @@ -2406,12 +2425,12 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const fprintf(f, "#include \"DNA_scene_types.h\"\n"); fprintf(f, "#include \"BLI_blenlib.h\"\n\n"); + fprintf(f, "#include \"BLI_utildefines.h\"\n\n"); fprintf(f, "#include \"BKE_context.h\"\n"); fprintf(f, "#include \"BKE_library.h\"\n"); fprintf(f, "#include \"BKE_main.h\"\n"); fprintf(f, "#include \"BKE_report.h\"\n"); - fprintf(f, "#include \"BKE_utildefines.h\"\n\n"); fprintf(f, "#include \"RNA_define.h\"\n"); fprintf(f, "#include \"RNA_types.h\"\n"); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index af4bc381930..96f4c85cbb5 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -30,6 +30,7 @@ #include "DNA_ID.h" #include "DNA_vfont_types.h" +#include "DNA_object_types.h" #include "WM_types.h" @@ -74,6 +75,7 @@ EnumPropertyItem id_type_items[] = { #include "BKE_library.h" #include "BKE_animsys.h" #include "BKE_material.h" +#include "BKE_depsgraph.h" /* name functions that ignore the first two ID characters */ void rna_ID_name_get(PointerRNA *ptr, char *value) @@ -251,6 +253,43 @@ ID *rna_ID_copy(ID *id) return NULL; } +static void rna_ID_update(ID *id, ReportList *reports, int flag) +{ + /* XXX, new function for this! */ + /*if (ob->type == OB_FONT) { + Curve *cu = ob->data; + freedisplist(&cu->disp); + BKE_text_to_curve(sce, ob, CU_LEFT); + }*/ + + if(flag == 0) { + /* pass */ + } + else { + /* ensure flag us correct for the type */ + switch(GS(id->name)) { + case ID_OB: + if(flag & ~(OB_RECALC_ALL)) { + BKE_report(reports, RPT_ERROR, "'refresh' incompatible with Object ID type"); + return; + } + break; + /* Could add particle updates later */ +/* case ID_PA: + if(flag & ~(OB_RECALC_ALL|PSYS_RECALC)) { + BKE_report(reports, RPT_ERROR, "'refresh' incompatible with ParticleSettings ID type"); + return; + } + break; */ + default: + BKE_report(reports, RPT_ERROR, "This ID type is not compatible with any 'refresh' options"); + return; + } + } + + DAG_id_tag_update(id, flag); +} + void rna_ID_user_clear(ID *id) { id->us= 0; /* dont save */ @@ -385,6 +424,12 @@ static void rna_def_ID(BlenderRNA *brna) FunctionRNA *func; PropertyRNA *prop, *parm; + static EnumPropertyItem update_flag_items[] = { + {OB_RECALC_OB, "OBJECT", 0, "Object", ""}, + {OB_RECALC_DATA, "DATA", 0, "Data", ""}, + {OB_RECALC_TIME, "TIME", 0, "Time", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "ID", NULL); RNA_def_struct_ui_text(srna, "ID", "Base type for datablocks, defining a unique name, linking from other libraries and garbage collection"); RNA_def_struct_flag(srna, STRUCT_ID|STRUCT_ID_REFCOUNT); @@ -436,6 +481,11 @@ static void rna_def_ID(BlenderRNA *brna) func= RNA_def_function(srna, "animation_data_clear", "BKE_free_animdata"); RNA_def_function_ui_description(func, "Clear animation on this this ID."); + func= RNA_def_function(srna, "update", "rna_ID_update"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Tag the id to update its display data."); + parm= RNA_def_enum(func, "refresh", update_flag_items, 0, "", "Type of updates to perform."); + RNA_def_property_flag(parm, PROP_ENUM_FLAG); } static void rna_def_library(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 5dba0a41a02..d509efbb927 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -34,6 +34,7 @@ #include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_dynstr.h" #include "BLI_ghash.h" @@ -42,7 +43,7 @@ #include "BKE_idprop.h" #include "BKE_main.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + #include "WM_api.h" @@ -704,8 +705,8 @@ int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[ { PropertyRNA *rprop= rna_ensure_property(prop); - if(length && rprop->arraydimension > 1) - rna_ensure_property_multi_array_length(ptr, prop, length); + if(length) + rna_ensure_property_multi_array_length(ptr, prop, length); return rprop->arraydimension; } @@ -2302,8 +2303,7 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int k if(cprop->lookupint) { /* we have a callback defined, use it */ - *r_ptr= cprop->lookupint(ptr, key); - return (r_ptr->data != NULL); + return cprop->lookupint(ptr, key, r_ptr); } else { /* no callback defined, just iterate and find the nth item */ @@ -2332,8 +2332,7 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co if(cprop->lookupstring) { /* we have a callback defined, use it */ - *r_ptr= cprop->lookupstring(ptr, key); - return (r_ptr->data != NULL); + return cprop->lookupstring(ptr, key, r_ptr); } else { /* no callback defined, compare with name properties if they exist */ @@ -4208,8 +4207,6 @@ void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter) void RNA_parameter_list_next(ParameterIterator *iter) { - PropertyType ptype; - iter->offset+= iter->size; iter->parm= iter->parm->next; iter->valid= iter->parm != NULL; @@ -4217,7 +4214,6 @@ void RNA_parameter_list_next(ParameterIterator *iter) if(iter->valid) { iter->size= rna_parameter_size_alloc(iter->parm); iter->data= (((char*)iter->parms->data)+iter->offset); - ptype= RNA_property_type(iter->parm); } } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 5077db345dc..09b9960deae 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -235,6 +235,12 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + prop= RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT); + RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of Lattice related Animation data"); + RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0); + RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + prop= RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM); RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data"); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 1cf6ffb00bc..40755e0dfd1 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -51,7 +51,7 @@ static void rna_Armature_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id= ptr->id.data; - DAG_id_tag_update(id, OB_RECALC_DATA); + DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, id); //WM_main_add_notifier(NC_OBJECT|ND_POSE, NULL); } diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 0af8828be01..60c28d8bae1 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -37,7 +37,6 @@ #include "IMB_imbuf.h" - #include "WM_types.h" static EnumPropertyItem prop_direction_items[]= { @@ -93,7 +92,6 @@ EnumPropertyItem brush_imagepaint_tool_items[] = { #include "BKE_texture.h" #include "BKE_brush.h" #include "BKE_icons.h" - #include "BKE_paint.h" #include "WM_api.h" @@ -792,6 +790,11 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna) prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_ui_text(prop, "Time", ""); + + /* used for Grease Pencil sketching sessions */ + prop= RNA_def_property(srna, "is_start", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_IDPROPERTY); + RNA_def_property_ui_text(prop, "Is Stroke Start", ""); /* XXX: Tool (this will be for pressing a modifier key for a different brush, e.g. switching to a Smooth brush in the middle of the stroke */ diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index e23d9a288cb..112526cec46 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -96,8 +96,6 @@ EnumPropertyItem constraint_ik_axisref_items[] ={ #ifdef RNA_RUNTIME -#include <stdio.h> - #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_constraint.h" diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index aaf322ee12c..8b9166b919f 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -175,6 +175,14 @@ static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values) bt->vec[1][2]= values[2]; } +static void rna_Curve_texspace_set(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->data; + + if (cu->texflag & CU_AUTOSPACE) + tex_space_curve(cu); +} + static int rna_Curve_texspace_editable(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->data; @@ -278,7 +286,7 @@ static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA static void rna_Curve_update_data_id(Main *bmain, Scene *scene, ID *id) { - DAG_id_tag_update(id, OB_RECALC_DATA); + DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, id); } @@ -1355,7 +1363,8 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE); RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjusts active object's texture space automatically when transforming object"); - + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Curve_texspace_set"); + prop= RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 963c4b98758..d2bd974d62a 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -34,10 +34,11 @@ #include "DNA_genfile.h" #include "DNA_sdna_types.h" -#include "RNA_define.h" - -#include "BLI_ghash.h" #include "BLI_string.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +#include "RNA_define.h" #include "rna_internal.h" diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index af98f6792e4..96ec09f844e 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -334,19 +334,36 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value) static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value) { - AnimData *adt= BKE_animdata_from_id(ptr->id.data); - bAction *act= (adt) ? adt->action : NULL; + ID *pid = (ID *)ptr->id.data; + ID *vid = (ID *)value.id.data; FCurve *fcu= ptr->data; - - /* same ID? */ - if (value.data && (ptr->id.data != value.id.data)) { + bAction *act = NULL; + + /* get action */ + if (ELEM(NULL, pid, vid)) { + printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid); + return; + } + else if (value.data && (pid != vid)) { /* id's differ, cant do this, should raise an error */ + printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid); return; } + + if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) { + /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */ + act = (bAction *)pid; + } + else { + /* the ID given is the owner of the F-Curve (for drivers) */ + AnimData *adt = BKE_animdata_from_id(ptr->id.data); + act = (adt)? adt->action : NULL; + } + /* already belongs to group? */ if (fcu->grp == value.data) { /* nothing to do */ - printf("ERROR: F-Curve already belongs to the group\n"); + printf("ERROR: F-Curve already belongs to this group\n"); return; } @@ -357,18 +374,16 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value) /* can't change the grouping of F-Curve when it doesn't belong to an action */ printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n"); return; - } - - /* try to remove F-Curve from action (including from any existing groups) - * - if after this op it is still attached to something, then it is a driver - * not an animation curve as we thought, and we should exit - */ - action_groups_remove_channel(act, fcu); - if (fcu->next) { - /* F-Curve is not one that exists in the action, since the above op couldn't remove it from the list */ + } + /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */ + else if (BLI_findindex(&act->curves, fcu) == -1) { + printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name); return; } + /* try to remove F-Curve from action (including from any existing groups) */ + action_groups_remove_channel(act, fcu); + /* add the F-Curve back to the action now in the right place */ // TODO: make the api function handle the case where there isn't any group to assign to if (value.data) { @@ -1320,9 +1335,9 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); /* optional */ - parm= RNA_def_boolean(func, "replace", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"); - parm= RNA_def_boolean(func, "needed", 0, "Needed", "Only adds keyframes that are needed"); - parm= RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"); + RNA_def_boolean(func, "replace", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"); + RNA_def_boolean(func, "needed", 0, "Needed", "Only adds keyframes that are needed"); + RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"); parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe"); RNA_def_function_return(func, parm); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 699b21e840e..4f7f32d72c0 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -40,7 +40,7 @@ #include "BKE_image.h" #include "BKE_packedFile.h" #include "BKE_main.h" -#include "BKE_utildefines.h" + #include "BKE_global.h" /* grr: G.main->name */ #include "IMB_imbuf.h" diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index fbd4fa7bfdc..280f5d882b4 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -303,7 +303,7 @@ void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struc void rna_builtin_properties_next(struct CollectionPropertyIterator *iter); PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter); PointerRNA rna_builtin_type_get(struct PointerRNA *ptr); -PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key); +int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr); /* Iterators */ diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 216533a8708..ee484c27c03 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -93,8 +93,8 @@ typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter); typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter); typedef PointerRNA (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter); typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr); -typedef PointerRNA (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key); -typedef PointerRNA (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key); +typedef int (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key, struct PointerRNA *r_ptr); +typedef int (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key, struct PointerRNA *r_ptr); /* Container - generic abstracted container of RNA properties */ typedef struct ContainerRNA { diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 47a14c3dac7..d4021dc1cec 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -97,6 +97,47 @@ static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max) *max= data->slidermax; } +/* epsilon for how close one end of shapekey range can get to the other */ +#define SHAPEKEY_SLIDER_TOL 0.001 + +static void rna_ShapeKey_slider_min_range(PointerRNA *ptr, float *min, float *max) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + + *min= -10.0f; + *max= data->slidermax - SHAPEKEY_SLIDER_TOL; +} + +static void rna_ShapeKey_slider_min_set(PointerRNA *ptr, float value) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + float min, max; + + rna_ShapeKey_slider_min_range(ptr, &min, &max); + CLAMP(value, min, max); + data->slidermin = value; +} + +static void rna_ShapeKey_slider_max_range(PointerRNA *ptr, float *min, float *max) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + + *min= data->slidermin + SHAPEKEY_SLIDER_TOL; + *max= 10.0f; +} + +static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + float min, max; + + rna_ShapeKey_slider_max_range(ptr, &min, &max); + CLAMP(value, min, max); + data->slidermax = value; +} + +#undef SHAPEKEY_SLIDER_TOL + PointerRNA rna_object_shapekey_index_get(ID *id, int value) { Key *key= rna_ShapeKey_find_key(id); @@ -446,12 +487,14 @@ static void rna_def_keyblock(BlenderRNA *brna) prop= RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "slidermin"); RNA_def_property_range(prop, -10.0f, 10.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_min_set", "rna_ShapeKey_slider_min_range"); RNA_def_property_ui_text(prop, "Slider Min", "Minimum for slider"); prop= RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "slidermax"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_max_set", "rna_ShapeKey_slider_max_range"); RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider"); prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 3285ed4e392..de09d9605cd 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -91,7 +91,7 @@ static void rna_Lattice_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id= ptr->id.data; - DAG_id_tag_update(id, OB_RECALC_DATA); + DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, id); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 2a2e4de9032..91220852e6d 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -490,6 +490,36 @@ void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineS /* XXX python now has invalid pointer? */ } +/* tag functions, all the same */ +void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); } +void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); } +void rna_Main_objects_tag(Main *bmain, int value) { tag_main_lb(&bmain->object, value); } +void rna_Main_materials_tag(Main *bmain, int value) { tag_main_lb(&bmain->mat, value); } +void rna_Main_node_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->nodetree, value); } +void rna_Main_meshes_tag(Main *bmain, int value) { tag_main_lb(&bmain->mesh, value); } +void rna_Main_lamps_tag(Main *bmain, int value) { tag_main_lb(&bmain->lamp, value); } +void rna_Main_libraries_tag(Main *bmain, int value) { tag_main_lb(&bmain->library, value); } +void rna_Main_screens_tag(Main *bmain, int value) { tag_main_lb(&bmain->screen, value); } +void rna_Main_window_managers_tag(Main *bmain, int value) { tag_main_lb(&bmain->wm, value); } +void rna_Main_images_tag(Main *bmain, int value) { tag_main_lb(&bmain->image, value); } +void rna_Main_lattices_tag(Main *bmain, int value) { tag_main_lb(&bmain->latt, value); } +void rna_Main_curves_tag(Main *bmain, int value) { tag_main_lb(&bmain->curve, value); } +void rna_Main_metaballs_tag(Main *bmain, int value) { tag_main_lb(&bmain->mball, value); } +void rna_Main_fonts_tag(Main *bmain, int value) { tag_main_lb(&bmain->vfont, value); } +void rna_Main_textures_tag(Main *bmain, int value) { tag_main_lb(&bmain->tex, value); } +void rna_Main_brushes_tag(Main *bmain, int value) { tag_main_lb(&bmain->brush, value); } +void rna_Main_worlds_tag(Main *bmain, int value) { tag_main_lb(&bmain->world, value); } +void rna_Main_groups_tag(Main *bmain, int value) { tag_main_lb(&bmain->group, value); } +void rna_Main_shape_keys_tag(Main *bmain, int value) { tag_main_lb(&bmain->key, value); } +void rna_Main_scripts_tag(Main *bmain, int value) { tag_main_lb(&bmain->script, value); } +void rna_Main_texts_tag(Main *bmain, int value) { tag_main_lb(&bmain->text, value); } +void rna_Main_sounds_tag(Main *bmain, int value) { tag_main_lb(&bmain->sound, value); } +void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armature, value); } +void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); } +void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); } +void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); } +void rna_Main_linestyle_tag(Main *bmain, int value) { tag_main_lb(&bmain->linestyle, value); } + #else void RNA_api_main(StructRNA *srna) @@ -534,6 +564,10 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a camera from the current blendfile."); parm= RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_cameras_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) @@ -588,6 +622,10 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_objects_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) @@ -613,6 +651,10 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a material from the current blendfile."); parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_materials_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) { @@ -645,6 +687,10 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a node tree from the current blendfile."); parm= RNA_def_pointer(func, "tree", "NodeTree", "", "Node tree to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_node_groups_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) { @@ -669,6 +715,10 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile."); parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_meshes_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) { @@ -693,18 +743,55 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile."); parm= RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_lamps_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } + void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainLibraries"); + srna= RNA_def_struct(brna, "MainLibraries", NULL); + RNA_def_struct_ui_text(srna, "Main Libraries", "Collection of libraries"); + func= RNA_def_function(srna, "tag", "rna_Main_libraries_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } + void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainScreens"); + srna= RNA_def_struct(brna, "MainScreens", NULL); + RNA_def_struct_ui_text(srna, "Main Screens", "Collection of screens"); + + func= RNA_def_function(srna, "tag", "rna_Main_screens_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } + void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainWindowManagers"); + srna= RNA_def_struct(brna, "MainWindowManagers", NULL); + RNA_def_struct_ui_text(srna, "Main Window Managers", "Collection of window managers"); + + func= RNA_def_function(srna, "tag", "rna_Main_window_managers_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) { @@ -742,6 +829,10 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove an image from the current blendfile."); parm= RNA_def_pointer(func, "image", "Image", "", "Image to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_images_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) @@ -767,6 +858,10 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a lattice from the current blendfile."); parm= RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_lattices_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) { @@ -793,6 +888,10 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a curve from the current blendfile."); parm= RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_curves_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) { @@ -817,6 +916,10 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a metaball from the current blendfile."); parm= RNA_def_pointer(func, "metaball", "MetaBall", "", "MetaBall to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_metaballs_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) { @@ -842,6 +945,10 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a font from the current blendfile."); parm= RNA_def_pointer(func, "vfont", "VectorFont", "", "Font to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_fonts_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) { @@ -868,6 +975,10 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a texture from the current blendfile."); parm= RNA_def_pointer(func, "texture", "Texture", "", "Texture to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_textures_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) { @@ -892,6 +1003,10 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a brush from the current blendfile."); parm= RNA_def_pointer(func, "brush", "Brush", "", "Brush to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_brushes_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) @@ -917,6 +1032,10 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a world from the current blendfile."); parm= RNA_def_pointer(func, "world", "World", "", "World to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_worlds_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) @@ -942,6 +1061,10 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a group from the current blendfile."); parm= RNA_def_pointer(func, "group", "Group", "", "Group to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_groups_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) { @@ -976,11 +1099,29 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) /* return type */ parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock."); RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "tag", "rna_Main_texts_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } + void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainSounds"); + srna= RNA_def_struct(brna, "MainSounds", NULL); + RNA_def_struct_ui_text(srna, "Main Sounds", "Collection of sounds"); + + /* TODO, 'load' */ + func= RNA_def_function(srna, "tag", "rna_Main_sounds_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } + void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -1004,6 +1145,10 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a armature from the current blendfile."); parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_armatures_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) { @@ -1028,6 +1173,10 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a action from the current blendfile."); parm= RNA_def_pointer(func, "action", "Action", "", "Action to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_actions_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) { @@ -1052,10 +1201,25 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a particle settings instance from the current blendfile."); parm= RNA_def_pointer(func, "particle", "ParticleSettings", "", "Particle Settings to remove."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "tag", "rna_Main_particles_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } + void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + RNA_def_property_srna(cprop, "MainGreasePencils"); + srna= RNA_def_struct(brna, "MainGreasePencils", NULL); + RNA_def_struct_ui_text(srna, "Main Grease Pencils", "Collection of grease pencils"); + + func= RNA_def_function(srna, "tag", "rna_Main_gpencil_tag"); + parm= RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) { diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 43dfd36d516..0fdb42f9146 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -367,6 +367,11 @@ static void rna_def_material_mtex(BlenderRNA *brna) {MTEX_NSPACE_TANGENT, "TANGENT", 0, "Tangent", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_bump_method_items[] = { + {0, "BUMP_ORIGINAL", 0, "Original", ""}, + {MTEX_NEW_BUMP, "BUMP_IMPROVED", 0, "Improved", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "MaterialTextureSlot", "TextureSlot"); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Material Texture Slot", "Texture slot for textures in a Material datablock"); @@ -668,9 +673,10 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot"); RNA_def_property_update(prop, 0, "rna_Material_update"); - prop= RNA_def_property(srna, "use_old_bump", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "texflag", MTEX_NEW_BUMP); - RNA_def_property_ui_text(prop, "Old Bump", "Use old bump mapping (backwards compatibility option)"); + prop= RNA_def_property(srna, "bump_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag"); + RNA_def_property_enum_items(prop, prop_bump_method_items); + RNA_def_property_ui_text(prop, "Bump Method", "Method to use for bump mapping"); RNA_def_property_update(prop, 0, "rna_Material_update"); } @@ -1601,7 +1607,7 @@ void RNA_def_material(BlenderRNA *brna) prop= RNA_def_property(srna, "use_object_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR); RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop= RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sbias"); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index e9490d2bc8a..fbbc88cc481 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -46,7 +46,7 @@ #include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" + #include "ED_mesh.h" /* XXX Bad level call */ @@ -59,7 +59,7 @@ static void rna_Mesh_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) /* cheating way for importers to avoid slow updates */ if(id->us > 0) { - DAG_id_tag_update(id, OB_RECALC_DATA); + DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, id); } } @@ -229,6 +229,15 @@ static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) (&mcol[3].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255)); } +static void rna_Mesh_texspace_set(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Mesh *me= (Mesh*)ptr->data; + + if (me->texflag & AUTOSPACE) + tex_space_mesh(me); +} + + static int rna_Mesh_texspace_editable(PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; @@ -1718,7 +1727,7 @@ static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "new", "rna_Mesh_vertex_color_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh."); - parm= RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); + RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer."); RNA_def_function_return(func, parm); @@ -1759,7 +1768,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh."); - parm= RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); + RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer."); RNA_def_function_return(func, parm); @@ -1903,6 +1912,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", AUTOSPACE); RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjusts active object's texture space automatically when transforming object"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Mesh_texspace_set"); prop= RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index b0ece32b6db..f1d41d86695 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -98,7 +98,7 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) if(ob->data == mb) copy_mball_properties(scene, ob); - DAG_id_tag_update(&mb->id, OB_RECALC_DATA); + DAG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, mb); } } @@ -116,7 +116,7 @@ static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type) /* cheating way for importers to avoid slow updates */ if(mb->id.us > 0) { - DAG_id_tag_update(&mb->id, OB_RECALC_DATA); + DAG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); } @@ -139,7 +139,7 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Meta /* cheating way for importers to avoid slow updates */ if(mb->id.us > 0) { - DAG_id_tag_update(&mb->id, OB_RECALC_DATA); + DAG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); } } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d13564b6621..e40506fcd83 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -41,6 +41,7 @@ #include "BKE_texture.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "WM_types.h" diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 978171997ef..6cb5a074c03 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -125,6 +125,7 @@ EnumPropertyItem object_type_curve_items[] = { #include "DNA_key_types.h" #include "DNA_constraint_types.h" +#include "DNA_lattice_types.h" #include "BKE_armature.h" #include "BKE_bullet.h" @@ -1114,10 +1115,60 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) } -static void rna_Object_add_vertex_to_group(Object *ob, int index_len, int *index, bDeformGroup *def, float weight, int assignmode) +static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name) { + bDeformGroup *defgroup = ED_vgroup_add_name(ob, name); + + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); + + return defgroup; +} + +static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) +{ + ED_vgroup_delete(ob, defgroup); + + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); +} + +static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len, int *index, float weight, int assignmode) +{ + Object *ob = (Object *)id; + + if(ED_vgroup_object_is_edit_mode(ob)) { + BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode."); + return; + } + while(index_len--) - ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); + ED_vgroup_vert_add(ob, def, *index++, weight, assignmode); /* XXX, not efficient calling within loop*/ + + WM_main_add_notifier(NC_GEOM|ND_DATA, (ID *)ob->data); +} + +static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *reports, int index_len, int *index) +{ + Object *ob = (Object *)id; + + if(ED_vgroup_object_is_edit_mode(ob)) { + BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode."); + return; + } + + while(index_len--) + ED_vgroup_vert_remove(ob, dg, *index++); + + WM_main_add_notifier(NC_GEOM|ND_DATA, (ID *)ob->data); +} + +static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index) +{ + float weight = ED_vgroup_vert_weight((Object *)id, dg, index); + + if(weight < 0) { + BKE_reportf(reports, RPT_ERROR, "Vertex not in group"); + } + return weight; } /* generic poll functions */ @@ -1154,6 +1205,14 @@ static void rna_def_vertex_group(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; + + static EnumPropertyItem assign_mode_items[] = { + {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"}, + {WEIGHT_ADD, "ADD", 0, "Add", "Add"}, + {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"}, + {0, NULL, 0, NULL, NULL} + }; srna= RNA_def_struct(brna, "VertexGroup", NULL); RNA_def_struct_sdna(srna, "bDeformGroup"); @@ -1169,6 +1228,32 @@ static void rna_def_vertex_group(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", NULL, NULL); RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group"); + + func= RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add"); + RNA_def_function_ui_description(func, "Add vertices to the group."); + RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); + /* TODO, see how array size of 0 works, this shouldnt be used */ + prop= RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List.", 0, 0); + RNA_def_property_flag(prop, PROP_DYNAMIC|PROP_REQUIRED); + prop= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop= RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode."); + RNA_def_property_flag(prop, PROP_REQUIRED); + + func= RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove"); + RNA_def_function_ui_description(func, "Remove a vertex from the group."); + RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); + /* TODO, see how array size of 0 works, this shouldnt be used */ + prop= RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List.", 0, 0); + RNA_def_property_flag(prop, PROP_DYNAMIC|PROP_REQUIRED); + + func= RNA_def_function(srna, "weight", "rna_VertexGroup_weight"); + RNA_def_function_ui_description(func, "Get a vertex weight from the group."); + RNA_def_function_flag(func, FUNC_USE_REPORTS|FUNC_USE_SELF_ID); + prop=RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex.", 0, INT_MAX); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f); + RNA_def_function_return(func, prop); } static void rna_def_material_slot(BlenderRNA *brna) @@ -1545,13 +1630,6 @@ static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop /* object.vertex_groups */ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) { - static EnumPropertyItem assign_mode_items[] = { - {WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"}, - {WEIGHT_ADD, "ADD", 0, "Add", "Add"}, - {WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"}, - {0, NULL, 0, NULL, NULL} - }; - StructRNA *srna; PropertyRNA *prop; @@ -1578,24 +1656,16 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data"); /* vertex groups */ // add_vertex_group - func= RNA_def_function(srna, "new", "ED_vgroup_add_name"); + func= RNA_def_function(srna, "new", "rna_Object_vgroup_new"); RNA_def_function_ui_description(func, "Add vertex group to object."); parm= RNA_def_string(func, "name", "Group", 0, "", "Vertex group name."); /* optional */ parm= RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group."); RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "assign", "rna_Object_add_vertex_to_group"); - RNA_def_function_ui_description(func, "Add vertex to a vertex group."); - /* TODO, see how array size of 0 works, this shouldnt be used */ - parm= RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List.", 0, 0); - RNA_def_property_flag(parm, PROP_DYNAMIC); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to add vertex to."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode."); - RNA_def_property_flag(parm, PROP_REQUIRED); + func= RNA_def_function(srna, "remove", "rna_Object_vgroup_remove"); + RNA_def_function_ui_description(func, "Delete vertex group from object."); + parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 96f24c4ecc9..945d0dbb123 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -262,25 +262,6 @@ static void rna_Object_free_duplilist(Object *ob, ReportList *reports) } } -/* copied from old API Object.makeDisplayList (Object.c) - * use _ suffix because this exists for internal rna */ -static void rna_Object_update(Object *ob, Scene *sce, int object, int data, int time) -{ - int flag= 0; - - if (ob->type == OB_FONT) { - Curve *cu = ob->data; - freedisplist(&cu->disp); - BKE_text_to_curve(sce, ob, CU_LEFT); - } - - if(object) flag |= OB_RECALC_OB; - if(data) flag |= OB_RECALC_DATA; - if(time) flag |= OB_RECALC_TIME; - - DAG_id_tag_update(&ob->id, flag); -} - static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix) { Scene *scene= CTX_data_scene(C); @@ -462,16 +443,6 @@ void RNA_api_object(StructRNA *srna) parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0); RNA_def_function_output(func, parm); - - /* DAG */ - func= RNA_def_function(srna, "update", "rna_Object_update"); - RNA_def_function_ui_description(func, "Tag the object to update its display data."); - parm= RNA_def_pointer(func, "scene", "Scene", "", ""); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); - RNA_def_boolean(func, "object", 1, "", "Tag the object for updating"); - RNA_def_boolean(func, "data", 1, "", "Tag the objects display data for updating"); - RNA_def_boolean(func, "time", 1, "", "Tag the object time related data for updating"); - /* View */ func= RNA_def_function(srna, "is_visible", "rna_Object_is_visible"); RNA_def_function_ui_description(func, "Determine if object is visible in a given scene."); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 90aeba65118..cb17893ce0d 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -95,6 +95,9 @@ EnumPropertyItem part_hair_ren_as_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math.h" +#include "BLI_listbase.h" + #include "BKE_context.h" #include "BKE_cloth.h" #include "BKE_deform.h" @@ -104,9 +107,6 @@ EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BLI_math.h" -#include "BLI_listbase.h" - /* use for object space hair get/set */ static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSystemModifierData **psmd_pt, ParticleData **pa_pt) { @@ -899,7 +899,7 @@ static void rna_def_particle(BlenderRNA *brna) /* Hair & Keyed Keys */ - prop= RNA_def_property(srna, "is_hair", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "hair", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "hair", "totkey"); RNA_def_property_struct_type(prop, "ParticleHairKey"); RNA_def_property_ui_text(prop, "Hair", ""); @@ -1103,8 +1103,8 @@ static void rna_def_particle_settings(BlenderRNA *brna) static EnumPropertyItem child_type_items[] = { {0, "NONE", 0, "None", ""}, - {PART_CHILD_PARTICLES, "PARTICLES", 0, "Particles", ""}, - {PART_CHILD_FACES, "FACES", 0, "Faces", ""}, + {PART_CHILD_PARTICLES, "SIMPLE", 0, "Simple", ""}, + {PART_CHILD_FACES, "INTERPOLATED", 0, "Interpolated", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1239,21 +1239,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Boids 2D", "Constrain boids to a surface"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); - prop= RNA_def_property(srna, "use_branching", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_BRANCHING); - RNA_def_property_ui_text(prop, "Branching", "Branch child paths from each other"); - RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); - - prop= RNA_def_property(srna, "use_animate_branching", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ANIM_BRANCHING); - RNA_def_property_ui_text(prop, "Animated", "Animate branching"); - RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); - - prop= RNA_def_property(srna, "use_symmetric_branching", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SYMM_BRANCHING); - RNA_def_property_ui_text(prop, "Symmetric", "Start and end points are the same"); - RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); - prop= RNA_def_property(srna, "use_hair_bspline", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_BSPLINE); RNA_def_property_ui_text(prop, "B-Spline", "Interpolate hair using B-Splines"); @@ -1269,10 +1254,10 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Children", "Apply effectors to children"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - //prop= RNA_def_property(srna, "child_seams", PROP_BOOLEAN, PROP_NONE); - //RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_SEAMS); - //RNA_def_property_ui_text(prop, "Use seams", "Use seams to determine parents"); - //RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + prop= RNA_def_property(srna, "create_long_hair_children", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_LONG_HAIR); + RNA_def_property_ui_text(prop, "Long Hair", "Calculate children that suit long hair well"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "apply_guide_to_children", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_GUIDE); @@ -1863,6 +1848,12 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Amplitude", "The amplitude of the offset"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + prop= RNA_def_property(srna, "kink_amplitude_clump", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "kink_amp_clump"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Amplitude Clump", "How much clump effects kink amplitude"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + prop= RNA_def_property(srna, "kink_frequency", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "kink_freq"); RNA_def_property_range(prop, -100000.0f, 100000.0f); @@ -1875,6 +1866,10 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shape", "Adjust the offset to the beginning/end"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + prop= RNA_def_property(srna, "kink_flat", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Flatness", "How flat the hairs are"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); /* rough */ prop= RNA_def_property(srna, "roughness_1", PROP_FLOAT, PROP_NONE); @@ -1936,6 +1931,25 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Threshold", "Amount of particles left untouched by child path length"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + /* parting */ + prop= RNA_def_property(srna, "child_parting_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "parting_fac"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Parting Factor", "Create parting in the children based on parent strands"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + + prop= RNA_def_property(srna, "child_parting_min", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "parting_min"); + RNA_def_property_range(prop, 0.0f, 180.0f); + RNA_def_property_ui_text(prop, "Parting Minimum", "Minimum root to tip angle (tip distance/root distance for long hair)"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + + prop= RNA_def_property(srna, "child_parting_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "parting_max"); + RNA_def_property_range(prop, 0.0f, 180.0f); + RNA_def_property_ui_text(prop, "Parting Maximum", "Maximum root to tip angle (tip distance/root distance for long hair)"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + /* branching */ prop= RNA_def_property(srna, "branch_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "branch_thres"); @@ -2152,6 +2166,10 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Seed", "Offset in the random number table, to get a different randomized result"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); + prop= RNA_def_property(srna, "child_seed", PROP_INT, PROP_UNSIGNED); + RNA_def_property_ui_text(prop, "Child Seed", "Offset in the random number table for child particles, to get a different randomized result"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + /* hair */ prop= RNA_def_property(srna, "is_global_hair", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_GLOBAL_HAIR); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 51a44c027e4..7b1a46dd6e2 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -547,13 +547,17 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index) } /* not essential, but much faster then the default lookup function */ -PointerRNA rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key) +int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { - PointerRNA rptr; bPose *pose= (bPose*)ptr->data; bPoseChannel *pchan= get_pose_channel(pose, key); - RNA_pointer_create(ptr->id.data, &RNA_PoseBone, pchan, &rptr); - return rptr; + if(pchan) { + RNA_pointer_create(ptr->id.data, &RNA_PoseBone, pchan, r_ptr); + return TRUE; + } + else { + return FALSE; + } } static void rna_PoseChannel_matrix_basis_get(PointerRNA *ptr, float *values) diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 29e8b2ed31a..5d1fc51a70f 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -30,9 +30,10 @@ #include "rna_internal.h" - #include "RE_pipeline.h" +#include "BKE_utildefines.h" + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" @@ -42,7 +43,6 @@ #include "BKE_context.h" #include "BKE_report.h" - /* RenderEngine */ static RenderEngineType internal_render_type = { diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 9e04132eaba..ec037ce59fa 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -54,6 +54,7 @@ EnumPropertyItem property_unit_items[] = { #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" /* Struct */ @@ -300,7 +301,7 @@ PointerRNA rna_builtin_properties_get(CollectionPropertyIterator *iter) return rna_Struct_properties_get(iter); } -PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key) +int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { StructRNA *srna; PropertyRNA *prop; @@ -315,7 +316,9 @@ PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key if(prop) { propptr.type= &RNA_Property; propptr.data= prop; - return propptr; + + *r_ptr= propptr; + return TRUE; } } @@ -323,7 +326,9 @@ PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key if(!(prop->flag & PROP_BUILTIN) && strcmp(prop->identifier, key)==0) { propptr.type= &RNA_Property; propptr.data= prop; - return propptr; + + *r_ptr= propptr; + return TRUE; } } } while((srna=srna->base)); @@ -342,13 +347,15 @@ PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key if(strcmp(idp->name, key) == 0) { propptr.type= &RNA_Property; propptr.data= idp; - return propptr; + + *r_ptr= propptr; + return TRUE; } } } } #endif - return propptr; + return FALSE; } PointerRNA rna_builtin_type_get(PointerRNA *ptr) @@ -842,34 +849,29 @@ static int rna_BlenderRNA_structs_length(PointerRNA *ptr) { return BLI_countlist(&((BlenderRNA*)ptr->data)->structs); } -static PointerRNA rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index) +static int rna_BlenderRNA_structs_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) { StructRNA *srna= BLI_findlink(&((BlenderRNA*)ptr->data)->structs, index); if(srna) { - PointerRNA r_ptr; - RNA_pointer_create(NULL, &RNA_Struct, srna, &r_ptr); - return r_ptr; + RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr); + return TRUE; } else { - return PointerRNA_NULL; + return FALSE; } } -static PointerRNA rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key) +static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { StructRNA *srna= ((BlenderRNA*)ptr->data)->structs.first; - for(; srna; srna=srna->cont.next) - if(key[0] == srna->identifier[0] && strcmp(key, srna->identifier)==0) - break; - - if(srna) { - PointerRNA r_ptr; - RNA_pointer_create(NULL, &RNA_Struct, srna, &r_ptr); - return r_ptr; - } - else { - return PointerRNA_NULL; + for(; srna; srna=srna->cont.next) { + if(key[0] == srna->identifier[0] && strcmp(key, srna->identifier)==0) { + RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr); + return TRUE; + } } + + return FALSE; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f4f7bda5efa..2529d262dda 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -155,6 +155,10 @@ EnumPropertyItem image_type_items[] = { #include "MEM_guardedalloc.h" +#include "BLI_threads.h" +#include "BLI_editVert.h" +#include "BLI_blenlib.h" + #include "BKE_context.h" #include "BKE_global.h" #include "BKE_image.h" @@ -169,10 +173,6 @@ EnumPropertyItem image_type_items[] = { #include "BKE_screen.h" #include "BKE_animsys.h" -#include "BLI_threads.h" -#include "BLI_editVert.h" -#include "BLI_blenlib.h" - #include "WM_api.h" #include "ED_info.h" @@ -185,18 +185,19 @@ EnumPropertyItem image_type_items[] = { #include "FRS_freestyle.h" -static PointerRNA rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key) +static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { Scene *scene= (Scene*)ptr->data; Base *base; for(base= scene->base.first; base; base= base->next) { if(strncmp(base->object->id.name+2, key, sizeof(base->object->id.name)-2)==0) { - return rna_pointer_inherit_refine(ptr, &RNA_ObjectBase, base); + *r_ptr= rna_pointer_inherit_refine(ptr, &RNA_ObjectBase, base); + return TRUE; } } - return PointerRNA_NULL; + return FALSE; } static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) @@ -1132,6 +1133,11 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Proportional Editing Falloff", "Falloff type for proportional editing mode"); RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + prop= RNA_def_property(srna, "proportional_size", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "proportional_size"); + RNA_def_property_ui_text(prop, "Proportional Size", "Display size for proportional editing circle"); + RNA_def_property_range(prop, 0.00001, 5000.0); + prop= RNA_def_property(srna, "normal_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "normalsize"); RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view"); @@ -1179,6 +1185,12 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_RETOPO, 0); RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + /* Grease Pencil */ + prop = RNA_def_property(srna, "use_grease_pencil_sessions", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); + RNA_def_property_ui_text(prop, "Use Sketching Sessions", "Allow drawing multiple strokes at a time with Grease Pencil"); + RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); // xxx: need toolbar to be redrawn... + /* Auto Keying */ prop= RNA_def_property(srna, "use_keyframe_insert_auto", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index f14b57e2b33..e891d64d514 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -76,19 +76,6 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION, TRUE); } -#ifdef WITH_COLLADA - -#include "../../collada/collada.h" - -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. */ - collada_export(scene, filepath); -} - -#endif - #else void RNA_api_scene(StructRNA *srna) @@ -104,14 +91,6 @@ void RNA_api_scene(StructRNA *srna) func= RNA_def_function(srna, "update", "rna_Scene_update_tagged"); RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators."); - -#ifdef WITH_COLLADA - func= RNA_def_function(srna, "collada_export", "rna_Scene_collada_export"); - parm= RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file."); - RNA_def_property_flag(parm, PROP_REQUIRED); - RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ - RNA_def_function_ui_description(func, "Export to collada file."); -#endif } void RNA_api_scene_render(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1752096d0aa..4a98d71a76a 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -575,6 +575,14 @@ static void rna_SpaceProperties_pin_id_update(Main *bmain, Scene *scene, Pointer } +static void rna_SpaceProperties_context_set(PointerRNA *ptr, int value) +{ + SpaceButs *sbuts= (SpaceButs*)(ptr->data); + + sbuts->mainb= value; + sbuts->mainbuser = value; +} + static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); @@ -1333,6 +1341,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop= RNA_def_property(srna, "context", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mainb"); RNA_def_property_enum_items(prop, buttons_context_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_context_set", NULL); RNA_def_property_ui_text(prop, "Context", "Type of active data to display and edit"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_PROPERTIES, NULL); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 6b53082c095..0c26741f06c 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -449,6 +449,16 @@ static void rna_UILayout_active_set(PointerRNA *ptr, int value) uiLayoutSetActive(ptr->data, value); } +static int rna_UILayout_alert_get(PointerRNA *ptr) +{ + return uiLayoutGetRedAlert(ptr->data); +} + +static void rna_UILayout_alert_set(PointerRNA *ptr, int value) +{ + uiLayoutSetRedAlert(ptr->data, value); +} + static void rna_UILayout_op_context_set(PointerRNA *ptr, int value) { uiLayoutSetOperatorContext(ptr->data, value); @@ -552,10 +562,8 @@ static void rna_def_ui_layout(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set"); RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is greyed out."); -#if 0 - prop= RNA_def_property(srna, "red_alert", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_UILayout_red_alert_get", "rna_UILayout_red_alert_set"); -#endif + prop= RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set"); prop= RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, alignment_items); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 378d6455fe7..ee6715b86f9 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -398,9 +398,9 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); parm= RNA_def_string(func, "active_property", "", 0, "", "Identifier of property in data, for the active element."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX); - parm= RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Maximum number of rows to display.", 0, INT_MAX); - parm= RNA_def_enum(func, "type", list_type_items, 0, "Type", "Type of list to use."); + RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX); + RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Maximum number of rows to display.", 0, INT_MAX); + RNA_def_enum(func, "type", list_type_items, 0, "Type", "Type of list to use."); func= RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index a7b7d91a2b6..90124e5f376 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -38,7 +38,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" #include "BKE_sound.h" @@ -2676,6 +2676,12 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_CONTINUOUS_MOUSE); RNA_def_property_ui_text(prop, "Continuous Grab", "Allow moving the mouse outside the view on some manipulations (transform, ui control drag)"); + /* tweak tablet & mouse preset */ + prop= RNA_def_property(srna, "drag_threshold", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dragthreshold"); + RNA_def_property_range(prop, 3, 40); + RNA_def_property_ui_text(prop, "Drag Threshold", "Amount of pixels you have to drag before dragging UI items happens"); + prop= RNA_def_property(srna, "ndof_pan_speed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ndof_pan"); RNA_def_property_range(prop, 0, 200); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 56c3bd3acb5..d06ec92d4df 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -35,7 +35,9 @@ #include "DNA_armature_types.h" #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_lattice.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index f371bfd5567..f6d497b763f 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -35,6 +35,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_edgehash.h" diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index a21d27180ba..e775d7e4262 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -31,6 +31,8 @@ */ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" + #include "BKE_bmesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 07300065659..112618a2bd6 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -32,7 +32,9 @@ #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index b31c3f19017..900a94487e5 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -37,6 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BKE_cdderivedmesh.h" diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 960db7fa925..1588d1f44d5 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -32,6 +32,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_rand.h" #include "BLI_ghash.h" diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 2d45ea19f01..c3400a6541d 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -34,12 +34,13 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_deform.h" #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" + #include "depsgraph_private.h" diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 97a79cce414..a0566d32c73 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -36,7 +36,9 @@ #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cloth.h" #include "BKE_cdderivedmesh.h" #include "BKE_global.h" diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 20319b8c65f..bf324030424 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -37,8 +37,9 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_collision.h" #include "BKE_cdderivedmesh.h" #include "BKE_global.h" diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 39816d1ff12..b1a5965cbe3 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -35,7 +35,9 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_lattice.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index d7e0ff4702b..7903e1adb47 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -33,8 +33,9 @@ #include "DNA_meshdata_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index f6e5b9c119a..931865409cb 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -34,8 +34,9 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" #include "BKE_texture.h" diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index daf9d76cf51..105e4777e87 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -39,8 +39,9 @@ #include "BLI_memarena.h" #include "BLI_edgehash.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" #include "BKE_particle.h" diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 9e93557968d..e6a3dc49668 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -37,6 +37,7 @@ #include "BLI_rand.h" #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_deform.h" @@ -46,7 +47,7 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" + #include "MEM_guardedalloc.h" @@ -197,7 +198,7 @@ static DerivedMesh * splitEdges(ExplodeModifierData *emd, DerivedMesh *dm){ int *facesplit = MEM_callocN(sizeof(int)*totface,"explode_facesplit"); int *vertpa = MEM_callocN(sizeof(int)*totvert,"explode_vertpa2"); int *facepa = emd->facepa; - int *fs, totesplit=0,totfsplit=0,totin=0,curdupvert=0,curdupface=0,curdupin=0; + int *fs, totesplit=0,totfsplit=0,totin=0,curdupface=0,curdupin=0; int i,j,v1,v2,v3,v4,esplit; edgehash= BLI_edgehash_new(); @@ -313,7 +314,6 @@ static DerivedMesh * splitEdges(ExplodeModifierData *emd, DerivedMesh *dm){ emd->facepa=facepa; /* create new verts */ - curdupvert=totvert; ehi= BLI_edgehashIterator_new(edgehash); for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_getKey(ehi, &i, &j); @@ -670,7 +670,8 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, EdgeHashIterator *ehi; float *vertco=0, imat[4][4]; float loc0[3], nor[3]; - float timestep, cfra; + float cfra; + /* float timestep; */ int *facepa=emd->facepa; int totdup=0,totvert=0,totface=0,totpart=0; int i, j, v, mindex=0; @@ -685,7 +686,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, sim.psys= psmd->psys; sim.psmd= psmd; - timestep= psys_get_timestep(&sim); + /* timestep= psys_get_timestep(&sim); */ //if(part->flag & PART_GLOB_TIME) cfra= BKE_curframe(scene); diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index d3cc653d992..bbb88ba09e3 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -34,7 +34,9 @@ #include "DNA_object_fluidsim.h" #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 07de73766f4..1ff997f92d7 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_main.h" #include "BKE_cdderivedmesh.h" diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index e29b4b456ae..adf19882419 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -35,12 +35,13 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" #include "BKE_deform.h" -#include "BKE_utildefines.h" + #include "depsgraph_private.h" #include "MEM_guardedalloc.h" @@ -268,7 +269,7 @@ static void deformVertsEM( if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0); + deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); if(!derivedData) dm->release(dm); } diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index deb4446fa4e..136998dbc78 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -34,7 +34,9 @@ #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_lattice.h" #include "BKE_modifier.h" diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 90fe8b81e53..e0a46203905 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -32,6 +32,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "DNA_armature_types.h" diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 249effa15f5..6df57bf372e 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -34,8 +34,9 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index c04c85c21f7..c07bd10d6fa 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -34,12 +34,13 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_deform.h" -#include "BKE_utildefines.h" + #include "MEM_guardedalloc.h" #include "depsgraph_private.h" diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index 1b6a709e7f4..cc27d3b659b 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -34,7 +34,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "BKE_utildefines.h" + + +#include "BLI_utildefines.h" + #include "MOD_modifiertypes.h" /* We only need to define isDisabled; because it always returns 1, diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 9fcefdba49a..f0e7699c292 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -37,13 +37,14 @@ #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_lattice.h" #include "BKE_modifier.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" + #include "depsgraph_private.h" diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index f2b580aca9a..9b77a904887 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -34,7 +34,9 @@ #include "DNA_material_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_material.h" #include "BKE_modifier.h" @@ -154,6 +156,10 @@ static void deformVerts(ModifierData *md, Object *ob, psmd->dm->needsFree = 1; psmd->dm->release(psmd->dm); } + else if(psmd->flag & eParticleSystemFlag_file_loaded) { + /* in file read dm just wasn't saved in file so no need to reset everything */ + psmd->flag &= ~eParticleSystemFlag_file_loaded; + } else { /* no dm before, so recalc particles fully */ psys->recalc |= PSYS_RECALC_RESET; @@ -176,7 +182,6 @@ static void deformVerts(ModifierData *md, Object *ob, if(psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert || psmd->dm->getNumEdges(psmd->dm)!=psmd->totdmedge || psmd->dm->getNumFaces(psmd->dm)!=psmd->totdmface){ - /* in file read dm hasn't really changed but just wasn't saved in file */ psys->recalc |= PSYS_RECALC_RESET; diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index f7d4744134f..e1c14faa3e1 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -36,8 +36,9 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "depsgraph_private.h" @@ -142,7 +143,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, int step; int i, j; int i1,i2; - int step_tot= ltmd->steps; + int step_tot= useRenderParams ? ltmd->render_steps : ltmd->steps; const int do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0; int maxVerts=0, maxEdges=0, maxFaces=0; int totvert= dm->getNumVerts(dm); @@ -172,8 +173,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (!totvert) return CDDM_from_template(dm, 0, 0, 0); - step_tot= useRenderParams ? ltmd->render_steps : ltmd->steps; - switch(ltmd->axis) { case 0: other_axis_1=1; diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index a43e19a5fc1..5466d240dd2 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -34,7 +34,9 @@ #include "DNA_key_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_key.h" #include "BKE_particle.h" diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index ff0ed5d841a..a7de27c0bf6 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -32,7 +32,9 @@ #include <string.h> -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" #include "BKE_shrinkwrap.h" diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 9e2d8e16c52..003b206f9bc 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -34,13 +34,14 @@ #include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_lattice.h" #include "BKE_modifier.h" #include "BKE_deform.h" #include "BKE_shrinkwrap.h" -#include "BKE_utildefines.h" + #include "depsgraph_private.h" diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index fc7d66b278e..4ec6e82a7dd 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -39,7 +39,9 @@ #include "DNA_scene_types.h" #include "DNA_smoke_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" #include "BKE_smoke.h" diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index e3740a42fff..bc04b253cec 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -33,11 +33,12 @@ #include "DNA_meshdata_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_particle.h" #include "BKE_deform.h" -#include "BKE_utildefines.h" + #include "MEM_guardedalloc.h" diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 8d962395d01..24af10fde2b 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -32,7 +32,9 @@ #include "DNA_scene_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_particle.h" #include "BKE_softbody.h" diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 935a3cc627a..013ca7c231f 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -34,12 +34,13 @@ #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_particle.h" #include "BKE_deform.h" -#include "BKE_utildefines.h" + #include "MOD_modifiertypes.h" diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 3264717c97a..1238c891f33 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -35,7 +35,9 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_scene.h" #include "BKE_subsurf.h" diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index a1593df0ffa..d68ba84d58b 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -35,8 +35,9 @@ #include "DNA_meshdata_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "MOD_modifiertypes.h" diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index cbf2bd8af4b..036ae276a7b 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -36,10 +36,12 @@ #include "DNA_object_types.h" #include "DNA_curve_types.h" +#include "BLI_utildefines.h" + #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_displist.h" -#include "BKE_utildefines.h" + #include "BKE_modifier.h" #include "MOD_util.h" diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 08c6477ead3..3f43924d6a2 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -38,8 +38,9 @@ #include "BLI_math.h" #include "BLI_uvproject.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "MOD_modifiertypes.h" diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 255d896fbc0..69c9f1165ce 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -36,7 +36,9 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "BKE_DerivedMesh.h" #include "BKE_object.h" #include "BKE_deform.h" diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c index 77c71ad7e3a..d344e9bf959 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c @@ -96,10 +96,6 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, /* first make the preview image */ CompBuf *prevbuf= alloc_compbuf(140, 140, CB_RGBA, 1); /* alloc */ - /* Also take care about the render size! */ - sizex = (rd->size*rd->xsch)/100; - sizey = (rd->size*rd->ysch)/100; - prevbuf->rect_procedural= texture_procedural; prevbuf->node= node; VECCOPY(prevbuf->procedural_offset, in[0]->vec); @@ -107,32 +103,39 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, prevbuf->procedural_type= CB_RGBA; composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_rgba, CB_RGBA); - /* texture is procedural node, like RGBA node, we give it fake buffer for nodes that don't check it */ + generate_preview(data, node, prevbuf); + free_compbuf(prevbuf); + + /* texture procedural buffer type doesnt work well, we now render a buffer in scene size */ + sizex = (rd->size*rd->xsch)/100; + sizey = (rd->size*rd->ysch)/100; + if(out[0]->hasoutput) { - CompBuf *stackbuf= dupalloc_compbuf(prevbuf); /* buffer alloc */ + CompBuf *stackbuf= alloc_compbuf(sizex, sizey, CB_VAL, 1); /* alloc */ stackbuf->rect_procedural= texture_procedural; stackbuf->node= node; VECCOPY(stackbuf->procedural_offset, in[0]->vec); VECCOPY(stackbuf->procedural_size, in[1]->vec); stackbuf->procedural_type= CB_VAL; + composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_value, CB_VAL); + stackbuf->rect_procedural= NULL; out[0]->data= stackbuf; } if(out[1]->hasoutput) { - CompBuf *stackbuf= dupalloc_compbuf(prevbuf); /* buffer alloc */ + CompBuf *stackbuf= alloc_compbuf(sizex, sizey, CB_RGBA, 1); /* alloc */ stackbuf->rect_procedural= texture_procedural; stackbuf->node= node; VECCOPY(stackbuf->procedural_offset, in[0]->vec); VECCOPY(stackbuf->procedural_size, in[1]->vec); stackbuf->procedural_type= CB_RGBA; + composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_rgba, CB_RGBA); + stackbuf->rect_procedural= NULL; out[1]->data= stackbuf; } - - generate_preview(data, node, prevbuf); - free_compbuf(prevbuf); } } diff --git a/source/blender/nodes/intern/CMP_util.h b/source/blender/nodes/intern/CMP_util.h index 19c48d8f083..1f91ee8a457 100644 --- a/source/blender/nodes/intern/CMP_util.h +++ b/source/blender/nodes/intern/CMP_util.h @@ -46,6 +46,13 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_rand.h" +#include "BLI_threads.h" +#include "BLI_utildefines.h" +#include "BLI_utildefines.h" + #include "BKE_blender.h" #include "BKE_colortools.h" #include "BKE_global.h" @@ -53,18 +60,13 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BKE_library.h" #include "BKE_object.h" #include "../CMP_node.h" #include "node_util.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_rand.h" -#include "BLI_threads.h" - #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c index a548893905a..7975c081880 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c @@ -38,7 +38,7 @@ #include "DNA_text_types.h" #include "BKE_text.h" -#include "BKE_utildefines.h" + // XXX #if 0 diff --git a/source/blender/nodes/intern/SHD_util.h b/source/blender/nodes/intern/SHD_util.h index ea3a100ca05..147291e380a 100644 --- a/source/blender/nodes/intern/SHD_util.h +++ b/source/blender/nodes/intern/SHD_util.h @@ -52,7 +52,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BKE_library.h" #include "../SHD_node.h" @@ -62,6 +62,7 @@ #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/nodes/intern/TEX_util.h b/source/blender/nodes/intern/TEX_util.h index a9465e17623..38edfabd346 100644 --- a/source/blender/nodes/intern/TEX_util.h +++ b/source/blender/nodes/intern/TEX_util.h @@ -51,7 +51,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BKE_library.h" #include "../SHD_node.h" @@ -61,6 +61,7 @@ #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 98e160525f8..5ee4664fd57 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -38,14 +38,12 @@ struct Object; /* DNA_object_types.h */ struct ChannelDriver; /* DNA_anim_types.h */ struct ListBase; /* DNA_listBase.h */ struct SpaceText; /* DNA_space_types.h */ -struct SpaceScript; /* DNA_space_types.h */ struct ScrArea; /* DNA_screen_types.h */ struct bScreen; /* DNA_screen_types.h */ struct bConstraint; /* DNA_constraint_types.h */ struct bPythonConstraint; /* DNA_constraint_types.h */ struct bConstraintOb; /* DNA_constraint_types.h */ struct bConstraintTarget; /* DNA_constraint_types.h*/ -struct Script; /* DNA_screen_types.h */ struct BPyMenu; struct bContext; struct bContextDataResult; @@ -55,34 +53,15 @@ struct ReportList; extern "C" { #endif - /*These two next functions are important for making sure the Draw module - works correctly. Before calling any gui callback using the Draw module, - the following code must be executed: - - if (some_drawspace_pylist) { - BPy_Set_DrawButtonsList(some_drawspace_pylist->but_refs); - BPy_Free_DrawButtonsList(); - } - some_drawspace_pylist = PyList_New(0); - BPy_Set_DrawButtonsList(some_drawspace_pylist); - - Also, BPy_Free_DrawButtonsList() must be called as necassary when a drawspace - with python callbacks is destroyed. - - This is necassary to avoid blender buttons storing invalid pointers to freed - python data.*/ -// void BPy_Set_DrawButtonsList(void *list); -// void BPy_Free_DrawButtonsList(void); -// - void BPY_pyconstraint_eval(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets); +void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets); // void BPY_pyconstraint_settings(void *arg1, void *arg2); - void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct); - void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con); - int BPY_is_pyconstraint(struct Text *text); +void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct); +void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con); +int BPY_is_pyconstraint(struct Text *text); // void BPY_free_pyconstraint_links(struct Text *text); // - void BPY_start_python( int argc, char **argv ); - void BPY_end_python( void ); +void BPY_python_start( int argc, char **argv ); +void BPY_python_end( void ); // void init_syspath( int first_time ); // void syspath_append( char *dir ); // void BPY_rebuild_syspath( void ); @@ -90,55 +69,23 @@ extern "C" { // // int BPY_Err_getLinenumber( void ); // const char *BPY_Err_getFilename( void ); -// -// int BPY_txt_do_python_Text( struct Text *text ); -// int BPY_menu_do_python( short menutype, int event ); -// int BPY_menu_do_shortcut( short menutype, unsigned short key, unsigned short modifiers ); -// int BPY_menu_invoke( struct BPyMenu *pym, short menutype ); - - /* 2.5 UI Scripts */ - int BPY_run_python_script( struct bContext *C, const char *filename, struct Text *text, struct ReportList *reports ); // 2.5 working - int BPY_run_script_space_draw(const struct bContext *C, struct SpaceScript * sc); // 2.5 working -// int BPY_run_script_space_listener(struct bContext *C, struct SpaceScript * sc, struct ARegion *ar, struct wmNotifier *wmn); // 2.5 working - void BPY_update_modules(struct bContext *C); // XXX - annoying, need this for pointers that get out of date -// - int BPY_context_get(struct bContext *C, const char *member, struct bContextDataResult *result); -// -// int BPY_run_script(struct Script *script); - void BPY_free_compiled_text( struct Text *text ); -// -// int BPY_has_onload_script( void ); -// -// int BPY_is_spacehandler(struct Text *text, char spacetype); -// int BPY_del_spacehandler(struct Text *text, struct ScrArea *sa); -// int BPY_add_spacehandler(struct Text *txt, struct ScrArea *sa,char spacetype); -// int BPY_has_spacehandler(struct Text *text, struct ScrArea *sa); -// void BPY_screen_free_spacehandlers(struct bScreen *sc); -// int BPY_do_spacehandlers(struct ScrArea *sa, unsigned short event, -// short eventValue, unsigned short space_event); -// - void BPY_reset_driver(void); - float BPY_eval_driver(struct ChannelDriver *driver); -// - int BPY_eval_button(struct bContext *C, const char *expr, double *value); - int BPY_eval_string(struct bContext *C, const char *expr); +/* 2.5 UI Scripts */ +int BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports); +int BPY_text_exec(struct bContext *C, struct Text *text, struct ReportList *reports); +void BPY_text_free_code(struct Text *text); +void BPY_modules_update(struct bContext *C); // XXX - annoying, need this for pointers that get out of date +void BPY_modules_load_user(struct bContext *C); -/* format importer hook */ - 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, -// unsigned short event, short val, char ascii ); -// void BPY_free_finished_script( struct Script *script ); -// void BPY_scripts_clear_pyobjects( void ); -// -// void error_pyscript( void ); - void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */ - void BPY_set_context(struct bContext *C); -/* void BPY_Err_Handle(struct Text *text); */ -/* int BPY_spacetext_is_pywin(struct SpaceText *st); */ - void BPY_load_user_modules(struct bContext *C); +void BPY_driver_reset(void); +float BPY_driver_exec(struct ChannelDriver *driver); + +int BPY_button_exec(struct bContext *C, const char *expr, double *value); +int BPY_string_exec(struct bContext *C, const char *expr); + +void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */ +int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result); +void BPY_context_set(struct bContext *C); #ifdef __cplusplus } /* extern "C" */ diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c index cb98ed0fd6b..7bf7f06f989 100644 --- a/source/blender/python/generic/IDProp.c +++ b/source/blender/python/generic/IDProp.c @@ -24,11 +24,13 @@ */ #include "IDProp.h" +#include "MEM_guardedalloc.h" -#include "BKE_idprop.h" -#include "BKE_utildefines.h" #include "BLI_string.h" -#include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" + +#include "BKE_idprop.h" + #define USE_STRING_COERCE diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index f1c2451dace..e72f2136ee5 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -35,7 +35,9 @@ #include <GL/glew.h> #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + static char Method_Buffer_doc[] = "(type, dimensions, [template]) - Create a new Buffer object\n\n\ diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index 380f2e456bd..0c0bf1a680d 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -26,7 +26,10 @@ #include "blf_py_api.h" #include "../../blenfont/BLF_api.h" -#include "BKE_utildefines.h" + +#include "BLI_utildefines.h" + + static char py_blf_position_doc[] = ".. function:: position(fontid, x, y, z)\n" diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index ac7f83c6563..a1b99e12e94 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -27,22 +27,26 @@ */ #include <Python.h> +#include <stddef.h> + #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ #include "bpy_internal_import.h" +#include "MEM_guardedalloc.h" + #include "DNA_text_types.h" -#include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" /* UNUSED */ -#include "BKE_text.h" /* txt_to_buf */ -#include "BKE_main.h" -#include "BKE_global.h" /* grr, only for G.main->name */ #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" -#include <stddef.h> +#include "BLI_utildefines.h" + + /* UNUSED */ +#include "BKE_text.h" /* txt_to_buf */ +#include "BKE_main.h" +#include "BKE_global.h" /* grr, only for G.main->name */ static Main *bpy_import_main= NULL; diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c index d307d1008a7..f0eca793028 100644 --- a/source/blender/python/generic/mathutils.c +++ b/source/blender/python/generic/mathutils.c @@ -46,6 +46,7 @@ * - Vector.toTrackQuat --> Vector.to_track_quat * - Quaternion * Quaternion --> cross product (not dot product) * - Euler.rotate(angle, axis) --> Euler.rotate_axis(axis, angle) + * - Euler.unique() *removed*, not a standard function only toggled different rotations. * * moved into class functions. * - Mathutils.RotationMatrix -> mathutils.Matrix.Rotation @@ -72,8 +73,9 @@ #include "mathutils.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" //-------------------------DOC STRINGS --------------------------- static char M_Mathutils_doc[] = diff --git a/source/blender/python/generic/mathutils_color.c b/source/blender/python/generic/mathutils_color.c index 989821510de..bc82e11915e 100644 --- a/source/blender/python/generic/mathutils_color.c +++ b/source/blender/python/generic/mathutils_color.c @@ -25,7 +25,9 @@ #include "mathutils.h" #include "BLI_math.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #define COLOR_SIZE 3 diff --git a/source/blender/python/generic/mathutils_euler.c b/source/blender/python/generic/mathutils_euler.c index 0474d30d29f..5f1a6f44d84 100644 --- a/source/blender/python/generic/mathutils_euler.c +++ b/source/blender/python/generic/mathutils_euler.c @@ -29,7 +29,9 @@ #include "mathutils.h" #include "BLI_math.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #ifndef int32_t #include "BLO_sys_types.h" @@ -155,65 +157,6 @@ static PyObject *Euler_ToMatrix(EulerObject * self) return newMatrixObject(mat, 3, 3 , Py_NEW, NULL); } -//sets the x,y,z values to a unique euler rotation -// TODO, check if this works with rotation order!!! -static char Euler_Unique_doc[] = -".. method:: unique()\n" -"\n" -" Calculate a unique rotation for this euler. Avoids gimble lock.\n" -"\n" -" :return: an instance of itself\n" -" :rtype: :class:`Euler`\n"; - -static PyObject *Euler_Unique(EulerObject * self) -{ -#define PI_2 (Py_PI * 2.0) -#define PI_HALF (Py_PI / 2.0) -#define PI_INV (1.0 / Py_PI) - - double heading, pitch, bank; - - if(!BaseMath_ReadCallback(self)) - return NULL; - - heading = self->eul[0]; - pitch = self->eul[1]; - bank = self->eul[2]; - - //wrap heading in +180 / -180 - pitch += Py_PI; - pitch -= floor(pitch * PI_INV) * PI_2; - pitch -= Py_PI; - - - if(pitch < -PI_HALF) { - pitch = -Py_PI - pitch; - heading += Py_PI; - bank += Py_PI; - } else if(pitch > PI_HALF) { - pitch = Py_PI - pitch; - heading += Py_PI; - bank += Py_PI; - } - //gimbal lock test - if(fabs(pitch) > PI_HALF - 1e-4) { - heading += bank; - bank = 0.0f; - } else { - bank += Py_PI; - bank -= (floor(bank * PI_INV)) * PI_2; - bank -= Py_PI; - } - - heading += Py_PI; - heading -= (floor(heading * PI_INV)) * PI_2; - heading -= Py_PI; - - (void)BaseMath_WriteCallback(self); - Py_INCREF(self); - return (PyObject *)self; -} - //sets the euler to 0,0,0 static char Euler_Zero_doc[] = ".. method:: zero()\n" @@ -629,7 +572,6 @@ static PyGetSetDef Euler_getseters[] = { //-----------------------METHOD DEFINITIONS ---------------------- static struct PyMethodDef Euler_methods[] = { {"zero", (PyCFunction) Euler_Zero, METH_NOARGS, Euler_Zero_doc}, - {"unique", (PyCFunction) Euler_Unique, METH_NOARGS, Euler_Unique_doc}, {"to_matrix", (PyCFunction) Euler_ToMatrix, METH_NOARGS, Euler_ToMatrix_doc}, {"to_quat", (PyCFunction) Euler_ToQuat, METH_NOARGS, Euler_ToQuat_doc}, {"rotate_axis", (PyCFunction) Euler_rotate_axis, METH_VARARGS, Euler_rotate_axis_doc}, diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c index 1010a08c9ed..9280dc4093c 100644 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/generic/mathutils_geometry.c @@ -30,14 +30,16 @@ #include "mathutils_geometry.h" /* Used for PolyFill */ -#include "BKE_displist.h" #include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" - -#include "BKE_utildefines.h" -#include "BKE_curve.h" #include "BLI_boxpack2d.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_displist.h" + +#include "BKE_curve.h" #define SWAP_FLOAT(a,b,tmp) tmp=a; a=b; b=tmp #define eps 0.000001 @@ -75,11 +77,11 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* float det, inv_det, u, v, t; int clip= 1; - if(!PyArg_ParseTuple(args, "intersect_ray_tri:O!O!O!O!O!|i", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) { + if(!PyArg_ParseTuple(args, "O!O!O!O!O!|i:intersect_ray_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) { 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"); + PyErr_SetString(PyExc_ValueError, "only 3D vectors for all parameters"); return NULL; } @@ -162,11 +164,11 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject VectorObject *vec1, *vec2, *vec3, *vec4; float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3]; - if(!PyArg_ParseTuple(args, "intersect_line_line:O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) { + if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) { 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"); + PyErr_SetString(PyExc_ValueError,"vectors must be of the same size"); return NULL; } @@ -214,7 +216,7 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject } } else { - PyErr_SetString(PyExc_TypeError, "2D/3D vectors only"); + PyErr_SetString(PyExc_ValueError, "2D/3D vectors only"); return NULL; } } @@ -244,15 +246,15 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args) float n[3]; if(PyTuple_GET_SIZE(args) == 3) { - if(!PyArg_ParseTuple(args, "normal:O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) { + if(!PyArg_ParseTuple(args, "O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) { return NULL; } if(vec1->size != vec2->size || vec1->size != vec3->size) { - PyErr_SetString(PyExc_TypeError, "vectors must be of the same size"); + PyErr_SetString(PyExc_ValueError, "vectors must be of the same size"); return NULL; } if(vec1->size < 3) { - PyErr_SetString(PyExc_TypeError, "2D vectors unsupported"); + PyErr_SetString(PyExc_ValueError, "2D vectors unsupported"); return NULL; } @@ -262,15 +264,15 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject* args) normal_tri_v3(n, vec1->vec, vec2->vec, vec3->vec); } else { - if(!PyArg_ParseTuple(args, "normal:O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) { + if(!PyArg_ParseTuple(args, "O!O!O!O!:normal", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4)) { 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"); + PyErr_SetString(PyExc_ValueError,"vectors must be of the same size"); return NULL; } if(vec1->size < 3) { - PyErr_SetString(PyExc_TypeError, "2D vectors unsupported"); + PyErr_SetString(PyExc_ValueError, "2D vectors unsupported"); return NULL; } @@ -302,12 +304,12 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args) { VectorObject *vec1, *vec2, *vec3; - if(!PyArg_ParseTuple(args, "area_tri:O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) { + if(!PyArg_ParseTuple(args, "O!O!O!:area_tri", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3)) { return NULL; } if(vec1->size != vec2->size || vec1->size != vec3->size) { - PyErr_SetString(PyExc_TypeError, "vectors must be of the same size"); + PyErr_SetString(PyExc_ValueError, "vectors must be of the same size"); return NULL; } @@ -321,7 +323,7 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args) return PyFloat_FromDouble(area_tri_v2(vec1->vec, vec2->vec, vec3->vec)); } else { - PyErr_SetString(PyExc_TypeError, "only 2D,3D vectors are supported"); + PyErr_SetString(PyExc_ValueError, "only 2D,3D vectors are supported"); return NULL; } } @@ -466,7 +468,7 @@ static PyObject *M_Geometry_intersect_line_line_2d(PyObject *UNUSED(self), PyObj { VectorObject *line_a1, *line_a2, *line_b1, *line_b2; float vi[2]; - if(!PyArg_ParseTuple (args, "intersect_line_line_2d:O!O!O!O!", + if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_line_line_2d", &vector_Type, &line_a1, &vector_Type, &line_a2, &vector_Type, &line_b1, @@ -506,7 +508,7 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec float lambda; PyObject *ret; - if(!PyArg_ParseTuple (args, "intersect_point_line:O!O!O!", + if(!PyArg_ParseTuple(args, "O!O!O!:intersect_point_line", &vector_Type, &pt, &vector_Type, &line_1, &vector_Type, &line_2) @@ -555,7 +557,7 @@ static PyObject *M_Geometry_intersect_point_tri_2d(PyObject *UNUSED(self), PyObj { VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3; - if(!PyArg_ParseTuple (args, "intersect_point_tri_2d:O!O!O!O!", + if(!PyArg_ParseTuple(args, "O!O!O!O!:intersect_point_tri_2d", &vector_Type, &pt_vec, &vector_Type, &tri_p1, &vector_Type, &tri_p2, @@ -591,7 +593,7 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb { VectorObject *pt_vec, *quad_p1, *quad_p2, *quad_p3, *quad_p4; - if(!PyArg_ParseTuple (args, "intersect_point_quad_2d:O!O!O!O!O!", + if(!PyArg_ParseTuple(args, "O!O!O!O!O!:intersect_point_quad_2d", &vector_Type, &pt_vec, &vector_Type, &quad_p1, &vector_Type, &quad_p2, @@ -616,7 +618,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, w, h]"); return -1; } @@ -629,7 +631,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 pack a list of [x, y, w, h]"); return -1; } @@ -638,15 +640,16 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) item_1= PyList_GET_ITEM(list_item, 2); item_2= PyList_GET_ITEM(list_item, 3); - 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]"); - return -1; - } - box->w= (float)PyFloat_AsDouble(item_1); box->h= (float)PyFloat_AsDouble(item_2); box->index= i; + + if (box->w < 0.0f || box->h < 0.0f) { + MEM_freeN(*boxarray); + PyErr_SetString(PyExc_TypeError, "error parsing width and height values from list: [x, y, w, h], not numbers or below zero"); + return -1; + } + /* verts will be added later */ } return 0; @@ -743,19 +746,23 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* float h2[4]= {0.0, 0.0, 0.0, 0.0}; - if(!PyArg_ParseTuple (args, "O!O!O!O!i", + if(!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier", &vector_Type, &vec_k1, &vector_Type, &vec_h1, &vector_Type, &vec_h2, - &vector_Type, &vec_k2, &resolu) || (resolu<=1) + &vector_Type, &vec_k2, &resolu) ) { - PyErr_SetString(PyExc_TypeError, "expected 4 vector types and an int greater then 1"); return NULL; } - + + if(resolu <= 1) { + PyErr_SetString(PyExc_ValueError, "resolution must be 2 or over"); + return NULL; + } + if(!BaseMath_ReadCallback(vec_k1) || !BaseMath_ReadCallback(vec_h1) || !BaseMath_ReadCallback(vec_k2) || !BaseMath_ReadCallback(vec_h2)) return NULL; - + dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i]; @@ -806,25 +813,30 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje VectorObject *vec_t1_src, *vec_t2_src, *vec_t3_src; float vec[3]; - if(!PyArg_ParseTuple (args, "O!O!O!O!O!O!O!", + if(!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform", &vector_Type, &vec_pt, &vector_Type, &vec_t1_src, &vector_Type, &vec_t2_src, &vector_Type, &vec_t3_src, &vector_Type, &vec_t1_tar, &vector_Type, &vec_t2_tar, - &vector_Type, &vec_t3_tar) ||(vec_pt->size != 3 || - vec_t1_src->size != 3 || - vec_t2_src->size != 3 || - vec_t3_src->size != 3 || - vec_t1_tar->size != 3 || - vec_t2_tar->size != 3 || - vec_t3_tar->size != 3) + &vector_Type, &vec_t3_tar) ) { - PyErr_SetString(PyExc_TypeError, "expected 7, 3D vector types"); return NULL; } + if( vec_pt->size != 3 || + vec_t1_src->size != 3 || + vec_t2_src->size != 3 || + vec_t3_src->size != 3 || + vec_t1_tar->size != 3 || + vec_t2_tar->size != 3 || + vec_t3_tar->size != 3) + { + PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector"); + return NULL; + } + barycentric_transform(vec, vec_pt->vec, vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec); diff --git a/source/blender/python/generic/mathutils_matrix.c b/source/blender/python/generic/mathutils_matrix.c index 8b8e68b798c..35d58ceb255 100644 --- a/source/blender/python/generic/mathutils_matrix.c +++ b/source/blender/python/generic/mathutils_matrix.c @@ -27,9 +27,11 @@ #include "mathutils.h" -#include "BKE_utildefines.h" #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + + /* matrix vector callbacks */ int mathutils_matrix_vector_cb_index= -1; @@ -848,10 +850,8 @@ static char Matrix_TranslationPart_doc[] = " Return a the translation part of a 4 row matrix.\n" "\n" " :return: Return a the translation of a matrix.\n" -" :rtype: :class:`Matrix`\n" -"\n" -" .. note:: Note that the (4,4) element of a matrix can be used for uniform scaling too.\n"; - +" :rtype: :class:`Vector`\n" +; PyObject *Matrix_TranslationPart(MatrixObject * self) { if(!BaseMath_ReadCallback(self)) @@ -1243,7 +1243,7 @@ static PyObject *Matrix_repr(MatrixObject * self) return NULL; for(x = 0; x < self->rowSize; x++){ - rows[x]= PyTuple_New(self->rowSize); + rows[x]= PyTuple_New(self->colSize); for(y = 0; y < self->colSize; y++) { PyTuple_SET_ITEM(rows[x], y, PyFloat_FromDouble(self->matrix[x][y])); } @@ -1342,57 +1342,29 @@ static PyObject *Matrix_item(MatrixObject * self, int i) return newVectorObject_cb((PyObject *)self, self->colSize, mathutils_matrix_vector_cb_index, i); } /*----------------------------object[]------------------------- - sequence accessor (set)*/ -static int Matrix_ass_item(MatrixObject * self, int i, PyObject * ob) + sequence accessor (set) */ + +static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value) { - int y, x, size = 0; float vec[4]; - PyObject *m, *f; - if(!BaseMath_ReadCallback(self)) return -1; - + if(i >= self->rowSize || i < 0){ 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"); - 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"); - 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"); - return -1; - } - - vec[x] = (float)PyFloat_AS_DOUBLE(f); - Py_DECREF(m); - Py_DECREF(f); - } - /*parsed well - now set in matrix*/ - for(y = 0; y < size; y++){ - self->matrix[i][y] = vec[y]; - } - - (void)BaseMath_WriteCallback(self); - return 0; - }else{ - PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: expects a sequence of column size"); + if(mathutils_array_parse(vec, self->colSize, self->colSize, value, "matrix[i] = value assignment") < 0) { return -1; } + + memcpy(self->matrix[i], vec, self->colSize * sizeof(float)); + + (void)BaseMath_WriteCallback(self); + return 0; } + /*----------------------------object[z:y]------------------------ sequence slice (get)*/ static PyObject *Matrix_slice(MatrixObject * self, int begin, int end) @@ -1419,12 +1391,9 @@ static PyObject *Matrix_slice(MatrixObject * self, int begin, int end) } /*----------------------------object[z:y]------------------------ sequence slice (set)*/ -static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * seq) +static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject *value) { - int i, x, y, size, sub_size = 0; - float mat[16], f; - PyObject *subseq; - PyObject *m; + PyObject *value_fast= NULL; if(!BaseMath_ReadCallback(self)) return -1; @@ -1433,74 +1402,46 @@ static int Matrix_ass_slice(MatrixObject * self, int begin, int end, PyObject * CLAMP(end, 0, self->rowSize); begin = MIN2(begin,end); - if(PySequence_Check(seq)){ - size = PySequence_Length(seq); - if(size != (end - begin)){ + /* non list/tuple cases */ + if(!(value_fast=PySequence_Fast(value, "matrix[begin:end] = value"))) { + /* PySequence_Fast sets the error */ + return -1; + } + else { + const int size= end - begin; + int i; + float mat[16]; + + if(PySequence_Fast_GET_SIZE(value_fast) != size) { + Py_DECREF(value_fast); PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment"); return -1; } + /*parse sub items*/ for (i = 0; i < size; i++) { /*parse each sub sequence*/ - subseq = PySequence_GetItem(seq, i); - if (subseq == NULL) { /*Failed to read sequence*/ - PyErr_SetString(PyExc_RuntimeError, "matrix[begin:end] = []: unable to read sequence"); - return -1; - } + PyObject *item= PySequence_Fast_GET_ITEM(value_fast, i); - if(PySequence_Check(subseq)){ - /*subsequence is also a sequence*/ - 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"); - 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"); - return -1; - } - - f = PyFloat_AsDouble(m); /* faster to assume a float and raise an error after */ - 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"); - return -1; - } - - mat[(i * self->colSize) + y] = f; - Py_DECREF(m); - } - }else{ - Py_DECREF(subseq); - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation"); + if(mathutils_array_parse(&mat[i * self->colSize], self->colSize, self->colSize, item, "matrix[begin:end] = value assignment") < 0) { return -1; } - Py_DECREF(subseq); } + + Py_DECREF(value_fast); + /*parsed well - now set in matrix*/ - for(x = 0; x < (size * sub_size); x++){ - self->matrix[begin + (int)floor(x / self->colSize)][x % self->colSize] = mat[x]; - } - + memcpy(self->contigPtr + (begin * self->colSize), mat, sizeof(float) * (size * self->colSize)); + (void)BaseMath_WriteCallback(self); return 0; - }else{ - PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation"); - return -1; } } /*------------------------NUMERIC PROTOCOLS---------------------- ------------------------obj + obj------------------------------*/ static PyObject *Matrix_add(PyObject * m1, PyObject * m2) { - int x, y; - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + float mat[16]; MatrixObject *mat1 = NULL, *mat2 = NULL; mat1 = (MatrixObject*)m1; @@ -1519,21 +1460,15 @@ static PyObject *Matrix_add(PyObject * m1, PyObject * m2) return NULL; } - for(x = 0; x < mat1->rowSize; x++) { - for(y = 0; y < mat1->colSize; y++) { - mat[((x * mat1->colSize) + y)] = mat1->matrix[x][y] + mat2->matrix[x][y]; - } - } + add_vn_vnvn(mat, mat1->contigPtr, mat2->contigPtr, mat1->rowSize * mat1->colSize); - return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, NULL); + return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1)); } /*------------------------obj - obj------------------------------ subtraction*/ static PyObject *Matrix_sub(PyObject * m1, PyObject * m2) { - int x, y; - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + float mat[16]; MatrixObject *mat1 = NULL, *mat2 = NULL; mat1 = (MatrixObject*)m1; @@ -1552,23 +1487,23 @@ static PyObject *Matrix_sub(PyObject * m1, PyObject * m2) return NULL; } - for(x = 0; x < mat1->rowSize; x++) { - for(y = 0; y < mat1->colSize; y++) { - mat[((x * mat1->colSize) + y)] = mat1->matrix[x][y] - mat2->matrix[x][y]; - } - } + sub_vn_vnvn(mat, mat1->contigPtr, mat2->contigPtr, mat1->rowSize * mat1->colSize); - return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, NULL); + return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1)); } /*------------------------obj * obj------------------------------ mulplication*/ +static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar) +{ + float tmat[16]; + mul_vn_vn_fl(tmat, mat->contigPtr, mat->rowSize * mat->colSize, scalar); + return newMatrixObject(tmat, mat->rowSize, mat->colSize, Py_NEW, Py_TYPE(mat)); +} + static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) { - int x, y, z; float scalar; - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - double dot = 0.0f; + MatrixObject *mat1 = NULL, *mat2 = NULL; if(MatrixObject_Check(m1)) { @@ -1587,54 +1522,42 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) PyErr_SetString(PyExc_AttributeError,"Matrix multiplication: matrix A rowsize must equal matrix B colsize"); return NULL; } - for(x = 0; x < mat2->rowSize; x++) { - for(y = 0; y < mat1->colSize; y++) { - for(z = 0; z < mat1->rowSize; z++) { - dot += (mat1->matrix[z][y] * mat2->matrix[x][z]); - } - mat[((x * mat1->colSize) + y)] = (float)dot; - dot = 0.0f; - } - } - - return newMatrixObject(mat, mat2->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1)); - } - - if(mat1==NULL){ - 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 */ + else { + float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + double dot = 0.0f; + int x, y, z; + for(x = 0; x < mat2->rowSize; x++) { - for(y = 0; y < mat2->colSize; y++) { - mat[((x * mat2->colSize) + y)] = scalar * mat2->matrix[x][y]; + for(y = 0; y < mat1->colSize; y++) { + for(z = 0; z < mat1->rowSize; z++) { + dot += (mat1->matrix[z][y] * mat2->matrix[x][z]); + } + mat[((x * mat1->colSize) + y)] = (float)dot; + dot = 0.0f; } } - return newMatrixObject(mat, mat2->rowSize, mat2->colSize, Py_NEW, Py_TYPE(mat2)); + + return newMatrixObject(mat, mat2->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1)); } - - PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); - return NULL; } - else /* if(mat1) { */ { - if(VectorObject_Check(m2)) { /* MATRIX*VECTOR */ - PyErr_SetString(PyExc_TypeError, "Matrix multiplication: Only 'vec * matrix' is supported, not the reverse"); - return NULL; + else if(mat2) { + if (((scalar= PyFloat_AsDouble(m1)) == -1.0 && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX */ + return matrix_mul_float(mat2, scalar); } - else { - scalar= PyFloat_AsDouble(m2); - if ((scalar == -1.0 && PyErr_Occurred())==0) { /* MATRIX*FLOAT/INT */ - for(x = 0; x < mat1->rowSize; x++) { - for(y = 0; y < mat1->colSize; y++) { - mat[((x * mat1->colSize) + y)] = scalar * mat1->matrix[x][y]; - } - } - return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW, Py_TYPE(mat1)); - } + } + else if(mat1) { + if (((scalar= PyFloat_AsDouble(m2)) == -1.0 && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX */ + return matrix_mul_float(mat1, scalar); } - PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); - return NULL; + } + else { + BKE_assert(!"internal error"); } - PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); + PyErr_Format(PyExc_TypeError, "Matrix multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(m1)->tp_name, Py_TYPE(m2)->tp_name); return NULL; } static PyObject* Matrix_inv(MatrixObject *self) @@ -1651,9 +1574,9 @@ static PySequenceMethods Matrix_SeqMethods = { (binaryfunc) NULL, /* sq_concat */ (ssizeargfunc) NULL, /* sq_repeat */ (ssizeargfunc) Matrix_item, /* sq_item */ - (ssizessizeargfunc) Matrix_slice, /* sq_slice, deprecated TODO, replace */ + (ssizessizeargfunc) NULL, /* sq_slice, deprecated */ (ssizeobjargproc) Matrix_ass_item, /* sq_ass_item */ - (ssizessizeobjargproc) Matrix_ass_slice, /* sq_ass_slice, deprecated TODO, replace */ + (ssizessizeobjargproc) NULL, /* sq_ass_slice, deprecated */ (objobjproc) NULL, /* sq_contains */ (binaryfunc) NULL, /* sq_inplace_concat */ (ssizeargfunc) NULL, /* sq_inplace_repeat */ diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c index 4dced9aaad1..1de249205b2 100644 --- a/source/blender/python/generic/mathutils_quat.c +++ b/source/blender/python/generic/mathutils_quat.c @@ -29,7 +29,9 @@ #include "mathutils.h" #include "BLI_math.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #define QUAT_SIZE 4 @@ -639,6 +641,15 @@ static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2) return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); } + +static PyObject *quat_mul_float(QuaternionObject *quat, const float scalar) +{ + float tquat[4]; + copy_qt_qt(tquat, quat->quat); + mul_qt_fl(tquat, scalar); + return newQuaternionObject(tquat, Py_NEW, Py_TYPE(quat)); +} + //------------------------obj * obj------------------------------ //mulplication static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) @@ -661,33 +672,22 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) mul_qt_qtqt(quat, quat1->quat, quat2->quat); return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); } - /* the only case this can happen (for a supported type is "FLOAT*QUAT" ) */ - if(!QuaternionObject_Check(q1)) { - scalar= PyFloat_AsDouble(q1); - if ((scalar == -1.0 && PyErr_Occurred())==0) { /* FLOAT*QUAT */ - QUATCOPY(quat, quat2->quat); - mul_qt_fl(quat, scalar); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(q2)); + else if(quat2) { /* FLOAT*QUAT */ + if(((scalar= PyFloat_AsDouble(q1)) == -1.0 && PyErr_Occurred())==0) { + return quat_mul_float(quat2, scalar); } - PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: val * quat, val is not an acceptable type"); - return NULL; } - else { /* QUAT*SOMETHING */ - if(VectorObject_Check(q2)){ /* QUAT*VEC */ - PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: Only 'vector * quaternion' is supported, not the reverse"); - return NULL; - } - - scalar= PyFloat_AsDouble(q2); - if ((scalar == -1.0 && PyErr_Occurred())==0) { /* QUAT*FLOAT */ - QUATCOPY(quat, quat1->quat); - mul_qt_fl(quat, scalar); - return newQuaternionObject(quat, Py_NEW, Py_TYPE(q1)); + else if (quat1) { /* QUAT*FLOAT */ + if((((scalar= PyFloat_AsDouble(q2)) == -1.0 && PyErr_Occurred())==0)) { + return quat_mul_float(quat1, scalar); } } - - PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation"); + else { + BKE_assert(!"internal error"); + } + + PyErr_Format(PyExc_TypeError, "Quaternion multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(q1)->tp_name, Py_TYPE(q2)->tp_name); return NULL; } diff --git a/source/blender/python/generic/mathutils_vector.c b/source/blender/python/generic/mathutils_vector.c index 7bf8eebb12d..2208046e6c0 100644 --- a/source/blender/python/generic/mathutils_vector.c +++ b/source/blender/python/generic/mathutils_vector.c @@ -28,8 +28,10 @@ #include "mathutils.h" #include "BLI_blenlib.h" -#include "BKE_utildefines.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + + #define MAX_DIMENSIONS 4 /* Swizzle axes get packed into a single value that is used as a closure. Each @@ -1045,6 +1047,17 @@ static int column_vector_multiplication(float *rvec, VectorObject* vec, MatrixOb return 0; } +static PyObject *vector_mul_float(VectorObject *vec, const float scalar) +{ + float tvec[MAX_DIMENSIONS]; + int i; + + for(i = 0; i < vec->size; i++) { + tvec[i] = vec->vec[i] * scalar; + } + return newVectorObject(tvec, vec->size, Py_NEW, Py_TYPE(vec)); +} + static PyObject *Vector_mul(PyObject * v1, PyObject * v2) { VectorObject *vec1 = NULL, *vec2 = NULL; @@ -1078,55 +1091,48 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2) } return PyFloat_FromDouble(dot); } - - /* swap so vec1 is always the vector */ - /* note: it would seem from this code that the matrix multiplication below - * is communicative. however the matrix class will always handle the - * (matrix * vector) case so we can ignore it here. - * This is NOT so for Quaternions: TODO, check if communicative (vec * quat) is correct */ - if (vec2) { - vec1= vec2; - v2= v1; - } + else if (vec1) { + if (MatrixObject_Check(v2)) { + /* VEC * MATRIX */ + float tvec[MAX_DIMENSIONS]; + if(!BaseMath_ReadCallback((MatrixObject *)v2)) + return NULL; + if(column_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { + return NULL; + } - if (MatrixObject_Check(v2)) { - /* VEC * MATRIX */ - float tvec[MAX_DIMENSIONS]; - if(!BaseMath_ReadCallback((MatrixObject *)v2)) - return NULL; - if(column_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { - return 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]; - 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"); - return NULL; + if(vec1->size != 3) { + PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported"); + return NULL; + } + if(!BaseMath_ReadCallback(quat2)) { + return NULL; + } + copy_v3_v3(tvec, vec1->vec); + mul_qt_v3(quat2->quat, tvec); + return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); } - if(!BaseMath_ReadCallback(quat2)) { - return NULL; + else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ + return vector_mul_float(vec1, scalar); } - copy_v3_v3(tvec, vec1->vec); - mul_qt_v3(quat2->quat, tvec); - return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ - int i; - float vec[MAX_DIMENSIONS]; - - for(i = 0; i < vec1->size; i++) { - vec[i] = vec1->vec[i] * scalar; + else if (vec2) { + if (((scalar= PyFloat_AsDouble(v1)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ + return vector_mul_float(vec2, scalar); } - return newVectorObject(vec, vec1->size, Py_NEW, Py_TYPE(vec1)); - } - - PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation"); + else { + BKE_assert(!"internal error"); + } + + PyErr_Format(PyExc_TypeError, "Vector multiplication: not supported between '%.200s' and '%.200s' types", Py_TYPE(v1)->tp_name, Py_TYPE(v2)->tp_name); return NULL; } diff --git a/source/blender/python/generic/noise.c b/source/blender/python/generic/noise.c index 7293cb91d45..f266a666274 100644 --- a/source/blender/python/generic/noise.c +++ b/source/blender/python/generic/noise.c @@ -38,9 +38,11 @@ #include "structseq.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" + #include "DNA_texture_types.h" -#include "BKE_utildefines.h" + /*-----------------------------------------*/ /* 'mersenne twister' random number generator */ diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 263ddd046cf..c50c37d0261 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -35,8 +35,9 @@ #include "BLI_path_util.h" #include "BLI_bpath.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_global.h" /* XXX, G.main only */ #include "MEM_guardedalloc.h" diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 0db8ea0f317..0f6fd3f6415 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -25,8 +25,9 @@ #include "bpy_app.h" #include "BLI_path_util.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_blender.h" #include "BKE_global.h" #include "structseq.h" diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index e055a8b0bc8..59f762a0658 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -69,41 +69,15 @@ int bpy_pydriver_create_dict(void) Py_DECREF(mod); } - -#if 0 // non existant yet - mod = PyImport_ImportModule("Blender.Noise"); - if (mod) { - PyDict_SetItemString(d, "noise", mod); - PyDict_SetItemString(d, "n", mod); - Py_DECREF(mod); - } else { - PyErr_Clear(); - } - - /* If there's a Blender text called pydrivers.py, import it. - * Users can add their own functions to this module. - */ - if (G.f & G_SCRIPT_AUTOEXEC) { - mod = importText("pydrivers"); /* can also use PyImport_Import() */ - if (mod) { - PyDict_SetItemString(d, "pydrivers", mod); - PyDict_SetItemString(d, "p", mod); - Py_DECREF(mod); - } else { - PyErr_Clear(); - } - } -#endif // non existant yet - return 0; } /* Update function, it gets rid of pydrivers global dictionary, forcing - * BPY_eval_driver to recreate it. This function is used to force + * BPY_driver_exec to recreate it. This function is used to force * reloading the Blender text module "pydrivers.py", if available, so * updates in it reach pydriver evaluation. */ -void BPY_reset_driver(void) +void BPY_driver_reset(void) { PyGILState_STATE gilstate; int use_gil= 1; // (PyThreadState_Get()==NULL); @@ -124,7 +98,7 @@ void BPY_reset_driver(void) } /* error return function for BPY_eval_pydriver */ -static float pydriver_error(ChannelDriver *driver) +static void pydriver_error(ChannelDriver *driver) { 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); @@ -132,8 +106,6 @@ static float pydriver_error(ChannelDriver *driver) // BPy_errors_to_report(NULL); // TODO - reports PyErr_Print(); PyErr_Clear(); - - return 0.0f; } /* This evals py driver expressions, 'expr' is a Python expression that @@ -143,7 +115,7 @@ static float pydriver_error(ChannelDriver *driver) * bake operator which intern starts a thread which calls scene update which * does a driver update. to avoid a deadlock check PyThreadState_Get() if PyGILState_Ensure() is needed. */ -float BPY_eval_driver (ChannelDriver *driver) +float BPY_driver_exec(ChannelDriver *driver) { PyObject *driver_vars=NULL; PyObject *retval= NULL; @@ -232,15 +204,15 @@ float BPY_eval_driver (ChannelDriver *driver) /* try to add to dictionary */ /* if (PyDict_SetItemString(driver_vars, dvar->name, driver_arg)) { */ - if (PyDict_SetItem(driver_vars, PyTuple_GET_ITEM(expr_vars, i++), driver_arg)) { /* use string interning for faster namespace creation */ + if (PyDict_SetItem(driver_vars, PyTuple_GET_ITEM(expr_vars, i++), driver_arg) < 0) { /* use string interning for faster namespace creation */ /* this target failed - bad name */ if (targets_ok) { /* first one - print some extra info for easier identification */ - fprintf(stderr, "\nBPY_eval_driver() - Error while evaluating PyDriver:\n"); + fprintf(stderr, "\nBPY_driver_eval() - Error while evaluating PyDriver:\n"); targets_ok= 0; } - fprintf(stderr, "\tBPY_eval_driver() - couldn't add variable '%s' to namespace\n", dvar->name); + fprintf(stderr, "\tBPY_driver_eval() - couldn't add variable '%s' to namespace\n", dvar->name); // BPy_errors_to_report(NULL); // TODO - reports PyErr_Print(); PyErr_Clear(); @@ -280,7 +252,7 @@ float BPY_eval_driver (ChannelDriver *driver) return (float)result; } else { - fprintf(stderr, "\tBPY_eval_driver() - driver '%s' evaluates to '%f'\n", dvar->name, result); + fprintf(stderr, "\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n", dvar->name, result); return 0.0f; } } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 2c615a52860..3c76e1a703f 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -30,6 +30,8 @@ #include <Python.h> +#include "MEM_guardedalloc.h" + #include "bpy.h" #include "bpy_rna.h" #include "bpy_util.h" @@ -37,12 +39,12 @@ #include "DNA_space_types.h" #include "DNA_text_types.h" -#include "MEM_guardedalloc.h" #include "BLI_path_util.h" #include "BLI_math_base.h" #include "BLI_string.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_context.h" #include "BKE_text.h" #include "BKE_font.h" /* only for utf8towchar */ @@ -88,7 +90,7 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n"); } - BPY_update_modules(C); /* can give really bad results if this isnt here */ + BPY_modules_update(C); /* can give really bad results if this isnt here */ #ifdef TIME_PY_RUN if(bpy_timer_count==0) { @@ -128,7 +130,7 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate) } } -void BPY_free_compiled_text( struct Text *text ) +void BPY_text_free_code(Text *text) { if( text->compiled ) { Py_DECREF( ( PyObject * ) text->compiled ); @@ -136,7 +138,7 @@ void BPY_free_compiled_text( struct Text *text ) } } -void BPY_update_modules(bContext *C) +void BPY_modules_update(bContext *C) { #if 0 // slow, this runs all the time poll, draw etc 100's of time a sec. PyObject *mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); @@ -150,7 +152,7 @@ void BPY_update_modules(bContext *C) } /* must be called before Py_Initialize */ -void BPY_start_python_path(void) +void BPY_python_start_path(void) { char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL); @@ -191,7 +193,7 @@ void BPY_start_python_path(void) -void BPY_set_context(bContext *C) +void BPY_context_set(bContext *C) { BPy_SetContext(C); } @@ -214,8 +216,8 @@ static struct _inittab bpy_internal_modules[]= { {NULL, NULL} }; -/* call BPY_set_context first */ -void BPY_start_python( int argc, char **argv ) +/* call BPY_context_set first */ +void BPY_python_start( int argc, char **argv ) { PyThreadState *py_tstate = NULL; @@ -227,7 +229,7 @@ void BPY_start_python( int argc, char **argv ) /* builtin modules */ PyImport_ExtendInittab(bpy_internal_modules); - BPY_start_python_path(); /* allow to use our own included python */ + BPY_python_start_path(); /* allow to use our own included python */ Py_Initialize( ); @@ -278,7 +280,7 @@ void BPY_start_python( int argc, char **argv ) PyEval_ReleaseThread(py_tstate); } -void BPY_end_python( void ) +void BPY_python_end(void) { // fprintf(stderr, "Ending Python!\n"); @@ -312,12 +314,13 @@ 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) +static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports) { PyObject *py_dict= NULL, *py_result= NULL; PyGILState_STATE gilstate; - + + BKE_assert(fn || text); + if (fn==NULL && text==NULL) { return 0; } @@ -327,7 +330,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc if (text) { char fn_dummy[FILE_MAXDIR]; bpy_text_filename_get(fn_dummy, text); - + if( !text->compiled ) { /* if it wasn't already compiled, do it now */ char *buf = txt_to_buf( text ); @@ -336,8 +339,8 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc MEM_freeN( buf ); - if( PyErr_Occurred( ) ) { - BPY_free_compiled_text( text ); + if(PyErr_Occurred()) { + BPY_text_free_code(text); } } @@ -345,7 +348,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc py_dict = PyC_DefaultNameSpace(fn_dummy); py_result = PyEval_EvalCode(text->compiled, py_dict, py_dict); } - + } else { FILE *fp= fopen(fn, "r"); @@ -354,9 +357,9 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc py_dict = PyC_DefaultNameSpace(fn); #ifdef _WIN32 - /* Previously we used PyRun_File to run directly the code on a FILE + /* Previously we used PyRun_File to run directly the code on a FILE * object, but as written in the Python/C API Ref Manual, chapter 2, - * 'FILE structs for different C libraries can be different and + * 'FILE structs for different C libraries can be different and * incompatible'. * So now we load the script file data to a buffer */ { @@ -380,14 +383,14 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc py_result= NULL; } } - + if (!py_result) { BPy_errors_to_report(reports); } else { Py_DECREF( py_result ); } -/* super annoying, undo _PyModule_Clear() */ +/* super annoying, undo _PyModule_Clear() */ #define PYMODULE_CLEAR_WORKAROUND if(py_dict) { @@ -405,92 +408,22 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc #endif #undef PYMODULE_CLEAR_WORKAROUND } - + bpy_context_clear(C, &gilstate); - return py_result ? 1:0; + return (py_result != NULL); } - -/* TODO - move into bpy_space.c ? */ -/* GUI interface routines */ - -/* Copied from Draw.c */ -static void exit_pydraw( SpaceScript * sc, short err ) +/* Can run a file or text block */ +int BPY_filepath_exec(bContext *C, const char *filepath, struct ReportList *reports) { - Script *script = NULL; - - if( !sc || !sc->script ) - return; - - script = sc->script; - - if( err ) { - BPy_errors_to_report(NULL); // TODO, reports - script->flags = 0; /* mark script struct for deletion */ - SCRIPT_SET_NULL(script); - script->scriptname[0] = '\0'; - script->scriptarg[0] = '\0'; -// XXX 2.5 error_pyscript(); -// XXX 2.5 scrarea_queue_redraw( sc->area ); - } - -#if 0 // XXX 2.5 - BPy_Set_DrawButtonsList(sc->but_refs); - BPy_Free_DrawButtonsList(); /*clear all temp button references*/ -#endif - - sc->but_refs = NULL; - - Py_XDECREF( ( PyObject * ) script->py_draw ); - Py_XDECREF( ( PyObject * ) script->py_event ); - Py_XDECREF( ( PyObject * ) script->py_button ); - - script->py_draw = script->py_event = script->py_button = NULL; + return python_script_exec(C, filepath, NULL, reports); } -static int bpy_run_script_init(bContext *C, SpaceScript * sc) -{ - if (sc->script==NULL) - return 0; - - if (sc->script->py_draw==NULL && sc->script->scriptname[0] != '\0') - BPY_run_python_script(C, sc->script->scriptname, NULL, NULL); - - if (sc->script->py_draw==NULL) - return 0; - - return 1; -} -int BPY_run_script_space_draw(const struct bContext *C, SpaceScript * sc) +int BPY_text_exec(bContext *C, struct Text *text, struct ReportList *reports) { - if (bpy_run_script_init( (bContext *)C, sc)) { - PyGILState_STATE gilstate = PyGILState_Ensure(); - PyObject *result = PyObject_CallObject( sc->script->py_draw, NULL ); - - if (result==NULL) - exit_pydraw(sc, 1); - - PyGILState_Release(gilstate); - } - return 1; -} - -// XXX - not used yet, listeners dont get a context -int BPY_run_script_space_listener(bContext *C, SpaceScript * sc) -{ - if (bpy_run_script_init(C, sc)) { - PyGILState_STATE gilstate = PyGILState_Ensure(); - - PyObject *result = PyObject_CallObject( sc->script->py_draw, NULL ); - - if (result==NULL) - exit_pydraw(sc, 1); - - PyGILState_Release(gilstate); - } - return 1; + return python_script_exec(C, NULL, text, reports); } void BPY_DECREF(void *pyob_ptr) @@ -500,57 +433,7 @@ void BPY_DECREF(void *pyob_ptr) PyGILState_Release(gilstate); } -#if 0 -/* called from the the scripts window, assume context is ok */ -int BPY_run_python_script_space(const char *modulename, const char *func) -{ - PyObject *py_dict, *py_result= NULL; - char pystring[512]; - PyGILState_STATE gilstate; - - /* for calling the module function */ - PyObject *py_func, - - gilstate = PyGILState_Ensure(); - - py_dict = PyC_DefaultNameSpace("<dummy>"); - - PyObject *module = PyImport_ImportModule(scpt->script.filename); - if (module==NULL) { - PyErr_SetFormat(PyExc_SystemError, "could not import '%s'", scpt->script.filename); - } - else { - py_func = PyObject_GetAttrString(modulename, func); - if (py_func==NULL) { - PyErr_SetFormat(PyExc_SystemError, "module has no function '%s.%s'\n", scpt->script.filename, func); - } - else { - Py_DECREF(py_func); - if (!PyCallable_Check(py_func)) { - PyErr_SetFormat(PyExc_SystemError, "module item is not callable '%s.%s'\n", scpt->script.filename, func); - } - else { - py_result= PyObject_CallObject(py_func, NULL); // XXX will need args eventually - } - } - } - - if (!py_result) { - BPy_errors_to_report(NULL); // TODO - reports - } else - Py_DECREF( py_result ); - - Py_XDECREF(module); - - PyDict_SetItemString(PyThreadState_GET()->interp->modules, "__main__", Py_None); - - PyGILState_Release(gilstate); - return 1; -} -#endif - - -int BPY_eval_button(bContext *C, const char *expr, double *value) +int BPY_button_exec(bContext *C, const char *expr, double *value) { PyGILState_STATE gilstate; PyObject *py_dict, *mod, *retval; @@ -622,7 +505,7 @@ int BPY_eval_button(bContext *C, const char *expr, double *value) return error_ret; } -int BPY_eval_string(bContext *C, const char *expr) +int BPY_string_exec(bContext *C, const char *expr) { PyGILState_STATE gilstate; PyObject *py_dict, *retval; @@ -657,7 +540,7 @@ int BPY_eval_string(bContext *C, const char *expr) } -void BPY_load_user_modules(bContext *C) +void BPY_modules_load_user(bContext *C) { PyGILState_STATE gilstate; Main *bmain= CTX_data_main(C); @@ -690,7 +573,7 @@ void BPY_load_user_modules(bContext *C) bpy_context_clear(C, &gilstate); } -int BPY_context_get(bContext *C, const char *member, bContextDataResult *result) +int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result) { PyObject *pyctx= (PyObject *)CTX_py_dict_get(C); PyObject *item= PyDict_GetItemString(pyctx, member); diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index de71d7d27a4..d5446b11349 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -32,6 +32,8 @@ #include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */ #include "bpy_util.h" +#include "BLI_utildefines.h" + #include "RNA_enum_types.h" #include "WM_api.h" diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index fa1aeacbc42..12c67f9e03f 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -27,6 +27,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "BLI_utildefines.h" + #include "RNA_define.h" #include "bpy_rna.h" diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 1148b9e5e2b..dd3a49ad8b1 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -26,7 +26,9 @@ #include "bpy_rna.h" #include "bpy_util.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + #include "RNA_define.h" /* for defining our own rna */ #include "RNA_enum_types.h" diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 721c996aca8..663c82e07ad 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -21,22 +21,23 @@ * * ***** END GPL LICENSE BLOCK ***** */ +#include <float.h> /* FLT_MIN/MAX */ #include "bpy_rna.h" #include "bpy_props.h" #include "bpy_util.h" #include "bpy_rna_callback.h" -//#include "blendef.h" + #include "BLI_dynstr.h" #include "BLI_string.h" #include "BLI_listbase.h" -#include "float.h" /* FLT_MIN/MAX */ +#include "BLI_utildefines.h" #include "RNA_enum_types.h" #include "RNA_define.h" /* RNA_def_property_free_identifier */ #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" + #include "BKE_idcode.h" #include "BKE_context.h" #include "BKE_global.h" /* evil G.* */ @@ -57,6 +58,8 @@ #define USE_MATHUTILS #define USE_STRING_COERCE +static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self); + #ifdef USE_PEDANTIC_WRITE static short rna_disallow_writes= FALSE; @@ -91,7 +94,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item #ifdef USE_MATHUTILS #include "../generic/mathutils.h" /* so we can have mathutils callbacks */ -static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length); +static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, Py_ssize_t start, Py_ssize_t stop, Py_ssize_t length); static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback); /* bpyrna vector/euler/quat callbacks */ @@ -1414,20 +1417,34 @@ static int pyrna_prop_collection_bool( BPy_PropertyRNA *self ) static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum) { PointerRNA newptr; - int len= RNA_property_collection_length(&self->ptr, self->prop); + Py_ssize_t keynum_abs= keynum; - if(keynum < 0) keynum += len; + /* notice getting the length of the collection is avoided unless negative index is used + * or to detect internal error with a valid index. + * This is done for faster lookups. */ + if(keynum < 0) { + keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); + + if(keynum_abs < 0) { + PyErr_Format(PyExc_IndexError, "bpy_prop_collection[%d]: out of range.", keynum); + return NULL; + } + } - if(keynum >= 0 && keynum < len) { - if(RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum, &newptr)) { - return pyrna_struct_CreatePyObject(&newptr); + if(RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum_abs, &newptr)) { + return pyrna_struct_CreatePyObject(&newptr); + } + else { + const int len= RNA_property_collection_length(&self->ptr, self->prop); + if(keynum_abs >= len) { + PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d out of range, size %d", keynum, len); } - else { /* fail's if ptr.data == NULL, valid for mesh.materials */ - Py_RETURN_NONE; + else { + PyErr_Format(PyExc_RuntimeError, "bpy_prop_collection[index]: internal error, valid index %d given in %d sized collection but value not found", keynum_abs, len); } + + return NULL; } - PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d out of range, size %d", keynum, len); - return NULL; } static PyObject *pyrna_prop_array_subscript_int(BPy_PropertyArrayRNA *self, int keynum) @@ -1454,26 +1471,37 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons } /* static PyObject *pyrna_prop_array_subscript_str(BPy_PropertyRNA *self, char *keyname) */ -static PyObject *pyrna_prop_collection_subscript_slice(PointerRNA *ptr, PropertyRNA *prop, int start, int stop) +static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self, Py_ssize_t start, Py_ssize_t stop) { - PointerRNA newptr; - PyObject *list = PyList_New(stop - start); - int count; + int count= 0; - start = MIN2(start,stop); /* values are clamped from */ + PyObject *list= PyList_New(0); + PyObject *item; - for(count = start; count < stop; count++) { - if(RNA_property_collection_lookup_int(ptr, prop, count - start, &newptr)) { - PyList_SET_ITEM(list, count - start, pyrna_struct_CreatePyObject(&newptr)); + /* first loop up-until the start */ + CollectionPropertyIterator rna_macro_iter; + for(RNA_property_collection_begin(&self->ptr, self->prop, &rna_macro_iter); rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { + /* PointerRNA itemptr= rna_macro_iter.ptr; */ + if(count == start) { + break; } - else { - Py_DECREF(list); + count++; + } - PyErr_SetString(PyExc_RuntimeError, "error getting an rna struct from a collection"); - return NULL; + /* add items until stop */ + for(; rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) { + item= pyrna_struct_CreatePyObject(&rna_macro_iter.ptr); + PyList_Append(list, item); + Py_DECREF(item); + + count++; + if(count == stop) { + break; } } + RNA_property_collection_end(&rna_macro_iter); + return list; } @@ -1481,7 +1509,7 @@ static PyObject *pyrna_prop_collection_subscript_slice(PointerRNA *ptr, Property * note: could also use pyrna_prop_array_to_py_index(self, count) in a loop but its a lot slower * since at the moment it reads (and even allocates) the entire array for each index. */ -static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length) +static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, Py_ssize_t start, Py_ssize_t stop, Py_ssize_t length) { int count, totdim; @@ -1567,21 +1595,39 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject return pyrna_prop_collection_subscript_int(self, i); } else if (PySlice_Check(key)) { - int len= RNA_property_collection_length(&self->ptr, self->prop); - Py_ssize_t start, stop, step, slicelength; + PySliceObject *key_slice= (PySliceObject *)key; + Py_ssize_t step= 1; - if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) + if(key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) { return NULL; - - if (slicelength <= 0) { - return PyList_New(0); } - else if (step == 1) { - return pyrna_prop_collection_subscript_slice(&self->ptr, self->prop, start, stop); + else if (step != 1) { + PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported"); + return NULL; + } + else if(key_slice->start == Py_None && key_slice->stop == Py_None) { + return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX); } else { - PyErr_SetString(PyExc_TypeError, "bpy_prop_collection[slice]: slice steps not supported with rna"); - return NULL; + Py_ssize_t start= 0, stop= PY_SSIZE_T_MAX; + + /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */ + if(key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL; + if(key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL; + + if(start < 0 || stop < 0) { + /* only get the length for negative values */ + Py_ssize_t len= (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop); + if(start < 0) start += len; + if(stop < 0) start += len; + } + + if (stop - start <= 0) { + return PyList_New(0); + } + else { + return pyrna_prop_collection_subscript_slice(self, start, stop); + } } } else { @@ -1602,21 +1648,34 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject return pyrna_prop_array_subscript_int(self, PyLong_AsLong(key)); } else if (PySlice_Check(key)) { - Py_ssize_t start, stop, step, slicelength; - int len = pyrna_prop_array_length(self); + Py_ssize_t step= 1; + PySliceObject *key_slice= (PySliceObject *)key; - if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) + if(key_slice->step != Py_None && !_PyEval_SliceIndex(key, &step)) { return NULL; - - if (slicelength <= 0) { - return PyList_New(0); } - else if (step == 1) { - return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len); + else if (step != 1) { + PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported"); + return NULL; + } + else if(key_slice->start == Py_None && key_slice->stop == Py_None) { + /* note, no significant advantage with optimizing [:] slice as with collections but include here for consistency with collection slice func */ + Py_ssize_t len= (Py_ssize_t)pyrna_prop_array_length(self); + return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len); } else { - PyErr_SetString(PyExc_TypeError, "bpy_prop_array[slice]: slice steps not supported with rna"); - return NULL; + int len= pyrna_prop_array_length(self); + Py_ssize_t start, stop, slicelength; + + if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop, &step, &slicelength) < 0) + return NULL; + + if (slicelength <= 0) { + return PyTuple_New(0); + } + else { + return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, start, stop, len); + } } } else { @@ -3046,7 +3105,7 @@ static PyGetSetDef pyrna_struct_getseters[] = { {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; -static PyObject *pyrna_prop_keys(BPy_PropertyRNA *self) +static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self) { PyObject *ret= PyList_New(0); PyObject *item; @@ -3071,7 +3130,7 @@ static PyObject *pyrna_prop_keys(BPy_PropertyRNA *self) return ret; } -static PyObject *pyrna_prop_items(BPy_PropertyRNA *self) +static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self) { PyObject *ret= PyList_New(0); PyObject *item; @@ -3104,19 +3163,10 @@ static PyObject *pyrna_prop_items(BPy_PropertyRNA *self) return ret; } -static PyObject *pyrna_prop_values(BPy_PropertyRNA *self) +static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self) { - PyObject *ret= PyList_New(0); - PyObject *item; - - RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) { - item = pyrna_struct_CreatePyObject(&itemptr); - PyList_Append(ret, item); - Py_DECREF(item); - } - RNA_PROP_END; - - return ret; + /* re-use slice*/ + return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX); } static char pyrna_struct_get_doc[] = @@ -3173,7 +3223,7 @@ static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self) return PyLong_FromVoidPtr(self->ptr.data); } -static PyObject *pyrna_prop_get(BPy_PropertyRNA *self, PyObject *args) +static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args) { PointerRNA newptr; @@ -3209,7 +3259,7 @@ static void foreach_attr_type( BPy_PropertyRNA *self, char *attr, RNA_PROP_END; } -/* pyrna_prop_foreach_get/set both use this */ +/* pyrna_prop_collection_foreach_get/set both use this */ static int foreach_parse_args( BPy_PropertyRNA *self, PyObject *args, @@ -3432,12 +3482,12 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) Py_RETURN_NONE; } -static PyObject *pyrna_prop_foreach_get(BPy_PropertyRNA *self, PyObject *args) +static PyObject *pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObject *args) { return foreach_getset(self, args, 0); } -static PyObject *pyrna_prop_foreach_set(BPy_PropertyRNA *self, PyObject *args) +static PyObject *pyrna_prop_collection_foreach_set(BPy_PropertyRNA *self, PyObject *args) { return foreach_getset(self, args, 1); } @@ -3467,7 +3517,7 @@ PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self) /* Try get values from a collection */ PyObject *ret; PyObject *iter= NULL; - ret = pyrna_prop_values(self); + ret= pyrna_prop_collection_values(self); /* we know this is a list so no need to PyIter_Check * otherwise it could be NULL (unlikely) if conversion failed */ @@ -3518,14 +3568,14 @@ static struct PyMethodDef pyrna_prop_array_methods[] = { }; static struct PyMethodDef pyrna_prop_collection_methods[] = { - {"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL}, - {"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL}, + {"foreach_get", (PyCFunction)pyrna_prop_collection_foreach_get, METH_VARARGS, NULL}, + {"foreach_set", (PyCFunction)pyrna_prop_collection_foreach_set, METH_VARARGS, NULL}, - {"keys", (PyCFunction)pyrna_prop_keys, METH_NOARGS, NULL}, - {"items", (PyCFunction)pyrna_prop_items, METH_NOARGS,NULL}, - {"values", (PyCFunction)pyrna_prop_values, METH_NOARGS, NULL}, + {"keys", (PyCFunction)pyrna_prop_collection_keys, METH_NOARGS, NULL}, + {"items", (PyCFunction)pyrna_prop_collection_items, METH_NOARGS,NULL}, + {"values", (PyCFunction)pyrna_prop_collection_values, METH_NOARGS, NULL}, - {"get", (PyCFunction)pyrna_prop_get, METH_VARARGS, NULL}, + {"get", (PyCFunction)pyrna_prop_collection_get, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; @@ -4796,7 +4846,7 @@ static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self) PyObject *list, *name; PyMethodDef *meth; - list= pyrna_prop_keys(self); /* like calling structs.keys(), avoids looping here */ + list= pyrna_prop_collection_keys(self); /* like calling structs.keys(), avoids looping here */ for(meth=pyrna_basetype_methods; meth->ml_name; meth++) { name = PyUnicode_FromString(meth->ml_name); @@ -5176,7 +5226,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun return 0; } -extern void BPY_update_modules(bContext *C); //XXX temp solution +extern void BPY_modules_update(bContext *C); //XXX temp solution /* TODO - multiple return values like with rna functions */ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) @@ -5416,12 +5466,13 @@ static void bpy_class_free(void *pyob_ptr) if(PyErr_Occurred()) PyErr_Clear(); +#if 0 /* needs further investigation, too annoying so quiet for now */ if(G.f&G_DEBUG) { if(self->ob_refcnt > 1) { PyC_ObSpit("zombie class - ref should be 1", self); } } - +#endif Py_DECREF((PyObject *)pyob_ptr); PyGILState_Release(gilstate); @@ -5541,7 +5592,10 @@ static PyObject *pyrna_basetype_register(PyObject *UNUSED(self), PyObject *py_cl if(BPy_reports_to_error(&reports, TRUE)) return NULL; - BKE_assert(srna_new != NULL); + /* python errors validating are not converted into reports so the check above will fail. + * the cause for returning NULL will be printed as an error */ + if(srna_new == NULL) + return NULL; pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */ diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 633ee070d9a..6d4cc035ece 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -26,8 +26,10 @@ #include "bpy_rna.h" #include "bpy_util.h" +#include "BLI_utildefines.h" + #include "DNA_screen_types.h" -#include "BKE_utildefines.h" + #include "BKE_context.h" #include "ED_space_api.h" diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c index abf329b5fd0..c766e802dd0 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -27,11 +27,10 @@ */ /* python, will come back */ -//void BPY_run_python_script(void) {} -//void BPY_start_python(void) {} -void BPY_call_importloader(const char *filepath) {(void)filepath;} -//void BPY_free_compiled_text(void) {} -void BPY_pyconstraint_eval(void) {} +//void BPY_script_exec(void) {} +//void BPY_python_start(void) {} +//void BPY_text_free_code(void) {} +void BPY_pyconstraint_exec(void) {} void BPY_pyconstraint_target(void) {} int BPY_is_pyconstraint(void) {return 0;} void BPY_pyconstraint_update(void) {} diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 7d6046b5537..50b23f65401 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -32,7 +32,6 @@ #include "DNA_listBase.h" #include "DNA_vec_types.h" -#include "BKE_utildefines.h" #include "RNA_types.h" struct bNodeTree; diff --git a/source/blender/render/extern/include/RE_raytrace.h b/source/blender/render/extern/include/RE_raytrace.h index 2bbcfc0d41c..cf463c0795e 100644 --- a/source/blender/render/extern/include/RE_raytrace.h +++ b/source/blender/render/extern/include/RE_raytrace.h @@ -177,6 +177,7 @@ struct Isect int lay; /* -1 default, set for layer lamps */ int skip; /* RE_SKIP_CULLFACE */ + int check; float col[4]; /* RGBA for shadow_tra */ @@ -195,13 +196,15 @@ struct Isect #define RE_RAY_SHADOW_TRA 2 /* skip options */ -#define RE_SKIP_CULLFACE (1 << 0) - +#define RE_SKIP_CULLFACE (1 << 0) /* if using this flag then *face should be a pointer to a VlakRen */ #define RE_SKIP_VLR_NEIGHBOUR (1 << 1) -#define RE_SKIP_VLR_RENDER_CHECK (1 << 2) -#define RE_SKIP_VLR_NON_SOLID_MATERIAL (1 << 3) -#define RE_SKIP_VLR_BAKE_CHECK (1 << 4) + +/* check options */ +#define RE_CHECK_VLR_NONE 0 +#define RE_CHECK_VLR_RENDER 1 +#define RE_CHECK_VLR_NON_SOLID_MATERIAL 2 +#define RE_CHECK_VLR_BAKE 3 /* TODO use: FLT_MAX? */ #define RE_RAYTRACE_MAXDIST 1e33 diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h index 133a3d4a005..c31d1213b99 100644 --- a/source/blender/render/intern/raytrace/bvh.h +++ b/source/blender/render/intern/raytrace/bvh.h @@ -31,6 +31,8 @@ #include "rayobject_rtbuild.h" #include "rayobject_hint.h" +#include "BLI_utildefines.h" + #include <assert.h> #ifdef __SSE__ diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp index 119a62ad05a..c267b89fc2c 100644 --- a/source/blender/render/intern/raytrace/rayobject.cpp +++ b/source/blender/render/intern/raytrace/rayobject.cpp @@ -22,17 +22,21 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ #include <assert.h> -#include "BKE_utildefines.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + + + #include "DNA_material_types.h" #include "RE_raytrace.h" + #include "render_types.h" #include "rayobject.h" #include "raycounter.h" @@ -195,19 +199,19 @@ static int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *is) return 0; /* check if we should intersect this face */ - if(is->skip & RE_SKIP_VLR_RENDER_CHECK) + if(is->check == RE_CHECK_VLR_RENDER) { if(vlr_check_intersect(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face ) == 0) return 0; } - else if(is->skip & RE_SKIP_VLR_NON_SOLID_MATERIAL) + else if(is->check == RE_CHECK_VLR_NON_SOLID_MATERIAL) { if(vlr_check_intersect(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face ) == 0) return 0; if(vlr_check_intersect_solid(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) return 0; } - else if(is->skip & RE_SKIP_VLR_BAKE_CHECK) { + else if(is->check == RE_CHECK_VLR_BAKE) { if(vlr_check_bake(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face ) == 0) return 0; } diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index 1c3cdd5919f..79bb3b9260f 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ @@ -33,8 +33,11 @@ #include "rayobject_rtbuild.h" #include "MEM_guardedalloc.h" + #include "BLI_math.h" -#include "BKE_utildefines.h" +#include "BLI_utildefines.h" + + static bool selected_node(RTBuilder::Object *node) { diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index de1e6d349be..b2104a2d557 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ @@ -38,7 +38,7 @@ int tot_hints = 0; #include "BLI_memarena.h" #include "MEM_guardedalloc.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #include "BLI_math.h" #include "reorganize.h" diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index 1d923c92d6f..c8fbd1cfe94 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -32,6 +32,8 @@ #include <vector> #include <queue> +#include "BLI_utildefines.h" + #include "BKE_global.h" #ifdef _WIN32 diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h index 055a71e3380..11511fccb89 100644 --- a/source/blender/render/intern/raytrace/svbvh.h +++ b/source/blender/render/intern/raytrace/svbvh.h @@ -33,6 +33,7 @@ #include "bvh.h" #include "BLI_memarena.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include <stdio.h> #include <algorithm> diff --git a/source/blender/render/intern/raytrace/vbvh.h b/source/blender/render/intern/raytrace/vbvh.h index 21c3c0b4c01..a5ca093de2a 100644 --- a/source/blender/render/intern/raytrace/vbvh.h +++ b/source/blender/render/intern/raytrace/vbvh.h @@ -31,7 +31,7 @@ #include <algorithm> #include "rayobject_rtbuild.h" #include "BLI_memarena.h" - +#include "BLI_utildefines.h" /* * VBVHNode represents a BVHNode with support for a variable number of childrens diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index adb386f80fb..15c5bb3b86d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -31,12 +31,11 @@ #include <string.h> #include <limits.h> - - #include "MEM_guardedalloc.h" #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_rand.h" #include "BLI_memarena.h" #include "BLI_ghash.h" @@ -92,7 +91,7 @@ #include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BKE_world.h" #include "PIL_time.h" @@ -1493,11 +1492,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem StrandBound *sbound= 0; StrandRen *strand=0; RNG *rng= 0; - float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3],time; + float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3]; float strandlen=0.0f, curlen=0.0f; - float hasize, pa_size, r_tilt, r_length, cfra= BKE_curframe(re->scene); + float hasize, pa_size, r_tilt, r_length; float pa_time, pa_birthtime, pa_dietime; float random, simplify[2], pa_co[3]; + const float cfra= BKE_curframe(re->scene); int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0; int totchild=0; int seed, path_nbr=0, orco1=0, num; @@ -1622,7 +1622,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(part->flag & PART_GLOB_TIME) #endif // XXX old animation system - cfra = BKE_curframe(re->scene); ///* 2.4 setup reactors */ // if(part->type == PART_REACTOR){ @@ -1880,6 +1879,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(path_nbr) { /* render strands */ for(k=0; k<=path_nbr; k++){ + float time; + if(k<=max_k){ VECCOPY(state.co,(cache+k)->co); VECCOPY(state.vel,(cache+k)->vel); @@ -1963,7 +1964,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } } else { - time=0.0f; state.time=cfra; if(psys_get_particle_state(&sim,a,&state,0)==0) continue; @@ -2595,18 +2595,14 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, int a, a1, end, totvert, vertofs; VertRen *ver; VlakRen *vlr; - Curve *cu= NULL; MVert *mvert = NULL; MFace *mface; Material *ma; + /* Curve *cu= ELEM(ob->type, OB_FONT, OB_CURVE) ? ob->data : NULL; */ mvert= dm->getVertArray(dm); totvert= dm->getNumVerts(dm); - if ELEM(ob->type, OB_FONT, OB_CURVE) { - cu= ob->data; - } - for(a=0; a<totvert; a++, mvert++) { ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, mvert->co); @@ -2703,7 +2699,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) ListBase displist= {NULL, NULL}; DispList *dl; Material **matar; - float *orco=NULL, *orcobase=NULL, mat[4][4]; + float *orco=NULL, mat[4][4]; int a, totmat, need_orco=0; DerivedMesh *dm= NULL; @@ -2741,7 +2737,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) dm->release(dm); } else { if(need_orco) { - orcobase= orco= get_object_orco(re, ob); + orco= get_object_orco(re, ob); } /* walk along displaylist and create rendervertices/-faces */ @@ -2767,9 +2763,9 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) DerivedMesh *dm = NULL; ListBase disp={NULL, NULL}; Material **matar; - float len, *data, *fp, *orco=NULL, *orcobase= NULL; + float *data, *fp, *orco=NULL; float n[3], mat[4][4]; - int nr, startvert, startvlak, a, b; + int nr, startvert, a, b; int need_orco=0, totmat; cu= ob->data; @@ -2806,7 +2802,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) dm->release(dm); } else { if(need_orco) { - orcobase=orco= get_object_orco(re, ob); + orco= get_object_orco(re, ob); } while(dl) { @@ -2839,7 +2835,6 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } if(timeoffset==0) { - startvlak= obr->totvlak; index= dl->index; for(a=0; a<dl->parts; a++, index+=3) { @@ -2884,7 +2879,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } if(dl->bevelSplitFlag || timeoffset==0) { - startvlak= obr->totvlak; + const int startvlak= obr->totvlak; for(a=0; a<dl->parts; a++) { @@ -2935,7 +2930,7 @@ 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); + normalize_v3(ver->n); } } } @@ -3465,7 +3460,6 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) /* bias is percentage, made 2x larger because of correction for angle of incidence */ /* when a ray is closer to parallel of a face, bias value is increased during render */ shb->bias= (0.02*lar->bias)*0x7FFFFFFF; - shb->bias= shb->bias; /* halfway method (average of first and 2nd z) reduces bias issues */ if(ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index f7da13373d1..55f7433da96 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -34,6 +34,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" /* for rectcpy */ @@ -48,7 +49,7 @@ #include "BKE_main.h" #include "BKE_image.h" // BKE_write_ibuf #include "BKE_texture.h" -#include "BKE_utildefines.h" + diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 1ab0e8f8042..3a8270a757e 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -51,8 +51,9 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_image.h" diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 26c68d0a167..f54b7e2a43f 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -40,8 +40,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" - - +#include "BLI_utildefines.h" #include "DNA_camera_types.h" #include "DNA_group_types.h" @@ -50,7 +49,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_utildefines.h" + #include "BKE_global.h" #include "BKE_material.h" #include "BKE_object.h" diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index fb69519236a..4d129312672 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -40,10 +40,11 @@ #include "BLI_blenlib.h" #include "BLI_memarena.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" + #include "RE_shader_ext.h" @@ -304,7 +305,7 @@ static float sh_eval(float *sh, float *v) /* ------------------------------ Building --------------------------------- */ -static void occ_face(const OccFace *face, float *co, float *normal, float *area) +static void occ_face(const OccFace *face, float co[3], float normal[3], float *area) { ObjectInstanceRen *obi; VlakRen *vlr; @@ -421,21 +422,23 @@ static void occ_node_from_face(OccFace *face, OccNode *node) sh_from_disc(n, node->area, node->sh); } -static void occ_build_dco(OcclusionTree *tree, OccNode *node, float *co, float *dco) +static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], float *dco) { - OccNode *child; - float dist, d[3], nco[3]; int b; - for(b=0; b<TOTCHILD; b++) { + float dist, d[3], nco[3]; + if(node->childflag & (1<<b)) { - occ_face(tree->face+node->child[b].face, nco, 0, 0); + occ_face(tree->face+node->child[b].face, nco, NULL, NULL); } else if(node->child[b].node) { - child= node->child[b].node; + OccNode *child= node->child[b].node; occ_build_dco(tree, child, co, dco); VECCOPY(nco, child->co); } + else { + continue; + } VECSUB(d, nco, co); dist= INPR(d, d); @@ -521,7 +524,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i ListBase threads; OcclusionBuildThread othreads[BLENDER_MAX_THREADS]; OccNode *child, tmpnode; - OccFace *face; + /* OccFace *face; */ int a, b, totthread=0, offset[TOTCHILD], count[TOTCHILD]; /* add a new node */ @@ -530,7 +533,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i /* leaf node with only children */ if(end - begin <= TOTCHILD) { for(a=begin, b=0; a<end; a++, b++) { - face= &tree->face[a]; + /* face= &tree->face[a]; */ node->child[b].face= a; node->childflag |= (1<<b); } @@ -547,7 +550,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i node->child[b].node= NULL; } else if(count[b] == 1) { - face= &tree->face[offset[b]]; + /* face= &tree->face[offset[b]]; */ node->child[b].face= offset[b]; node->childflag |= (1<<b); } @@ -1526,7 +1529,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int for(i=0; i<4; i++) { VECSUB(d, samples[i]->co, co); - dist2= INPR(d, d); + //dist2= INPR(d, d); wz[i]= 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); wn[i]= pow(INPR(samples[i]->n, n), 32.0f); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 2c4916aa9c2..5940a8bf48b 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -59,6 +59,7 @@ #include "BLI_blenlib.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "PIL_time.h" #include "IMB_imbuf.h" diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 768fc4ecacb..74b59c881bb 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -27,14 +27,14 @@ #include <float.h> #include <math.h> #include <string.h> + #include "BLI_math.h" +#include "BLI_utildefines.h" /* External modules: */ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" - - #include "DNA_camera_types.h" #include "DNA_group_types.h" #include "DNA_material_types.h" @@ -48,7 +48,7 @@ #include "BKE_global.h" #include "BKE_material.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + /* own module */ #include "render_types.h" diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index a5609390ef4..15279fea01d 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -32,6 +32,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdopbvh.h" +#include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" diff --git a/source/blender/render/intern/source/rayobject_blibvh.c b/source/blender/render/intern/source/rayobject_blibvh.c index d824719a2ac..fa5c32a8e8d 100644 --- a/source/blender/render/intern/source/rayobject_blibvh.c +++ b/source/blender/render/intern/source/rayobject_blibvh.c @@ -22,16 +22,17 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ #include <assert.h> #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" + #include "BLI_kdopbvh.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "RE_raytrace.h" #include "render_types.h" #include "rayobject.h" diff --git a/source/blender/render/intern/source/rayobject_instance.c b/source/blender/render/intern/source/rayobject_instance.c index a8098d2e8ef..d7b4beb8023 100644 --- a/source/blender/render/intern/source/rayobject_instance.c +++ b/source/blender/render/intern/source/rayobject_instance.c @@ -22,15 +22,18 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ #include <assert.h> #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" + + #include "BLI_math.h" +#include "BLI_utildefines.h" + #include "RE_raytrace.h" #include "rayobject.h" diff --git a/source/blender/render/intern/source/rayobject_octree.c b/source/blender/render/intern/source/rayobject_octree.c index 6d99d961e26..2637643989e 100644 --- a/source/blender/render/intern/source/rayobject_octree.c +++ b/source/blender/render/intern/source/rayobject_octree.c @@ -38,9 +38,10 @@ #include "DNA_material_types.h" -#include "BKE_utildefines.h" - #include "BLI_math.h" +#include "BLI_utildefines.h" + + #include "rayobject.h" diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f66d8b9c55e..e1e0828bdd2 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -37,15 +37,16 @@ #include "DNA_material_types.h" #include "DNA_lamp_types.h" -#include "BKE_global.h" -#include "BKE_node.h" -#include "BKE_utildefines.h" - #include "BLI_blenlib.h" #include "BLI_cpu.h" #include "BLI_jitter.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" + +#include "BKE_global.h" +#include "BKE_node.h" + #include "PIL_time.h" @@ -707,7 +708,8 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo VECCOPY(isec.vec, vec ); isec.labda = dist_mir > 0 ? dist_mir : RE_RAYTRACE_MAXDIST; isec.mode= RE_RAY_MIRROR; - isec.skip = RE_SKIP_VLR_NEIGHBOUR | RE_SKIP_VLR_RENDER_CHECK; + isec.check = RE_CHECK_VLR_RENDER; + isec.skip = RE_SKIP_VLR_NEIGHBOUR; isec.hint = 0; isec.orig.ob = obi; @@ -1850,7 +1852,8 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env) RE_RC_INIT(isec, *shi); isec.orig.ob = shi->obi; isec.orig.face = shi->vlr; - isec.skip = RE_SKIP_VLR_NEIGHBOUR|RE_SKIP_VLR_NON_SOLID_MATERIAL; + isec.check = RE_CHECK_VLR_NON_SOLID_MATERIAL; + isec.skip = RE_SKIP_VLR_NEIGHBOUR; isec.hint = 0; isec.hit.ob = 0; @@ -1989,7 +1992,8 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *ao, float *env) RE_RC_INIT(isec, *shi); isec.orig.ob = shi->obi; isec.orig.face = shi->vlr; - isec.skip = RE_SKIP_VLR_NEIGHBOUR | RE_SKIP_VLR_RENDER_CHECK; + isec.check = RE_CHECK_VLR_RENDER; + isec.skip = RE_SKIP_VLR_NEIGHBOUR; isec.hint = 0; isec.hit.ob = 0; @@ -2209,7 +2213,8 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float * RE_rayobject_hint_bb( R.raytree, &bb_hint, min, max); isec->hint = &bb_hint; - isec->skip = RE_SKIP_VLR_NEIGHBOUR | RE_SKIP_VLR_RENDER_CHECK; + isec->check = RE_CHECK_VLR_RENDER; + isec->skip = RE_SKIP_VLR_NEIGHBOUR; VECCOPY(vec, lampco); while (samples < max_samples) { @@ -2378,7 +2383,8 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, float *lampco, floa isec->vec[1] = vec[1]+lampco[1]-isec->start[1]; isec->vec[2] = vec[2]+lampco[2]-isec->start[2]; isec->labda = 1.0f; - isec->skip = RE_SKIP_VLR_NEIGHBOUR | RE_SKIP_VLR_RENDER_CHECK; + isec->check = RE_CHECK_VLR_RENDER; + isec->skip = RE_SKIP_VLR_NEIGHBOUR; if(isec->mode==RE_RAY_SHADOW_TRA) { /* isec.col is like shadfac, so defines amount of light (0.0 is full shadow) */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 37bd823fa23..d955043b1f1 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -41,8 +41,9 @@ #include "BLI_jitter.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "DNA_image_types.h" #include "DNA_lamp_types.h" @@ -2422,7 +2423,8 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) isec.orig.ob = obi; isec.orig.face = vlr; isec.userdata= bs->actob; - isec.skip = RE_SKIP_VLR_NEIGHBOUR|RE_SKIP_VLR_BAKE_CHECK; + isec.check = RE_CHECK_VLR_BAKE; + isec.skip = RE_SKIP_VLR_NEIGHBOUR; if(bake_intersect_tree(R.raytree, &isec, shi->co, shi->vn, sign, co, &dist)) { if(!hit || len_v3v3(shi->co, co) < len_v3v3(shi->co, minco)) { diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 2da2f3633c3..8f28419b9af 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -58,10 +58,11 @@ #include <string.h> #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" + #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_memarena.h" diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index e589bb3a840..8dd07fad022 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -35,13 +35,14 @@ #include "BKE_global.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" + #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_memarena.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "PIL_time.h" @@ -300,8 +301,14 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A DeepSample *ds[RE_MAX_OSA], *sampleds[RE_MAX_OSA], *dsb, *newbuf; APixstr *ap, *apn; APixstrand *aps, *apns; - float visibility, totbuf= shb->totbuf; - int a, b, c, tot, minz, found, size= shb->size, prevtot, newtot; + float visibility; + + const int totbuf= shb->totbuf; + const float totbuf_f= (float)shb->totbuf; + const float totbuf_f_inv= 1.0f/totbuf_f; + const int size= shb->size; + + int a, b, c, tot, minz, found, prevtot, newtot; int sampletot[RE_MAX_OSA], totsample = 0, totsamplec = 0; shsample= MEM_callocN( sizeof(ShadSampleBuf), "shad sample buf"); @@ -456,9 +463,9 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A } if(sampleds[c] == ds[c]) - visibility += 1.0f/totbuf; + visibility += totbuf_f_inv; else - visibility += (ds[c]-1)->v/totbuf; + visibility += (ds[c]-1)->v / totbuf_f; } dsb->v= visibility; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index eb3048a9545..07f09deaf60 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -32,6 +32,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_group_types.h" @@ -40,7 +41,7 @@ #include "DNA_material_types.h" #include "BKE_colortools.h" -#include "BKE_utildefines.h" + #include "BKE_node.h" /* local include */ diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 5eb91845dc2..14af838d826 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -30,13 +30,13 @@ #include <math.h> #include <string.h> - #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_colortools.h" #include "BKE_material.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "DNA_group_types.h" #include "DNA_lamp_types.h" diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 4bccb46d3d8..44c89f8cbd5 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -49,8 +49,10 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_memarena.h" + #include "PIL_time.h" #include "DNA_material_types.h" @@ -61,7 +63,7 @@ #include "BKE_material.h" #include "BKE_node.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" + /* this module */ #include "render_types.h" diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index fbbeceeea2c..099bf76f40b 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -39,12 +39,13 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_memarena.h" #include "BKE_DerivedMesh.h" #include "BKE_key.h" -#include "BKE_utildefines.h" + #include "render_types.h" #include "initrender.h" diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 684732c10d3..1706d63064c 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -30,11 +30,10 @@ #include <string.h> #include <math.h> - - #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "DNA_texture_types.h" #include "DNA_object_types.h" @@ -52,7 +51,7 @@ #include "BKE_image.h" #include "BKE_node.h" #include "BKE_plugin_types.h" -#include "BKE_utildefines.h" + #include "BKE_global.h" #include "BKE_main.h" @@ -1462,7 +1461,6 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg case MTEX_LIGHT: fact*= facg; - facm= 1.0-fact; col= fact*tex[0]; if(col > out[0]) in[0]= col; else in[0]= out[0]; @@ -1565,7 +1563,6 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen break; case MTEX_SOFT_LIGHT: - col= fact*tex; scf=1.0 - (1.0 - tex) * (1.0 - out); in= facm*out + fact * ((1.0 - out) * tex * out) + (out * scf); break; @@ -2364,7 +2361,6 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa /* which coords */ if(mtex->texco==TEXCO_OBJECT) { Object *ob= mtex->object; - ob= mtex->object; if(ob) { VECCOPY(co, xyz); if(mtex->texflag & MTEX_OB_DUPLI_ORIG) { diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index ccdef6006d4..2813df3744f 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -37,6 +37,7 @@ #include "BLI_math.h" #include "BLI_threads.h" #include "BLI_voxel.h" +#include "BLI_utildefines.h" #include "PIL_time.h" diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index fb9b3985cc2..b0aca038e72 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -37,6 +37,7 @@ #include "BLI_math.h" #include "BLI_rand.h" #include "BLI_voxel.h" +#include "BLI_utildefines.h" #include "RE_shader_ext.h" #include "RE_raytrace.h" @@ -93,7 +94,8 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, float *co) } is.mode = RE_RAY_MIRROR; - is.skip = RE_SKIP_VLR_RENDER_CHECK | RE_SKIP_VLR_NON_SOLID_MATERIAL; + is.check = RE_CHECK_VLR_NON_SOLID_MATERIAL; + is.skip = 0; if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) is.lay= lar->lay; @@ -122,6 +124,7 @@ static int vol_get_bounds(ShadeInput *shi, float *co, float *vec, float *hitco, isect->mode= RE_RAY_MIRROR; isect->last_hit = NULL; isect->lay= -1; + isect->check= RE_CHECK_VLR_NONE; if (intersect_type == VOL_BOUNDS_DEPTH) { isect->skip = RE_SKIP_VLR_NEIGHBOUR; @@ -186,6 +189,7 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, float *co, float *co isect.labda = FLT_MAX; isect.mode= RE_RAY_MIRROR; + isect.check = RE_CHECK_VLR_NONE; isect.skip = RE_SKIP_VLR_NEIGHBOUR; isect.orig.ob = (void*) shi->obi; isect.orig.face = (void*)vlr; @@ -734,7 +738,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct { float hitco[3]; float tr[3] = {1.0,1.0,1.0}; - Isect is; + Isect is= {{0}}; float *startco, *endco; int intersect_type = VOL_BOUNDS_DEPTH; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 581dedfe655..2fba1091319 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -35,6 +35,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_voxel.h" +#include "BLI_utildefines.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 1cdb93f0c1f..a3d3a65cccc 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -41,7 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_jitter.h" #include "BLI_threads.h" - +#include "BLI_utildefines.h" #include "MEM_guardedalloc.h" @@ -53,7 +53,7 @@ #include "BKE_global.h" #include "BKE_material.h" -#include "BKE_utildefines.h" + #include "RE_render_ext.h" diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 9c3e19ef4b7..a7aad83d471 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -316,6 +316,7 @@ int WM_framebuffer_to_index(unsigned int col); #define WM_JOB_PRIORITY 1 #define WM_JOB_EXCL_RENDER 2 #define WM_JOB_PROGRESS 4 +#define WM_JOB_SUSPEND 8 struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index bbd22cae0f3..728e5f1a800 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -482,14 +482,14 @@ typedef struct wmDrag { int icon, type; /* type, see WM_DRAG defines above */ void *poin; - char path[FILE_MAX]; + char path[240]; /* FILE_MAX */ double value; struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */ float scale; short sx, sy; - char opname[FILE_MAX]; /* if set, draws operator name*/ + char opname[240]; /* FILE_MAX */ /* if set, draws operator name*/ } wmDrag; /* dropboxes are like keymaps, part of the screen/area/region definition */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 18aa4694d58..6bdb45c3220 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -39,10 +39,11 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #include "GHOST_C-api.h" @@ -568,8 +569,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) wmSubWindowSet(win, screen->mainwin); wm_triple_draw_textures(win, win->drawdata); - - triple= win->drawdata; } else { win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 84c78669c64..0cf3522eaf3 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -41,6 +41,7 @@ #include "GHOST_C-api.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" @@ -50,7 +51,7 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" -#include "BKE_utildefines.h" + #include "BKE_sound.h" #include "ED_fileselect.h" @@ -1478,7 +1479,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) //wm_operator_invoke(C, drop->ot, event, drop->ptr, NULL, FALSE); action |= WM_HANDLER_BREAK; - /* prevent hanging on file read */ + /* XXX fileread case */ + if(CTX_wm_window(C)==NULL) + return action; + BLI_freelistN(event->customdata); event->customdata= NULL; event->custom= 0; @@ -1501,7 +1505,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } } - /* fileread case */ + /* XXX fileread case */ if(CTX_wm_window(C)==NULL) return action; } @@ -1890,14 +1894,20 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval) void WM_event_add_fileselect(bContext *C, wmOperator *op) { - wmEventHandler *handler; + wmEventHandler *handler, *handlernext; wmWindow *win= CTX_wm_window(C); int full= 1; // XXX preset? - /* only allow file selector open per window bug [#23553] */ - for(handler= win->modalhandlers.first; handler; handler=handler->next) { - if(handler->type == WM_HANDLER_FILESELECT) - return; + /* only allow 1 file selector open per window */ + for(handler= win->modalhandlers.first; handler; handler=handlernext) { + handlernext= handler->next; + + if(handler->type == WM_HANDLER_FILESELECT) { + if(handler->op) + WM_operator_free(handler->op); + BLI_remlink(&win->modalhandlers, handler); + wm_event_free_handler(handler); + } } handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler"); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 5938f661ca8..518f7c4997a 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -49,6 +49,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_ipo_types.h" // XXX old animation system @@ -72,7 +73,7 @@ #include "BKE_report.h" #include "BKE_sound.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BLO_readfile.h" #include "BLO_writefile.h" @@ -91,6 +92,7 @@ #include "ED_util.h" #include "GHOST_C-api.h" +#include "GHOST_Path-api.h" #include "UI_interface.h" @@ -275,7 +277,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) retval= BKE_read_exotic(CTX_data_scene(C), name); /* we didn't succeed, now try to read Blender file */ - if (retval== 0) { + if (retval == BKE_READ_EXOTIC_OK_BLEND) { int G_f= G.f; ListBase wmbase; @@ -297,17 +299,14 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) // XXX mainwindow_set_filename_to_title(G.main->name); - if(retval==2) wm_init_userdef(C); // in case a userdef is read from regular .blend + if(retval == BKE_READ_FILE_OK_USERPREFS) wm_init_userdef(C); // in case a userdef is read from regular .blend - if (retval!=0) { + if (retval != BKE_READ_FILE_FAIL) { G.relbase_valid = 1; if(!G.background) /* assume automated tasks with background, dont write recent file list */ write_history(); } -// XXX undo_editmode_clear(); - BKE_reset_undo(); - BKE_write_undo(C, "original"); /* save current state */ WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); // refresh_interface_font(); @@ -319,18 +318,32 @@ void WM_read_file(bContext *C, const 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); + BPY_driver_reset(); + BPY_modules_load_user(C); #endif CTX_wm_window_set(C, NULL); /* exits queues */ + + // XXX undo_editmode_clear(); + BKE_reset_undo(); + BKE_write_undo(C, "original"); /* save current state */ + } - else if(retval==1) + else if(retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); - else if(retval == -1) { - if(reports) - BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Incompatible file format"); + else if(retval == BKE_READ_EXOTIC_FAIL_OPEN) { + BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Unable to open the file"); } - + else if(retval == BKE_READ_EXOTIC_FAIL_FORMAT) { + BKE_reportf(reports, RPT_ERROR, "File format is not supported in file: \"%s\".", name); + } + else if(retval == BKE_READ_EXOTIC_FAIL_PATH) { + BKE_reportf(reports, RPT_ERROR, "File path invalid: \"%s\".", name); + } + else { + BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", name); + BKE_assert(!"invalid 'retval'"); + } + WM_cursor_wait(0); } @@ -369,7 +382,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) wm_window_match_init(C, &wmbase); if (!from_memory && BLI_exists(tstr)) { - success = BKE_read_file(C, tstr, NULL); + success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL); if(U.themes.first==NULL) { printf("\nError: No valid startup.blend, fall back to built-in default.\n\n"); @@ -413,10 +426,10 @@ int WM_read_homefile(bContext *C, wmOperator *op) #ifdef WITH_PYTHON 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_string_exec(C, "__import__('bpy').utils.addon_reset_all()"); - BPY_reset_driver(); - BPY_load_user_modules(C); + BPY_driver_reset(); + BPY_modules_load_user(C); } #endif @@ -509,6 +522,9 @@ static void write_history(void) } fclose(fp); } + + /* also update most recent files on System */ + GHOST_addToSystemRecentFiles(G.main->name); } } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 8d873709212..3c27a71537b 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -37,9 +37,10 @@ #include "BLI_editVert.h" /* lasso tessellation */ #include "BLI_math.h" #include "BLI_scanfill.h" /* lasso tessellation */ +#include "BLI_utildefines.h" #include "BKE_context.h" -#include "BKE_utildefines.h" + #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 181ae62af17..19bb92d72e0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -52,7 +52,7 @@ #include "BKE_main.h" #include "BKE_mball.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + #include "BKE_packedFile.h" #include "BKE_sequencer.h" /* free seq clipboard */ #include "BKE_material.h" /* clear_matcopybuf */ @@ -68,6 +68,7 @@ #ifdef WITH_GAMEENGINE #include "SYS_System.h" #endif +#include "GHOST_Path-api.h" #include "RNA_define.h" @@ -118,6 +119,8 @@ void WM_init(bContext *C, int argc, char **argv) wm_ghost_init(C); /* note: it assigns C to ghost! */ wm_init_cursor_data(); } + GHOST_CreateSystemPaths(); + wm_operatortype_init(); set_free_windowmanager_cb(wm_close_and_free); /* library.c */ @@ -144,11 +147,11 @@ void WM_init(bContext *C, int argc, char **argv) * Will try fix when the crash can be repeated. - campbell. */ #ifdef WITH_PYTHON - BPY_set_context(C); /* necessary evil */ - BPY_start_python(argc, argv); + BPY_context_set(C); /* necessary evil */ + BPY_python_start(argc, argv); - BPY_reset_driver(); - BPY_load_user_modules(C); + BPY_driver_reset(); + BPY_modules_load_user(C); #else (void)argc; /* unused */ (void)argv; /* unused */ @@ -412,7 +415,7 @@ void WM_exit(bContext *C) /* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's * so decref'ing them after python ends causes bad problems every time * the pyDriver bug can be fixed if it happens again we can deal with it then */ - BPY_end_python(); + BPY_python_end(); #endif if (!G.background) { @@ -435,7 +438,7 @@ void WM_exit(bContext *C) UI_exit(); BKE_userdef_free(); - RNA_exit(); /* should be after BPY_end_python so struct python slots are cleared */ + RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */ wm_ghost_exit(); @@ -443,6 +446,9 @@ void WM_exit(bContext *C) #ifdef WITH_GAMEENGINE SYS_DeleteSystem(SYS_GetSystem()); #endif + + GHOST_DisposeSystemPaths(); + if(MEM_get_memory_blocks_in_use()!=0) { printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use()); MEM_printmemlist(); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 41b206f5479..591ed5c33b5 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -247,33 +247,40 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) wmJob *steve; int suspend= 0; - for(steve= wm->jobs.first; steve; steve= steve->next) { - /* obvious case, no test needed */ - if(steve==test || !steve->running) continue; - - /* if new job is not render, then check for same startjob */ - if(0==(test->flag & WM_JOB_EXCL_RENDER)) - if(steve->startjob!=test->startjob) - continue; - - /* if new job is render, any render job should be stopped */ - if(test->flag & WM_JOB_EXCL_RENDER) - if(0==(steve->flag & WM_JOB_EXCL_RENDER)) - continue; - + /* job added with suspend flag, we wait 1 timer step before activating it */ + if(test->flag & WM_JOB_SUSPEND) { suspend= 1; + test->flag &= ~WM_JOB_SUSPEND; + } + else { + /* check other jobs */ + for(steve= wm->jobs.first; steve; steve= steve->next) { + /* obvious case, no test needed */ + if(steve==test || !steve->running) continue; + + /* if new job is not render, then check for same startjob */ + if(0==(test->flag & WM_JOB_EXCL_RENDER)) + if(steve->startjob!=test->startjob) + continue; + + /* if new job is render, any render job should be stopped */ + if(test->flag & WM_JOB_EXCL_RENDER) + if(0==(steve->flag & WM_JOB_EXCL_RENDER)) + continue; - /* if this job has higher priority, stop others */ - if(test->flag & WM_JOB_PRIORITY) { - steve->stop= 1; - // printf("job stopped: %s\n", steve->name); + suspend= 1; + + /* if this job has higher priority, stop others */ + if(test->flag & WM_JOB_PRIORITY) { + steve->stop= 1; + // printf("job stopped: %s\n", steve->name); + } } } - + /* possible suspend ourselfs, waiting for other jobs, or de-suspend */ test->suspended= suspend; // if(suspend) printf("job suspended: %s\n", test->name); - } /* if job running, the same owner gave it a new job */ @@ -283,8 +290,10 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) if(steve->running) { /* signal job to end and restart */ steve->stop= 1; + // printf("job started a running job, ending... %s\n", steve->name); } else { + if(steve->customdata && steve->startjob) { wm_jobs_test_suspend_stop(wm, steve); @@ -304,10 +313,10 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) steve->ready= 0; steve->progress= 0.0; + // printf("job started: %s\n", steve->name); + BLI_init_threads(&steve->threads, do_job_thread, 1); BLI_insert_thread(&steve->threads, steve); - - // printf("job started: %s\n", steve->name); } /* restarted job has timer already */ @@ -431,8 +440,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) steve->run_customdata= NULL; steve->run_free= NULL; - // if(steve->stop) printf("job stopped\n"); - // else printf("job finished\n"); + // if(steve->stop) printf("job ready but stopped %s\n", steve->name); + // else printf("job finished %s\n", steve->name); steve->running= 0; BLI_end_threads(&steve->threads); @@ -444,6 +453,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) /* new job added for steve? */ if(steve->customdata) { + // printf("job restarted with new data %s\n", steve->name); WM_jobs_start(wm, steve); } else { diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index a3f662cbbf3..7d67245d077 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -37,6 +37,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" @@ -44,7 +45,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_screen.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" #include "RNA_enum_types.h" diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index de3773c192b..605da96acea 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -40,6 +40,8 @@ #include <io.h> #endif +#include "MEM_guardedalloc.h" + #include "DNA_ID.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" @@ -47,8 +49,6 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "MEM_guardedalloc.h" - #include "BLF_api.h" #include "PIL_time.h" @@ -56,6 +56,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" /*for WM_operator_pystring */ #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLO_readfile.h" @@ -69,7 +70,7 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" /* BKE_ST_MAXNAME */ -#include "BKE_utildefines.h" + #include "BKE_idcode.h" #include "BIF_gl.h" @@ -2686,8 +2687,6 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glutil_draw_lined_arc(0.0, M_PI*2.0, r1, 40); glutil_draw_lined_arc(0.0, M_PI*2.0, r2, 40); glDisable(GL_BLEND); - - glPopMatrix(); } int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 271b32359f5..c08df0ccd75 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -39,8 +39,9 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + -#include "BKE_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 723286b09ce..db427ea68d1 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -41,13 +41,14 @@ #include "GHOST_C-api.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index e81a6affc44..5fd58128f6a 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -263,6 +263,11 @@ void ED_object_constraint_dependency_update(struct Scene *scene, struct Object * void ED_object_constraint_update(struct Object *ob){} struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, char *name){return (struct bDeformGroup *) NULL;} void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode){} +void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum){} +void ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum){} +void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup){} +void ED_vgroup_object_is_edit_mode(struct Object *ob){} + void ED_sequencer_update_view(struct bContext *C, int view){} float ED_rollBoneToVector(struct EditBone *bone, float new_up_axis[3]){return 0.0f;} void ED_space_image_size(struct SpaceImage *sima, int *width, int *height){} @@ -291,6 +296,8 @@ struct uiLayout *uiLayoutColumn(struct uiLayout *layout, int align){return (stru struct uiLayout *uiLayoutColumnFlow(struct uiLayout *layout, int number, int align){return (struct uiLayout *) NULL;} struct uiLayout *uiLayoutBox(struct uiLayout *layout){return (struct uiLayout *) NULL;} struct uiLayout *uiLayoutSplit(struct uiLayout *layout, float percentage, int align){return (struct uiLayout *) NULL;} +int uiLayoutGetRedAlert(struct uiLayout *layout){return 0;} +void uiLayoutSetRedAlert(struct uiLayout *layout, int redalert){} void uiItemsEnumR(struct uiLayout *layout, struct PointerRNA *ptr, char *propname){} void uiItemMenuEnumR(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, char *name, int icon){} void uiItemEnumR_string(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, char *value, char *name, int icon){} @@ -376,15 +383,13 @@ char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value){return (struct wmKeyMapItem *)NULL;} struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items){return (struct wmKeyMap *) NULL;} -/* RNA Collada dependency */ -int collada_export(struct Scene *sce, const char *filepath){return 0;} - - /* intern/decimation */ +#if 1 int LOD_FreeDecimationData(struct LOD_Decimation_Info *info){return 0;} int LOD_CollapseEdge(struct LOD_Decimation_Info *info){return 0;} int LOD_PreprocessMesh(struct LOD_Decimation_Info *info){return 0;} int LOD_LoadMesh(struct LOD_Decimation_Info *info){return 0;} +#endif /* smoke */ void LzmaCompress(void) { return; } @@ -430,6 +435,7 @@ void sculpt_set_brush_alpha(struct Brush *brush, float alpha){} char blender_path[] = ""; /* CSG */ +#if 1 struct CSG_BooleanOperation * CSG_NewBooleanFunction( void ){return (struct CSG_BooleanOperation *) NULL;} void CSG_FreeBooleanOperation(struct CSG_BooleanOperation *operation){return;} void CSG_FreeFaceDescriptor(struct CSG_FaceIteratorDescriptor * f_descriptor){return;} @@ -450,4 +456,5 @@ int CSG_PerformBooleanOperation( CSG_VertexIteratorDescriptor obBVertices) { return 0;} +#endif #endif // WITH_GAMEENGINE diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index bca42fc39b7..c46f6935a7b 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -558,7 +558,7 @@ endif() ge_scenegraph ge_logic_network bf_gen_system - bf_python # duplicate for BPY_eval_driver + bf_python # duplicate for BPY_driver_exec ge_logic_ngnetwork extern_bullet ge_logic_loopbacknetwork diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c index 2203a97aa91..c3b9ea56c45 100644 --- a/source/creator/buildinfo.c +++ b/source/creator/buildinfo.c @@ -28,7 +28,10 @@ */ #ifdef BUILD_DATE -#include "BKE_utildefines.h" + +/* copied from BLI_utildefines.h */ +#define STRINGIFY_ARG(x) #x +#define STRINGIFY(x) STRINGIFY_ARG(x) char build_date[]= STRINGIFY(BUILD_DATE); char build_time[]= STRINGIFY(BUILD_TIME); diff --git a/source/creator/creator.c b/source/creator/creator.c index a83cfc62e14..7d78bb1e439 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -58,6 +58,7 @@ #include "BLI_args.h" #include "BLI_threads.h" #include "BLI_scanfill.h" // for BLI_setErrorCallBack, TODO, move elsewhere +#include "BLI_utildefines.h" #include "DNA_ID.h" #include "DNA_scene_types.h" @@ -863,7 +864,7 @@ static int run_python(int argc, char **argv, void *data) BLI_strncpy(filename, argv[1], sizeof(filename)); BLI_path_cwd(filename); - BPY_CTX_SETUP( BPY_run_python_script(C, filename, NULL, NULL) ) + BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)) return 1; } else { @@ -880,10 +881,9 @@ static int run_python(int argc, char **argv, void *data) static int run_python_console(int UNUSED(argc), char **argv, void *data) { #ifdef WITH_PYTHON - bContext *C = data; - const char *expr= "__import__('code').interact()"; + bContext *C = data; - BPY_CTX_SETUP( BPY_eval_string(C, expr) ) + BPY_CTX_SETUP(BPY_string_exec(C, "__import__('code').interact()")) return 0; #else @@ -907,7 +907,7 @@ static int load_file(int UNUSED(argc), char **argv, void *data) /*we successfully loaded a blend file, get sure that pointcache works */ - if (retval!=0) { + if (retval != BKE_READ_FILE_FAIL) { wmWindowManager *wm= CTX_wm_manager(C); /* special case, 2.4x files */ @@ -928,8 +928,8 @@ 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); + BPY_driver_reset(); + BPY_modules_load_user(C); #endif /* happens for the UI on file reading too (huh? (ton))*/ @@ -1161,7 +1161,7 @@ int main(int argc, char **argv) * NOTE: the U.pythondir string is NULL until WM_init() is executed, * so we provide the BPY_ function below to append the user defined * pythondir to Python's sys.path at this point. Simply putting - * WM_init() before BPY_start_python() crashes Blender at startup. + * WM_init() before BPY_python_start() crashes Blender at startup. * Update: now this function also inits the bpymenus, which also depend * on U.pythondir. */ diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index c9d85e6b48f..e5179e8926f 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -77,7 +77,7 @@ extern "C" { #include "BKE_global.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + //XXX #include "BIF_screen.h" //XXX #include "BIF_scrarea.h" diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 39e3e87708e..ac35007129a 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -39,16 +39,17 @@ #include "BL_SkinDeformer.h" #include "KX_GameObject.h" #include "STR_HashedString.h" +#include "MEM_guardedalloc.h" #include "DNA_nla_types.h" -#include "BKE_action.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_scene_types.h" -#include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "MT_Matrix4x4.h" -#include "BKE_utildefines.h" + +#include "BKE_action.h" #include "FloatValue.h" #include "PyObjectPlus.h" #include "KX_PyMath.h" diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 0c5bb036b04..be42b80f916 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -32,12 +32,13 @@ #include "KX_BlenderSceneConverter.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_ghash.h" #include "BLI_math.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "BIK_api.h" #include "BKE_action.h" #include "BKE_armature.h" -#include "BKE_utildefines.h" + #include "BKE_constraint.h" #include "GEN_Map.h" #include "GEN_HashedPtr.h" diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 47e31585148..3cdc688f55d 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -91,7 +91,7 @@ #include "BL_MeshDeformer.h" #include "KX_SoftBodyDeformer.h" //#include "BL_ArmatureController.h" - +#include "BLI_utildefines.h" #include "BlenderWorldInfo.h" #include "KX_KetsjiEngine.h" @@ -126,7 +126,7 @@ #include "DNA_object_force.h" #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" + #include "BKE_key.h" #include "BKE_mesh.h" #include "MT_Point3.h" diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index 7bf83315d65..5eb25b05567 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -49,6 +49,7 @@ #include "DNA_curve_types.h" #include "DNA_modifier_types.h" #include "DNA_scene_types.h" +#include "BLI_utildefines.h" #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_key.h" @@ -61,7 +62,7 @@ extern "C"{ #include "BKE_lattice.h" #include "BKE_modifier.h" } - #include "BKE_utildefines.h" + #include "BLI_blenlib.h" #include "BLI_math.h" diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index ccd7dc6f745..4f6e07206dd 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -48,7 +48,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "MT_Matrix4x4.h" -#include "BKE_utildefines.h" + #include "FloatValue.h" #include "PyObjectPlus.h" diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 2fc78646d92..a5fd797852f 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -55,7 +55,7 @@ extern "C"{ #include "BKE_lattice.h" } - #include "BKE_utildefines.h" + #include "BLI_blenlib.h" #include "BLI_math.h" @@ -154,7 +154,7 @@ bool BL_ShapeDeformer::Update(void) /* store verts locally */ VerifyStorage(); - do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_bmesh->key, NULL, 0); + do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_bmesh->key, NULL, 0); /* last arg is ignored */ m_bDynamic = true; } diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 748df4c2e41..3bac525d765 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -42,6 +42,7 @@ #include "DNA_action_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "BLI_utildefines.h" #include "BKE_armature.h" #include "BKE_action.h" #include "MT_Point3.h" @@ -49,7 +50,7 @@ extern "C"{ #include "BKE_lattice.h" } - #include "BKE_utildefines.h" + #include "BLI_blenlib.h" #include "BLI_math.h" diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 51cd323a375..b5b6851bc52 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -347,13 +347,11 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, if (mode == RAS_IRenderTools::RAS_TEXT_PADDED) { glColor3ub(0, 0, 0); - glRasterPos2s(xco+1, height-yco-1); - // XXX BMF_DrawString(m_font, s); + BLF_draw_default(xco+1, height-yco-1, 0.f, text, strlen(text)); } glColor3ub(255, 255, 255); - glRasterPos2s(xco, height-yco); - // XXX BMF_DrawString(m_font, s); + BLF_draw_default(xco, height-yco, 0.f, text, strlen(text)); // Restore view settings glMatrixMode(GL_PROJECTION); diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 37314e80dc6..54f2d05fb28 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -30,6 +30,7 @@ #include "DNA_curve_types.h" #include "KX_Scene.h" #include "KX_PythonInit.h" +#include "BLI_math.h" extern "C" { #include "BLF_api.h" @@ -45,7 +46,6 @@ KX_FontObject::KX_FontObject( void* sgReplicationInfo, m_object(ob), m_dpi(72), m_resolution(1.f), - m_color(ob->col), /* initial color - non-animatable */ m_rendertools(rendertools) { Curve *text = static_cast<Curve *> (ob->data); @@ -64,6 +64,12 @@ KX_FontObject::KX_FontObject( void* sgReplicationInfo, m_fontid = BLF_load(filepath); if (m_fontid == -1) m_fontid = BLF_load("default"); + + /* initialize the color with the object color and store it in the KX_Object class + This is a workaround waiting for the fix: + [#25487] BGE: Object Color only works when it has a keyed frame */ + copy_v4_v4(m_color, (const float*) ob->col); + this->SetObjectColor((const MT_Vector4&) m_color); } KX_FontObject::~KX_FontObject() @@ -89,12 +95,16 @@ void KX_FontObject::DrawText() /* only draws the text if visible */ if(this->GetVisible() == 0) return; + /* update the animated color */ + this->GetObjectColor().getValue(m_color); + /* XXX 2DO - handle multiple lines */ /* HARDCODED MULTIPLICATION FACTOR - this will affect the render resolution directly */ float RES = BGE_FONT_RES * m_resolution; float size = m_fsize * m_object->size[0] * RES; float aspect = 1.f / (m_object->size[0] * RES); + m_rendertools->RenderText3D(m_fontid, m_text, int(size), m_dpi, m_color, this->GetOpenGLMatrix(), aspect); } @@ -137,7 +147,7 @@ PyMethodDef KX_FontObject::Methods[] = { }; PyAttributeDef KX_FontObject::Attributes[] = { - KX_PYATTRIBUTE_STRING_RW("text", 0, 140, false, KX_FontObject, m_text), + KX_PYATTRIBUTE_STRING_RW("text", 0, 280, false, KX_FontObject, m_text), //arbitrary limit. 280 = 140 unicode chars in unicode KX_PYATTRIBUTE_FLOAT_RW("size", 0.0001f, 10000.0f, KX_FontObject, m_fsize), KX_PYATTRIBUTE_FLOAT_RW("resolution", 0.0001f, 10000.0f, KX_FontObject, m_resolution), /* KX_PYATTRIBUTE_INT_RW("dpi", 0, 10000, false, KX_FontObject, m_dpi), */// no real need for expose this I think diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index 21fe1f0e9ea..a4f9692da57 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -60,7 +60,7 @@ protected: int m_dpi; float m_fsize; float m_resolution; - float* m_color; + float m_color[4]; class RAS_IRenderTools* m_rendertools; //needed for drawing routine diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index dc3ff5543f9..61e7f0451d1 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -103,11 +103,12 @@ public: KX_ACT_IPO_MAX }; +#ifdef WITH_PYTHON static PyObject* pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - +#endif static const char *S_KX_ACT_IPO_PLAY_STRING; static const char *S_KX_ACT_IPO_PINGPONG_STRING; static const char *S_KX_ACT_IPO_FLIPPER_STRING; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 48e002fc3c2..f5a9e438e1a 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -232,7 +232,7 @@ static PyObject* gPyExpandPath(PyObject*, PyObject* args) BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); BLI_path_abs(expanded, gp_GamePythonPath); - return PyUnicode_FromString(expanded); + return PyUnicode_DecodeFSDefault(expanded); } static char gPyStartGame_doc[] = @@ -498,7 +498,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) while ((dirp = readdir(dp)) != NULL) { if (BLI_testextensie(dirp->d_name, ".blend")) { - value = PyUnicode_FromString(dirp->d_name); + value= PyUnicode_DecodeFSDefault(dirp->d_name); PyList_Append(list, value); Py_DECREF(value); } @@ -1826,7 +1826,7 @@ static void initPySysObjects__append(PyObject *sys_path, char *filename) BLI_split_dirfile(filename, expanded, NULL); /* get the dir part of filename only */ BLI_path_abs(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */ BLI_cleanup_file(gp_GamePythonPath, expanded); /* Dont use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */ - item= PyUnicode_FromString(expanded); + item= PyUnicode_DecodeFSDefault(expanded); // printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath); @@ -1917,7 +1917,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur PyObject *py_argv= PyList_New(argc); for (i=0; i<argc; i++) - PyList_SET_ITEM(py_argv, i, PyUnicode_FromString(argv[i])); + PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i])); PySys_SetObject("argv", py_argv); Py_DECREF(py_argv); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 122a738e4f3..e8c2db5526a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -784,6 +784,13 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi) current_mesh = ms.m_mesh; current_wireframe = wireframe; MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); + + // handle two-side + if (current_polymat->GetDrawingMode() & RAS_IRasterizer::KX_TWOSIDE) + this->SetCullFace(false); + else + this->SetCullFace(true); + if (current_polymat->GetFlag() & RAS_BLENDERGLSL) { // GetMaterialIndex return the original mface material index, // increment by 1 to match what derived mesh is doing |